ModeShape Distribution 3.0.0.Beta4

Class AbstractTextSequencer

  extended by org.modeshape.jcr.api.sequencer.Sequencer
      extended by org.modeshape.sequencer.text.AbstractTextSequencer
Direct Known Subclasses:
DelimitedTextSequencer, FixedWidthTextSequencer

public abstract class AbstractTextSequencer
extends Sequencer

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.

Nested Class Summary
Nested classes/interfaces inherited from class org.modeshape.jcr.api.sequencer.Sequencer
Constructor Summary
Method Summary
 boolean execute(Property inputProperty, Node outputNode, Sequencer.Context context)
          Execute the sequencing operation on the specified property, which has recently been created or changed.
 String getCommentMarker()
 int getMaximumLinesToRead()
 String getRowFactoryClassName()
 void initialize(NamespaceRegistry registry, NodeTypeManager nodeTypeManager)
          Initialize the sequencer.
protected abstract  String[] parseLine(String row)
          Parse the given row into its constituent columns.
 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 org.modeshape.jcr.api.sequencer.Sequencer
getAcceptedMimeTypes, getLogger, getName, getPathExpressions, getRepositoryName, getUniqueId, hasAcceptedMimeTypes, isAccepted, registerDefaultMimeTypes, registerNamespace, registerNodeTypes, registerNodeTypes, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public AbstractTextSequencer()
Method Detail


public void initialize(NamespaceRegistry registry,
                       NodeTypeManager nodeTypeManager)
                throws RepositoryException,
Description copied from class: Sequencer
Initialize the sequencer. This is called automatically by ModeShape once for each Sequencer instance, and should not be called by the sequencer.

By default this method does nothing, so it should be overridden by implementations to do a one-time initialization of any internal components. For example, sequencers can use the supplied registry and nodeTypeManager objects to register custom namesapces and node types required by the generated content.

initialize in class Sequencer
registry - the namespace registry that can be used to register custom namespaces; never null
nodeTypeManager - the node type manager that can be used to register custom node types; never null
RepositoryException - if operations on the NamespaceRegistry or NodeTypeManager fail
IOException - if any stream based operations fail (like importing cnd files)


public boolean execute(Property inputProperty,
                       Node outputNode,
                       Sequencer.Context context)
                throws Exception
Description copied from class: Sequencer
Execute the sequencing operation on the specified property, which has recently been created or changed.

Each sequencer is expected to process the value of the property, extract information from the value, and write a structured representation (in the form of a node or a subgraph of nodes) using the supplied output node. Note that the output node will either be:

  1. the selected node, in which case the sequencer was configured to generate the output information directly under the selected input node; or
  2. a newly created node in a different location than node being sequenced (in this case, the primary type of the new node will be 'nt:unstructured', but the sequencer can easily change that using Node.setPrimaryType(String))

The implementation is expected to always clean up all resources that it acquired, even in the case of exceptions.

Note: This method must be threadsafe: ModeShape will likely invoke this method concurrently in separate threads, and the method should never modify the state or fields of the Sequencer implementation class. All initialization should be performed in Sequencer.initialize(NamespaceRegistry, NodeTypeManager).

Specified by:
execute in class Sequencer
inputProperty - the property that was changed and that should be used as the input; never null
outputNode - the node that represents the output for the derived information; never null, and will either be new if the output is being placed outside of the selected node, or will not be new when the output is to be placed on the selected input node
context - the context in which this sequencer is executing, and which may contain additional parameters useful when generating the output structure; never null
true if the sequencer's output should be saved, or false otherwise
Exception - if there was a problem with the sequencer that could not be handled. All exceptions will be logged automatically as errors by ModeShape.


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.

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


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


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


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.

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


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


public void setRowFactoryClassName(String rowFactoryClassName)
Sets the custom row factory class name.

rowFactoryClassName - the fully-qualified class name of the new custom row factory implementation; null indicates that the default row factory should be used.


protected abstract String[] parseLine(String row)
Parse the given row into its constituent columns.

row - the row to be parsed
an array of columns; never null

ModeShape Distribution 3.0.0.Beta4

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