- java.lang.Object
-
- de.siegmar.fastcsv.reader.CollectingStatusListener
-
- All Implemented Interfaces:
StatusListener
public class CollectingStatusListener extends java.lang.Object implements StatusListener
Implementation ofStatusListener
that collects updates.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicLong
byteCount
private boolean
completionStatus
private java.lang.Throwable
failedThrowable
private long
fileSize
private java.util.concurrent.atomic.AtomicLong
recordCount
-
Constructor Summary
Constructors Constructor Description CollectingStatusListener()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getByteCount()
Get the number of bytes already read.long
getFileSize()
Get the total size in bytes.long
getRecordCount()
Get the number of records already indexed.java.lang.Throwable
getThrowable()
Get the throwable that occurred while indexing.boolean
isCompleted()
Get the completion status.void
onComplete()
Called when the indexing finished successfully (without an exception).void
onError(java.lang.Throwable throwable)
Called when there was an error while indexing.void
onInit(long fileSize)
Called on initialization.void
onReadBytes(int bytes)
Called when a new read operation has been performend.void
onReadRecord()
Called when a new record has been read.java.lang.String
toString()
-
-
-
Field Detail
-
fileSize
private volatile long fileSize
-
recordCount
private final java.util.concurrent.atomic.AtomicLong recordCount
-
byteCount
private final java.util.concurrent.atomic.AtomicLong byteCount
-
completionStatus
private volatile boolean completionStatus
-
failedThrowable
private volatile java.lang.Throwable failedThrowable
-
-
Method Detail
-
onInit
public void onInit(long fileSize)
Description copied from interface:StatusListener
Called on initialization.- Specified by:
onInit
in interfaceStatusListener
- Parameters:
fileSize
- the total file size.
-
getFileSize
public long getFileSize()
Get the total size in bytes.- Returns:
- the total size in bytes
-
onReadRecord
public void onReadRecord()
Description copied from interface:StatusListener
Called when a new record has been read.- Specified by:
onReadRecord
in interfaceStatusListener
-
getRecordCount
public long getRecordCount()
Get the number of records already indexed.- Returns:
- the number of records already indexed
-
onReadBytes
public void onReadBytes(int bytes)
Description copied from interface:StatusListener
Called when a new read operation has been performend.- Specified by:
onReadBytes
in interfaceStatusListener
- Parameters:
bytes
- number of bytes read.
-
getByteCount
public long getByteCount()
Get the number of bytes already read.- Returns:
- the number of bytes already read
-
onComplete
public void onComplete()
Description copied from interface:StatusListener
Called when the indexing finished successfully (without an exception).- Specified by:
onComplete
in interfaceStatusListener
-
isCompleted
public boolean isCompleted()
Get the completion status.- Returns:
true
, when all data have been indexed successfully
-
onError
public void onError(java.lang.Throwable throwable)
Description copied from interface:StatusListener
Called when there was an error while indexing.- Specified by:
onError
in interfaceStatusListener
- Parameters:
throwable
- the exception thrown.
-
getThrowable
public java.lang.Throwable getThrowable()
Get the throwable that occurred while indexing.- Returns:
- the throwable that occurred while indexing,
null
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-