|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.esw.collection.ATransducer | +--net.sourceforge.esw.collection.AIOTransducer | +--net.sourceforge.esw.collection.FixedPositionTransducer
Transduces data that has a fixed position within a stream.
This transduction occurs both ways; put()
takes data
from the IMetaCollection
instance to which this
ITransducer
instance is attached and places it into the data
source represented by this ITransducer
instance. The
get()
method takes data from the data source represented by this
ITransducer
instance and places it into the
IMetaCollection
instance to which this ITransducer
instance is attached.
This IIOTransducer
instance provides stream-based access for
stream-based ITransducer
implementors. It abstracts out the
setting and getting of the streams, or the Reader
instances and
the Writer
instances, into this interface.
Fixed position data is data that has a fixed width for each data element. For example, the first data element has 10 characters, the secondhas 20 characters, and etc.
Example:
IMetaCollection meta = MetaFactory.createMetaCollection(); FixedPositionTransducer transducer = new FixedPositionTransducer(); transducer.setReader( getMyReader() ); // for files or strings or others... transducer.addWidth( 10 ); // this sets the first column to 10 characters transducer.addWidth( 20 ); // this sets the second column to 20 characters ... meta.setTransducer( transducer ); try { meta.get(); } catch ( TransducerException te ) { te.printStackTrace(); // in case something went wrong. }
Field Summary | |
protected java.util.ArrayList |
positions
The widths of each of the columns, in the order which they occur in the data. |
Fields inherited from class net.sourceforge.esw.collection.AIOTransducer |
reader, writer |
Fields inherited from class net.sourceforge.esw.collection.ATransducer |
contextFactory |
Constructor Summary | |
FixedPositionTransducer()
Creates a new FixedPositionTransducer instance. |
|
FixedPositionTransducer(java.util.List aWidths)
Creates a new FixedPositionTransducer instance with the
specified widths. |
Method Summary | |
void |
addWidth(int aWidth)
Adds a width to this FixedPositionTransducer instance. |
void |
get(IMetaCollection aCollection)
Gets the data source's data represented by this ITransducer
instance into the referenced IMetaCollection instance. |
int |
getWidth(int aPosition)
Returns the width at the specified position for this FixedPositionTransducer instance. |
void |
put(IMetaCollection aCollection)
Puts the referenced IMetaCollection instance's data into the
data source represented by this ITransducer instance. |
protected INode |
setupBasicNodeStructure()
Returns the graph from the INodeContextFactory instance. |
void |
setWidth(int aPosition,
int aWidth)
Sets the width at the specified position for this FixedPositionTransducer instance. |
Methods inherited from class net.sourceforge.esw.collection.AIOTransducer |
getReader, getWriter, setReader, setWriter |
Methods inherited from class net.sourceforge.esw.collection.ATransducer |
getContextFactory, setContextFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.esw.collection.ITransducer |
getContextFactory, setContextFactory |
Field Detail |
protected java.util.ArrayList positions
Constructor Detail |
public FixedPositionTransducer()
FixedPositionTransducer
instance.public FixedPositionTransducer(java.util.List aWidths)
FixedPositionTransducer
instance with the
specified widths.aWidths
- a List
of widths to add to this
FixedPositionTransducer
instance.Method Detail |
public void setWidth(int aPosition, int aWidth)
FixedPositionTransducer
instance.aWidth
- the width at the position for this
FixedPositionTransducer
instance to use.aPosition
- the position of the width.java.lang.IndexOutOfBoundsException
- if the specified position is greater
than the number of previously added
widths.getWidth( int )
,
addWidth( int )
public void addWidth(int aWidth)
FixedPositionTransducer
instance.aWidth
- the width to add to this FixedPositionTransducer
instance.getWidth( int )
,
setWidth( int, int )
public int getWidth(int aPosition)
FixedPositionTransducer
instance.aPosition
- the position of the width to return.addWidth( int )
,
setWidth( int, int )
public void get(IMetaCollection aCollection) throws TransducerException
ITransducer
instance into the referenced IMetaCollection
instance.
This implementation cannot pad data or provide missing fields.
aCollection
- the IMetaCollection
instance into which to
read.TransducerException
- if an error occurs during transduction.put( IMetaCollection )
public void put(IMetaCollection aCollection) throws TransducerException
IMetaCollection
instance's data into the
data source represented by this ITransducer
instance.aCollection
- the IMetaCollection
instance from which to
take data.TransducerException
- if an error occurs during transduction.get( IMetaCollection )
protected INode setupBasicNodeStructure()
INodeContextFactory
instance. If
the graph doesn't contain enough depth to support the current number of
delimiters, builds the structure up until the depth of the graph is equal
to the number of delimiters.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |