org.jboss.dna.sequencer.text
Class AbstractTextSequencer

java.lang.Object
  extended by org.jboss.dna.sequencer.text.AbstractTextSequencer
All Implemented Interfaces:
StreamSequencer
Direct Known Subclasses:
DelimitedTextSequencer, FixedWidthTextSequencer

@ThreadSafe
public abstract class AbstractTextSequencer
extends Object
implements StreamSequencer

The base class for the text sequencers. This class treats the text to be sequenced as a series of rows, with each row delimited by a line terminator. Concrete subclasses provide their own mechanisms for splitting a row of data into a series of columns.

This class provides some fundamental capabilities, including the ability to set a comment marker, limit the number of lines to be read from a file, and provide custom transformations from the sets of columns to the graph structure.


Constructor Summary
AbstractTextSequencer()
           
 
Method Summary
 String getCommentMarker()
           
 int getMaximumLinesToRead()
           
 String getRowFactoryClassName()
           
 void sequence(InputStream stream, SequencerOutput output, StreamSequencerContext context)
          Sequence the data found in the supplied stream, placing the output information into the supplied map.
 void setCommentMarker(String commentMarker)
          Sets the comment marker to use.
 void setMaximumLinesToRead(int maximumLinesToRead)
          Sets the maximum number of lines to read.
 void setRowFactoryClassName(String rowFactoryClassName)
          Sets the custom row factory class name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTextSequencer

public AbstractTextSequencer()
Method Detail

sequence

public void sequence(InputStream stream,
                     SequencerOutput output,
                     StreamSequencerContext context)
Sequence the data found in the supplied stream, placing the output information into the supplied map.

JBoss DNA's SequencingService determines the sequencers that should be executed by monitoring the changes to one or more workspaces that it is monitoring. Changes in those workspaces are aggregated and used to determine which sequencers should be called. If the sequencer implements this interface, then this method is called with the property that is to be sequenced along with the interface used to register the output. The framework takes care of all the rest.

Specified by:
sequence in interface StreamSequencer
Parameters:
stream - the stream with the data to be sequenced; never null
output - the output from the sequencing operation; never null
context - the context for the sequencing operation; never null

setCommentMarker

public void setCommentMarker(String commentMarker)
Sets the comment marker to use. Any line that begins with the comment marker will be ignored and will not be counted as a read line for the purposes of the maximum line limitation.

Parameters:
commentMarker - the string that indicates that the line is a comment and should be ignored; null indicates that there is no comment marker

getCommentMarker

public String getCommentMarker()
Returns:
the current comment marker; may be null

getMaximumLinesToRead

public int getMaximumLinesToRead()
Returns:
the maximum number of lines to read when sequencing; non-positive numbers indicate that all lines should be read and sequenced

setMaximumLinesToRead

public void setMaximumLinesToRead(int maximumLinesToRead)
Sets the maximum number of lines to read. When this number is reached during the sequencing of any particular stream, the stream will be closed and remaining lines (if any) will be ignored. Comment lines do not count towards the number of lines read.

Parameters:
maximumLinesToRead - the maximum number of lines to read; a non-positive number indicates that all lines should be read and sequenced.

getRowFactoryClassName

public String getRowFactoryClassName()
Returns:
the current row factory class name; may not be null

setRowFactoryClassName

public void setRowFactoryClassName(String rowFactoryClassName)
                            throws ClassNotFoundException,
                                   IllegalAccessException,
                                   InstantiationException
Sets the custom row factory class name. This method attempts to instantiate an instance of the custom RowFactory class prior to modifying the row factory class name to ensure that the new value represents a valid implementation.

Parameters:
rowFactoryClassName - the fully-qualified class name of the new custom row factory implementation; null indicates that the default row factory should be used.
Throws:
ClassNotFoundException - if the the named row factory class cannot be located
IllegalAccessException - if the row factory class or its nullary constructor is not accessible.
InstantiationException - if the row factory represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ClassCastException - if the instantiated row factory does not implement the RowFactory interface


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.