|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.databeans.io.XmlInput
public class XmlInput
Manages decoding of data bean objects from XML.
Basic usage:
Reader reader = new FileReader ("file.dbxml"); Object decodedObject = xmlInput.read (reader); reader.close ();
Constructor Summary | |
---|---|
XmlInput()
Create a new instance using the default XML reader. |
|
XmlInput(String xmlReaderClass)
Create a new instance. |
Method Summary | |
---|---|
void |
finished()
Signal reading is finished. |
static String |
getDefaultXmlReaderClass()
|
int |
getMajorVersion()
|
int |
getMinorVersion()
|
Object |
getProperty(Object name)
Get a custom property defined by setProperty(Object, Object) . |
XmlDecoder |
getXmlDecoder(String elementType)
Look up a decoder registered with registerXmlDecoder(String, XmlDecoder) . |
boolean |
isMultiObject()
See setMultiObject(boolean) . |
Object |
read(org.jdom.Document document)
Read an object from a JDOM document. |
Object |
read(org.jdom.Element root)
Read an object from a JDOM root element. |
Object |
read(Reader stream)
Read an object from an XML stream. |
org.jdom.Document |
readDocument(Reader stream)
Read a document from an XML stream using the JDOM SAX reader. |
org.jdom.Element |
readElement(Reader reader)
Shortcut to read the XML and return the root element. |
Object |
readFile(String filename)
Shortcut to read an object from a DBXML file. |
static void |
registerGlobalTextDecoder(String valueType,
String decoderClassName)
Register a TextDecoder for this input object. |
static void |
registerGlobalTextDecoder(String valueType,
TextDecoder decoder)
Register a TextDecoder for this input object. |
static void |
registerGlobalXmlDecoder(String elementType,
XmlDecoder decoder)
Register a global XmlDecoder. |
void |
registerTextDecoder(String valueType,
String decoderClassName)
Register a TextDecoder for this input object. |
void |
registerTextDecoder(String valueType,
TextDecoder decoder)
Register a TextDecoder for this input object. |
void |
registerXmlDecoder(String elementType,
XmlDecoder decoder)
Register an XmlDecoder for this input object. |
static void |
setDefaultXmlReaderClass(String className)
Set the default SAX driver class that will be used by JDOM. |
void |
setMultiObject(boolean newValue)
If set to true (default = false), then multiple elements may be decoded by calling the decode () methods multiple times while sharing the same context. |
void |
setProperty(Object name,
Object value)
Define a custom property that will be accessible during this session via getProperty(Object) and
XmlDecodeContext.getProperty(Object) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlInput()
read(Reader)
to read objects.
public XmlInput(String xmlReaderClass)
read(Reader)
to read objects.
xmlReaderClass
- The class name of a SAX XMLReader.Method Detail |
---|
public static void setDefaultXmlReaderClass(String className)
public static String getDefaultXmlReaderClass()
public void setProperty(Object name, Object value)
getProperty(Object)
and
XmlDecodeContext.getProperty(Object)
.
public Object getProperty(Object name)
setProperty(Object, Object)
.
public boolean isMultiObject()
setMultiObject(boolean)
.
public void setMultiObject(boolean newValue)
IMPORTANT: If this option is enabled, it is up to the client to
call finished()
when the decode session is complete,
otherwise outstanding links may not be resolved.
public void finished()
public Object read(Reader stream) throws org.jdom.JDOMException, IOException, ClassNotFoundException
readDocument(Reader)
and then decodes the document using
read(Document)
. If a DBXML header is present, the major/minor
version numbers are read and the first child of the header is read.
stream
- The stream to read from.
org.jdom.JDOMException
- If the JDOM document builder encounters an error.
ClassNotFoundException
- If a class referenced by the serialized
stream cannot be found.
IOException
public org.jdom.Document readDocument(Reader stream) throws org.jdom.JDOMException, IOException
stream
- The stream to read from.
org.jdom.JDOMException
- If the JDOM SAX document builder encounters an error.
IOException
readElement(Reader)
,
read(Reader)
public org.jdom.Element readElement(Reader reader) throws org.jdom.JDOMException, IOException
org.jdom.JDOMException
IOException
public Object readFile(String filename) throws ClassNotFoundException, IOException, IllegalArgumentException
ClassNotFoundException
IOException
IllegalArgumentException
public Object read(org.jdom.Document document) throws IllegalArgumentException, ClassNotFoundException
document
- The document to read from.
IllegalArgumentException
- if an error is found in the structure
of the document.
ClassNotFoundException
- If a class referenced by the document
cannot be found.read(Element)
,
readDocument(Reader)
public Object read(org.jdom.Element root) throws IllegalArgumentException, ClassNotFoundException
root
- The root element to read from.
IllegalArgumentException
- if an error is found in the structure
of the document.
ClassNotFoundException
- If a class referenced by the document
cannot be found.read(Document)
,
read(Reader)
public int getMajorVersion()
public int getMinorVersion()
public void registerXmlDecoder(String elementType, XmlDecoder decoder)
elementType
- The element type. The decoder will be used to decode
all element's that have this name.decoder
- The decoder.registerGlobalXmlDecoder(String, XmlDecoder)
public XmlDecoder getXmlDecoder(String elementType)
registerXmlDecoder(String, XmlDecoder)
.
public void registerTextDecoder(String valueType, String decoderClassName)
valueType
- The value type. The decoder will be used to decode
all element's that are compatible with this type as defined by
TypeMap
.decoderClassName
- The decoder class name. The decoder class will be
instantiated when/if an object of the specified type is encountered.registerGlobalTextDecoder(String, String)
public void registerTextDecoder(String valueType, TextDecoder decoder)
valueType
- The value type. The decoder will be used to decode
all element's that are compatible with this type as defined by
TypeMap
.decoder
- The decoder.registerGlobalTextDecoder(String, String)
public static void registerGlobalXmlDecoder(String elementType, XmlDecoder decoder)
elementType
- The element type. The decoder will be used to decode
all element's that have this name.decoder
- The decoder.registerXmlDecoder(String, XmlDecoder)
public static void registerGlobalTextDecoder(String valueType, String decoderClassName)
valueType
- The value type. The decoder will be used to decode
all element's that are compatible with this type as defined by
TypeMap
.decoderClassName
- The decoder class name. The decoder class will be
instantiated when/if an object of the specified type is encountered.registerTextDecoder(String, TextDecoder)
public static void registerGlobalTextDecoder(String valueType, TextDecoder decoder)
valueType
- The value type. The decoder will be used to decode
all element's that are compatible with this type as defined by
TypeMap
.decoder
- The decoder.registerTextDecoder(String, String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |