|
|||||||||
| 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.DictionaryTransducer
Transduces a dictionary (name=value) based data source.
Performs transduction against a stream of data from either a
Reader or a Writer.
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 readers and the writers, into
this interface.
For specific type of streams, like file-based streams or string-based streams, see the TransducerAdapter objects.
This DictionaryTransducer instance transduces name/value pairs
seperated by a specified delimiter. All dictionary based data sources can be
considered to be only a single row. That is, the depth of the
INode instance that the data is read into is 1. Data sources
like the java.util.Properties format are dictionary based
formats.
Example:
// for Properties based data formats...
IMetaCollection meta = MetaFactory.createMetaCollection();
DictionaryTransducer transducer = new DictionaryTransducer();
transducer.setReader( getMyReader() ); // for files or strings or others...
transducer.setDelimiter( "=" ); // this will parse commas first, then
meta.setTransducer( transducer );
try {
meta.get();
}
catch ( TransducerException te ) {
te.printStackTrace(); // in case something went wrong.
}
FileTransducerAdapter,
StringTransducerAdapter,
URLTransducerAdapter,
IMetaCollection, Serialized Form| Field Summary | |
protected java.lang.String |
delimiter
The delimiter which seperates the name from the value in this DictionaryTransducer instance. |
| Fields inherited from class net.sourceforge.esw.collection.AIOTransducer |
reader, writer |
| Fields inherited from class net.sourceforge.esw.collection.ATransducer |
contextFactory |
| Constructor Summary | |
DictionaryTransducer()
Creates a new DictionaryTransducer instance. |
|
DictionaryTransducer(java.lang.String aDelimiter)
Creates a new DictionaryTransducer instance with the
specified delimiter. |
|
| Method Summary | |
protected void |
checkMetaCollectionNotNull(IMetaCollection aCollection)
If the specified IMetaCollection instance is
null, throws a TransducerException stating so. |
protected void |
checkParameters()
If the required parameters are null or empty, throws a
TransducerException stating that the parameter cannot be
null or empty. |
void |
get(IMetaCollection aCollection)
Gets the data source's data represented by this ITransducer
instance into the referenced IMetaCollection instance. |
java.lang.String |
getDelimiter()
Returns the delimiter for this DictionaryTransducer instance. |
void |
put(IMetaCollection aCollection)
Puts the referenced IMetaCollection instance's data into the
data source represented by this ITransducer instance. |
void |
setDelimiter(java.lang.String aDelimiter)
Sets the delimiter for this DictionaryTransducer 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.IIOTransducer |
getReader, getWriter, setReader, setWriter |
| Methods inherited from interface net.sourceforge.esw.collection.ITransducer |
getContextFactory, setContextFactory |
| Field Detail |
protected java.lang.String delimiter
| Constructor Detail |
public DictionaryTransducer()
DictionaryTransducer instance.public DictionaryTransducer(java.lang.String aDelimiter)
DictionaryTransducer instance with the
specified delimiter.aDelimiter - the delimiter for this DictionaryTransducer instance
that seperates the name from the value.| Method Detail |
public void setDelimiter(java.lang.String aDelimiter)
DictionaryTransducer instance.aDelimiter - the delimiter for this DictionaryTransducer
instance that seperates the name from the value.public java.lang.String getDelimiter()
DictionaryTransducer instance.
public void put(IMetaCollection aCollection)
throws TransducerException
IMetaCollection instance's data into the
data source represented by this ITransducer instance.put in interface ITransduceraCollection - the IMetaCollection instance from which to
take data.TransducerException - if an error occurs during transduction.get( IMetaCollection )
public void get(IMetaCollection aCollection)
throws TransducerException
ITransducer
instance into the referenced IMetaCollection instance.get in interface ITransduceraCollection - the IMetaCollection instance into which to
read.TransducerException - if an error occurs during transduction.put( IMetaCollection )
protected void checkMetaCollectionNotNull(IMetaCollection aCollection)
throws TransducerException
IMetaCollection instance is
null, throws a TransducerException stating so.
Otherwise, returns normally.aCollection - the IMetaCollection instance to check if
null.TransducerException - if the specified
IMetaCollection
instance is null.
protected void checkParameters()
throws TransducerException
null or empty, throws a
TransducerException stating that the parameter cannot be
null or empty. Otherwise, returns normally.TransducerException - if the required parameters are
null or empty.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||