An unmarshaller to allowing unmarshalling of XML documents to
Java Objects. The Class must specify
the proper access methods (setters/getters) in order for instances
of the Class to be properly unmarshalled.
characters
public void characters(char[] ch,
int start,
int length)
throws SAXException
endDocument
public void endDocument()
throws org.xml.sax.SAXException
endElement
public void endElement(String name)
throws org.xml.sax.SAXException
error
public void error(SAXParseException exception)
throws org.xml.sax.SAXException
fatalError
public void fatalError(SAXParseException exception)
throws org.xml.sax.SAXException
getCurrentObject
public Object getCurrentObject()
Returns the Object that the UnmarshalHandler is currently
handling (within the object model), or null if the current
element is a simpleType.
- the Object currently being unmarshalled, or null if the
current element is a simpleType.
getDocumentLocator
public Locator getDocumentLocator()
getObject
public Object getObject()
Returns the "root" Object (ie. the entire object model)
being unmarshalled.
- the root Object being unmarshalled.
ignorableWhitespace
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
processingInstruction
public void processingInstruction(String target,
String data)
throws org.xml.sax.SAXException
setClassLoader
public void setClassLoader(ClassLoader loader)
Sets the ClassLoader to use when loading classes
loader
- the ClassLoader to use
setClearCollections
public void setClearCollections(boolean clear)
Sets whether or not to clear collections (including arrays)
upon first use to remove default values. By default, and
for backward compatibility with previous versions of Castor
this value is false, indicating that collections are not
cleared before initial use by Castor.
clear
- the boolean value that when true indicates
collections should be cleared upon first use.
setConfiguration
protected void setConfiguration(Configuration config)
Sets the current Castor configuration. Currently this
Configuration is only used during Validation (which is
why this method is currently protected, since it has
no effect at this point on the actual configuration of
the unmarshaller)
Currently, this method should only be called by the
Unmarshaller.
setDebug
public void setDebug(boolean debug)
Turns debuging on or off. If no Log Writer has been set, then
System.out will be used to display debug information
debug
- the flag indicating whether to generate debug information.
A value of true, will turn debuggin on.
setDocumentLocator
public void setDocumentLocator(Locator locator)
setIDResolver
public void setIDResolver(IDResolver idResolver)
Sets the IDResolver to use when resolving IDREFs for
which no associated element may exist in XML document.
idResolver
- the IDResolver to use when resolving
IDREFs for which no associated element may exist in the
XML document.
setIgnoreExtraAttributes
public void setIgnoreExtraAttributes(boolean ignoreExtraAtts)
Sets whether or not attributes that do not match
a specific field should simply be ignored or
reported as an error. By default, extra attributes
are ignored.
ignoreExtraAtts
- a boolean that when true will
allow non-matched attributes to simply be ignored.
setIgnoreExtraElements
public void setIgnoreExtraElements(boolean ignoreExtraElems)
Sets whether or not elements that do not match
a specific field should simply be ignored or
reported as an error. By default, extra attributes
are ignored.
ignoreExtraElems
- a boolean that when true will
allow non-matched attributes to simply be ignored.
setLogWriter
public void setLogWriter(PrintWriter printWriter)
Sets the PrintWriter used for printing log messages
printWriter
- the PrintWriter to use when printing
log messages
setResolver
public void setResolver(ClassDescriptorResolver cdResolver)
Sets the ClassDescriptorResolver to use for loading and
resolving ClassDescriptors
cdResolver
- the ClassDescriptorResolver to use
setReuseObjects
public void setReuseObjects(boolean reuse)
Sets a boolean that when true indicates that objects
contained within the object model should be re-used
where appropriate. This is only valid when unmarshalling
to an existing object.
reuse
- the boolean indicating whether or not
to re-use existing objects in the object model.
setRootObject
public void setRootObject(Object root)
Sets the root (top-level) object to use for unmarshalling into.
root
- the instance to unmarshal into.
setUnmarshalListener
public void setUnmarshalListener(UnmarshalListener listener)
listener
- the UnmarshalListener to use with this instance
of the UnmarshalHandler.
setValidation
public void setValidation(boolean validate)
Sets the flag for validation
startDocument
public void startDocument()
throws org.xml.sax.SAXException
startElement
public void startElement(String name,
AttributeList attList)
throws org.xml.sax.SAXException
toPrimitiveObject
public static Object toPrimitiveObject(Class type,
String value)
Converts a String to the given primitive object type
type
- the class type of the primitive in which
to convert the String tovalue
- the String to convert to a primitive
warning
public void warning(SAXParseException exception)
throws org.xml.sax.SAXException