net.sourceforge.esw.collection
Class XMLTransducer
java.lang.Object
|
+--net.sourceforge.esw.collection.ATransducer
|
+--net.sourceforge.esw.collection.AIOTransducer
|
+--net.sourceforge.esw.collection.XMLTransducer
- All Implemented Interfaces:
- IIOTransducer, ITransducer, java.io.Serializable
- public class XMLTransducer
- extends AIOTransducer
- implements IIOTransducer
Performs Transduction between a XML data source and an
IMetaCollection
instance.
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.
By default, this XMLTransducer
instance does not validate the
XML document. However, it will always check for well-formed XML documents. If
you wish an instance of an XMLTransducer
to validate the XML
document, call the setValidating(boolean)
method of the
XMLTransducer
instance.
For speed purposes, this XMLTransducer
instance utilizes
SAX 2.0 for its parsing.
Example:
IMetaCollection meta = MetaFactory.createMetaCollection();
XMLTransducer transducer = new XMLTransducer();
transducer.setReader( getMyReader() ); // for files or strings or others...
meta.setTransducer( transducer );
try {
meta.get();
}
catch ( TransducerException te ) {
te.printStackTrace(); // in case something went wrong.
}
- See Also:
IMetaCollection
, Serialized Form
Field Summary |
protected boolean |
bValidating
Specifies whether this XMLTransducer instance validate the XML
document By default, validation does not occur. |
Constructor Summary |
XMLTransducer()
Creates a new, non-validating XMLTransducer instance. |
XMLTransducer(boolean bValidate)
Creates a new XMLTransducer instance against the XML file
with the specified name, specifying whether validation should occur. |
Method Summary |
void |
get(IMetaCollection aCollection)
Gets the data source's data represented by this ITransducer
instance into the referenced IMetaCollection instance. |
boolean |
getValidating()
Returns whether this XMLTransducer instance should validate
its XML document during get invocations. |
void |
put(IMetaCollection aCollection)
Puts the referenced IMetaCollection instance's data into the
data source represented by this ITransducer instance. |
void |
setValidating(boolean aValidate)
Sets whether this XMLTransducer instance should validate its
XML document during get invocations. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
bValidating
protected boolean bValidating
- Specifies whether this
XMLTransducer
instance validate the XML
document By default, validation does not occur.
XMLTransducer
public XMLTransducer()
- Creates a new, non-validating
XMLTransducer
instance.
XMLTransducer
public XMLTransducer(boolean bValidate)
- Creates a new
XMLTransducer
instance against the XML file
with the specified name, specifying whether validation should occur.
- Parameters:
bValidate
- sets whether this XMLTransducer
instance will
validate the XML document.
put
public void put(IMetaCollection aCollection)
throws TransducerException
- Puts the referenced
IMetaCollection
instance's data into the
data source represented by this ITransducer
instance.
- Specified by:
put
in interface ITransducer
- Parameters:
aCollection
- the IMetaCollection
instance from which to
take data.- Throws:
TransducerException
- if an error occurs during transduction.- See Also:
get( IMetaCollection )
get
public void get(IMetaCollection aCollection)
throws TransducerException
- Gets the data source's data represented by this
ITransducer
instance into the referenced IMetaCollection
instance.
- Specified by:
get
in interface ITransducer
- Parameters:
aCollection
- the IMetaCollection
instance into which to
read.- Throws:
TransducerException
- if an error occurs during transduction.- See Also:
put( IMetaCollection )
setValidating
public void setValidating(boolean aValidate)
- Sets whether this
XMLTransducer
instance should validate its
XML document during get
invocations.
- Parameters:
aValidate
- if true
, will validate the XML document
this XMLTransducer
instance is processing.
Otherwise, validation will not occur.
getValidating
public boolean getValidating()
- Returns whether this
XMLTransducer
instance should validate
its XML document during get
invocations.
- Returns:
- whether this
XMLTransducer
instance should validate
its XML document.
Copyright 2002 Free Software Foundation. All Rights Reserved.