org.jboss.dna.sequencer.text
Class FixedWidthTextSequencer

java.lang.Object
  extended by org.jboss.dna.sequencer.text.AbstractTextSequencer
      extended by org.jboss.dna.sequencer.text.FixedWidthTextSequencer
All Implemented Interfaces:
StreamSequencer

public class FixedWidthTextSequencer
extends AbstractTextSequencer

An text sequencer implementation that uses a list of column numbers to split incoming rows into fixed-width columns. By default, this class treats each row as a single column. There is an implicit column start index of 0 for the first column.

See Also:
AbstractTextSequencer

Constructor Summary
FixedWidthTextSequencer()
           
 
Method Summary
 void setColumnStartPositions(int[] columnStartPositions)
          Set the column start positions.
 void setColumnStartPositions(String commaDelimitedColumnStartPositions)
          Set the column start positions from a list of column start positions concatenated into a single, comma-delimited string.
 
Methods inherited from class org.jboss.dna.sequencer.text.AbstractTextSequencer
getCommentMarker, getMaximumLinesToRead, getRowFactoryClassName, sequence, setCommentMarker, setMaximumLinesToRead, setRowFactoryClassName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedWidthTextSequencer

public FixedWidthTextSequencer()
Method Detail

setColumnStartPositions

public void setColumnStartPositions(int[] columnStartPositions)
Set the column start positions. The column start positions are 0-based. Everything before the first start position is treated as the first column.

As an example, if the column start positions were {3, 6, 15} and the incoming stream was:

           1         2
 012345678901234567890
 supercallifragilistic
 expialidocious
 
This sequencer would return the following rows:
 row 1: "sup", "erc", "allifragi", "listic"
 row 2: "exp:, "ial", "idocious"
 
Note that there are only three columns returned in the second row, as there were not enough characters to reach the third start position.

Parameters:
columnStartPositions - the column startPositions; may not be null

setColumnStartPositions

public void setColumnStartPositions(String commaDelimitedColumnStartPositions)
Set the column start positions from a list of column start positions concatenated into a single, comma-delimited string.

Parameters:
commaDelimitedColumnStartPositions - a list of column start positions concatenated into a single, comma-delimited string; may not be null
See Also:
setColumnStartPositions(int[])


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