- java.lang.Object
-
- de.siegmar.fastcsv.reader.CollectingStatusListener
-
- All Implemented Interfaces:
StatusListener
public class CollectingStatusListener extends java.lang.Object implements StatusListener
Implementation ofStatusListenerthat collects updates.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicLongbyteCountprivate booleancompletionStatusprivate java.lang.ThrowablefailedThrowableprivate longfileSizeprivate java.util.concurrent.atomic.AtomicLongrecordCount
-
Constructor Summary
Constructors Constructor Description CollectingStatusListener()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetByteCount()Get the number of bytes already read.longgetFileSize()Get the total size in bytes.longgetRecordCount()Get the number of records already indexed.java.lang.ThrowablegetThrowable()Get the throwable that occurred while indexing.booleanisCompleted()Get the completion status.voidonComplete()Called when the indexing finished successfully (without an exception).voidonError(java.lang.Throwable throwable)Called when there was an error while indexing.voidonInit(long fileSize)Called on initialization.voidonReadBytes(int bytes)Called when a new read operation has been performend.voidonReadRecord()Called when a new record has been read.java.lang.StringtoString()
-
-
-
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:StatusListenerCalled on initialization.- Specified by:
onInitin 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:StatusListenerCalled when a new record has been read.- Specified by:
onReadRecordin 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:StatusListenerCalled when a new read operation has been performend.- Specified by:
onReadBytesin 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:StatusListenerCalled when the indexing finished successfully (without an exception).- Specified by:
onCompletein 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:StatusListenerCalled when there was an error while indexing.- Specified by:
onErrorin 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,
nullotherwise.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-