com.northconcepts.datapipeline.core
Class DataEndpoint

java.lang.Object
  extended by com.northconcepts.datapipeline.core.DataEndpoint
Direct Known Subclasses:
DataEndpointGroup, DataReader, DataWriter

public abstract class DataEndpoint
extends Object

Abstract super-class for reading and writing records. Common operations like open(), close(), and getRecordCount() are defined here.


Nested Class Summary
static class DataEndpoint.State
           
 
Field Summary
static int BUFFER_SIZE
           
static org.apache.log4j.Logger log
           
 
Constructor Summary
DataEndpoint()
           
 
Method Summary
 DataException addExceptionProperties(DataException exception)
          Adds this endpoint's current state to a DataException.
 void assertNotOpened()
          Asserts that this endpoint has not yet started reading or writing, otherwise an exception is thrown.
 void assertOpened()
          Asserts that this endpoint has started reading or writing, otherwise an exception is thrown.
 void close()
          Indicates that this endpoint has finished reading or writing.
protected  void decrementRecordCount()
          Reduces this endpoint's record-count by 1.
 DataException exception(String message)
          Creates an exception with the specified message and containing this endpoint's properties (name-value pairs).
 DataException exception(String message, Throwable exception)
          Converts an exception to a DataException, prefixing the original message with the specified text and adding this endpoint's properties (name-value pairs).
 DataException exception(Throwable exception)
          Converts an exception to a DataException and adds this endpoint's properties (name-value pairs).
protected  void finalize()
          Closes this endpoint if it's still open.
 String getDescription()
           
 long getRecordCount()
          Returns this endpoint's record-count as a long.
 BigInteger getRecordCountAsBigInteger()
          Returns this endpoint's record-count as a BigInteger.
 String getRecordCountAsString()
          Returns this endpoint's record-count as a String.
 DataEndpoint.State getState()
           
protected  void incrementRecordCount()
          Increases this endpoint's record-count by 1.
 boolean isClosed()
          Indicates if this endpoint has finished transferring data.
 boolean isOpen()
          Indicates if this endpoint is ready for reading or writing.
 boolean isRecordCountBigInteger()
          Indicates if this endpoint's record-count is too big (over 1000000000000000000L or 1.0e+18) for a long and should be retrieved as a BigInteger using getRecordCountAsBigInteger().
 void open()
          Makes this endpoint ready for reading or writing.
protected  void resetRecordCount()
          Restarts this endpoint's record-count at 0.
 DataEndpoint setDescription(String description)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

DataEndpoint

public DataEndpoint()
Method Detail

getDescription

public String getDescription()

setDescription

public DataEndpoint setDescription(String description)

open

public void open()
          throws DataException
Makes this endpoint ready for reading or writing.

Throws:
DataException

close

public void close()
           throws DataException
Indicates that this endpoint has finished reading or writing.

Throws:
DataException

getState

public DataEndpoint.State getState()

isOpen

public boolean isOpen()
Indicates if this endpoint is ready for reading or writing.


isClosed

public boolean isClosed()
Indicates if this endpoint has finished transferring data.


assertOpened

public void assertOpened()
Asserts that this endpoint has started reading or writing, otherwise an exception is thrown.


assertNotOpened

public void assertNotOpened()
Asserts that this endpoint has not yet started reading or writing, otherwise an exception is thrown.


addExceptionProperties

public DataException addExceptionProperties(DataException exception)
Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.


exception

public DataException exception(String message,
                               Throwable exception)
Converts an exception to a DataException, prefixing the original message with the specified text and adding this endpoint's properties (name-value pairs).

The returned exception can then be thrown in the normal way.

If the supplied exception is an instanceof DataException, it will be returned, otherwise it will be nested inside a DataException. In either case the result message will contain the new prefix along with this endpoint properties.


exception

public DataException exception(Throwable exception)
Converts an exception to a DataException and adds this endpoint's properties (name-value pairs).

The returned exception can then be thrown in the normal way.

If the supplied exception is an instanceof DataException, it will be returned, otherwise it will be nested inside a DataException. In either case the result message will contain this endpoint properties.


exception

public DataException exception(String message)
Creates an exception with the specified message and containing this endpoint's properties (name-value pairs).

The returned exception can then be thrown in the normal way.


finalize

protected void finalize()
                 throws Throwable
Closes this endpoint if it's still open.

Overrides:
finalize in class Object
Throws:
Throwable

toString

public String toString()
Overrides:
toString in class Object

incrementRecordCount

protected void incrementRecordCount()
Increases this endpoint's record-count by 1.

See Also:
getRecordCountAsBigInteger(), getRecordCount(), isRecordCountBigInteger()

decrementRecordCount

protected void decrementRecordCount()
Reduces this endpoint's record-count by 1.

See Also:
getRecordCountAsBigInteger(), getRecordCount(), isRecordCountBigInteger()

resetRecordCount

protected void resetRecordCount()
Restarts this endpoint's record-count at 0.

See Also:
getRecordCountAsBigInteger(), getRecordCount(), isRecordCountBigInteger()

isRecordCountBigInteger

public boolean isRecordCountBigInteger()
Indicates if this endpoint's record-count is too big (over 1000000000000000000L or 1.0e+18) for a long and should be retrieved as a BigInteger using getRecordCountAsBigInteger().

See Also:
getRecordCountAsBigInteger(), getRecordCount()

getRecordCount

public long getRecordCount()
Returns this endpoint's record-count as a long. If the count grows above 1000000000000000000L or 1.0e+18, it will wrap to 1, but getRecordCountAsBigInteger() will contain the full value.

See Also:
getRecordCountAsBigInteger(), isRecordCountBigInteger()

getRecordCountAsBigInteger

public BigInteger getRecordCountAsBigInteger()
Returns this endpoint's record-count as a BigInteger.

See Also:
getRecordCount(), isRecordCountBigInteger()

getRecordCountAsString

public String getRecordCountAsString()
Returns this endpoint's record-count as a String.

See Also:
getRecordCountAsBigInteger(), getRecordCount(), isRecordCountBigInteger()


Copyright (c) 2007-2012 North Concepts Inc. All Rights Reserved.