|
Lizzy v1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object christophedelory.xml.XmlSerializer
public final class XmlSerializer
A collection of utilities when manipulating the Castor framework. The 3d-party Castor package achieves the Java-XML data binding.
Method Summary | |
---|---|
static XmlSerializer |
getMapping(String packageName)
Retrieves the XML serializer instance associated to the specified package name. |
Marshaller |
getMarshaller()
Returns the associated Castor marshaller. |
Unmarshaller |
getUnmarshaller()
Returns the associated Castor unmarshaller. |
void |
marshal(Object o,
File file,
boolean asDocument)
Writes the specified object as an XML stream to an output file. |
void |
marshal(Object o,
String fileName,
boolean asDocument)
Writes the specified object as an XML stream to an output file. |
void |
marshal(Object o,
Writer out,
boolean asDocument)
Writes the specified object as an XML stream to an output writer. |
Object |
unmarshal(File file)
Unmarshalls an object from an input file, according to the underlying mapping. |
Object |
unmarshal(InputStream in)
Unmarshalls an object from an input stream, according to the underlying mapping. |
Object |
unmarshal(Reader reader)
Unmarshalls an object from a reader, according to the underlying mapping. |
Object |
unmarshal(String fileName)
Unmarshalls an object from an input file, according to the underlying mapping. |
Object |
unmarshal(URL url)
Unmarshalls an object from an input URL, according to the underlying mapping. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static XmlSerializer getMapping(String packageName) throws IOException, MappingException
packageName/mapping.xml
.
Thus the separator character used in packageName
shall be the slash ("/
").
packageName
- the package name. May be null
.
XmlSerializer
instance. Shall not be null
.
FileNotFoundException
- if the mapping file cannot be found.
IOException
- an error occured when reading the mapping file.
MappingException
- the mapping file is invalid.
SecurityException
- if a security manager exists and its checkPermission
method denies access to the class loader for the class.public Object unmarshal(String fileName) throws Exception
fileName
- an XML file name. Shall not be null
.
MappingException
- an exception indicating an invalid mapping error.
FileNotFoundException
- if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
SecurityException
- if a security manager exists and its checkRead
method denies read access to the file.
MarshalException
- when there is an error during the unmarshalling process.
ValidationException
- when there is a validation error.
NullPointerException
- if fileName
is null
.
Exception
unmarshal(InputStream)
,
Mapping
public Object unmarshal(File file) throws Exception
file
- an XML file.
MappingException
- an exception indicating an invalid mapping error.
FileNotFoundException
- if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
SecurityException
- if a security manager exists and its checkRead
method denies read access to the file.
MarshalException
- when there is an error during the unmarshalling process.
ValidationException
- when there is a validation error.
NullPointerException
- if file
is null
.
Exception
unmarshal(InputStream)
,
Mapping
public Object unmarshal(URL url) throws Exception
url
- an URL.
MappingException
- an exception indicating an invalid mapping error.
IOException
- if an I/O exception occurs.
MarshalException
- when there is an error during the unmarshalling process.
ValidationException
- when there is a validation error.
NullPointerException
- if url
is null
.
Exception
unmarshal(InputStream)
,
Mapping
public Object unmarshal(InputStream in) throws Exception
in
- an input stream.
MappingException
- an exception indicating an invalid mapping error.
MarshalException
- when there is an error during the unmarshalling process.
ValidationException
- when there is a validation error.
NullPointerException
- if in
is null
.
Exception
Mapping
public Object unmarshal(Reader reader) throws Exception
reader
- a reader.
MappingException
- an exception indicating an invalid mapping error.
MarshalException
- when there is an error during the unmarshalling process.
ValidationException
- when there is a validation error.
NullPointerException
- if reader
is null
.
Exception
Mapping
public void marshal(Object o, String fileName, boolean asDocument) throws Exception
o
- the object to serialize.fileName
- an XML file name.asDocument
- if true
, indicates to marshal as a complete XML document, which includes the XML declaration, and if necessary the DOCTYPE declaration.
IOException
- if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
IOException
- if any I/O error occurred.
MappingException
- an exception indicating an invalid mapping error.
MarshalException
- a marshalling exception.
ValidationException
- an XML validation error occurred.
NullPointerException
- if o
is null
.
NullPointerException
- if fileName
is null
.
Exception
marshal(Object,Writer,boolean)
,
Mapping
public void marshal(Object o, File file, boolean asDocument) throws Exception
o
- the object to serialize.file
- an XML file.asDocument
- if true
, indicates to marshal as a complete XML document, which includes the XML declaration, and if necessary the DOCTYPE declaration.
IOException
- if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
IOException
- if any I/O error occurred.
MappingException
- an exception indicating an invalid mapping error.
MarshalException
- a marshalling exception.
ValidationException
- an XML validation error occurred.
NullPointerException
- if o
is null
.
NullPointerException
- if file
is null
.
Exception
marshal(Object,Writer,boolean)
,
Mapping
public void marshal(Object o, Writer out, boolean asDocument) throws Exception
o
- the object to serialize.out
- the writer.asDocument
- if true
, indicates to marshal as a complete XML document, which includes the XML declaration, and if necessary the DOCTYPE declaration.
MappingException
- an exception indicating an invalid mapping error.
MarshalException
- a marshalling exception.
ValidationException
- an XML validation error occurred.
NullPointerException
- if o
is null
.
NullPointerException
- if out
is null
.
Exception
Mapping
public Marshaller getMarshaller()
null
.public Unmarshaller getUnmarshaller()
null
.
|
© 2008-2009 Christophe Delory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |