org.ow2.weblab.core.extended.jaxb
Class WebLabMarshaller
java.lang.Object
org.ow2.weblab.core.extended.jaxb.WebLabMarshaller
public class WebLabMarshaller
- extends java.lang.Object
A wrapping class for a JAXB Marshaller and a JAXB Unmarshaler. Many functions are available on Writer since it's easy for the use
to create a Writer from a file or from an output stream. new OutputStreamWriter(new FileOutputStream(file)), "UTF-8"); Note that you need to
close the I/O streams, readers and writers that you gave to this class. When you use a file, we close the opened stream.
- Author:
- Cassidian WebLab Team
- Date:
- 2008-01-15
|
Method Summary |
void |
marshal(Resource resource,
java.io.Writer writer,
javax.xml.namespace.QName qname)
|
void |
marshal(Resource resource,
java.io.Writer writer,
java.lang.String qnameLocalPart)
|
void |
marshalResource(Resource resource,
java.io.File file)
|
void |
marshalResource(Resource resource,
java.io.OutputStream stream)
|
void |
marshalResource(Resource resource,
java.io.Writer writer)
|
void |
marshalResource(Resource resource,
java.io.Writer writer,
boolean checkXML)
|
void |
reset()
Reset marshaller, unmarshaller and jc. |
boolean |
setMarshallerProperty(java.lang.String key,
java.lang.Object value)
|
boolean |
setUnmarshallerProperty(java.lang.String key,
java.lang.Object value)
|
|
unmarshal(java.io.File file,
java.lang.Class<T> resourceClass)
|
|
unmarshal(java.io.InputStream stream,
java.lang.Class<T> resourceClass)
|
|
unmarshal(java.io.Reader reader,
java.lang.Class<T> resourceClass)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WebLabMarshaller
public WebLabMarshaller()
- Constructors
reset
public void reset()
- Reset
marshaller, unmarshaller and jc.
unmarshal
public <T extends Resource> T unmarshal(java.io.File file,
java.lang.Class<T> resourceClass)
throws WebLabCheckedException
- Type Parameters:
T - Class of the Resource to be unmarshaled- Parameters:
file - File to be read.resourceClass - Class of the Resource to be unmarshaled. Using Resource will prevent from
cast errors when the
content of the File isn't compatible with resourceClass.
- Returns:
- an instance of
resourceClass from the content of File.
- Throws:
WebLabCheckedException - if a JAXBException or a ClassCastException occurred.
unmarshal
public <T extends Resource> T unmarshal(java.io.InputStream stream,
java.lang.Class<T> resourceClass)
throws WebLabCheckedException
- Type Parameters:
T - Class of the Resource to be unmarshaled- Parameters:
stream - InputStream to be read. Note that you need to
close the stream after using this method.resourceClass - Class of the Resource to be unmarshaled. Using Resource will prevent from
cast errors when the
content of the InputStream isn't compatible with resourceClass.
- Returns:
- an instance of
resourceClass from the content of the InputStream.
- Throws:
WebLabCheckedException - if a JAXBException or a ClassCastException occurred.
unmarshal
public <T extends Resource> T unmarshal(java.io.Reader reader,
java.lang.Class<T> resourceClass)
throws WebLabCheckedException
- Type Parameters:
T - Class of the Resource to be unmarshaled- Parameters:
reader - Reader to be read. Note that you need to close
the reader after using this method.resourceClass - Class of the Resource to be unmarshaled. Using Resource will prevent from
cast errors when the
content of the Reader isn't compatible with resourceClass.
- Returns:
- an instance of
resourceClass from the content of
source.
- Throws:
WebLabCheckedException - if a JAXBException or a ClassCastException
occurred.
marshalResource
public void marshalResource(Resource resource,
java.io.File file)
throws WebLabCheckedException
- Parameters:
resource - The resource to be marshaled.file - The File to be written.
- Throws:
WebLabCheckedException - if a JAXBException occurred.
marshalResource
public void marshalResource(Resource resource,
java.io.OutputStream stream)
throws WebLabCheckedException
- Parameters:
resource - The Resource to be marshaled.stream - The OutputStream to be written. Note that you
need to close the stream after using this method.
- Throws:
WebLabCheckedException - if a JAXBException occurred.
marshalResource
public void marshalResource(Resource resource,
java.io.Writer writer)
throws WebLabCheckedException
- Parameters:
resource - The Resource to be marshaled.writer - The Writer to be written. Note that you need to
close the writer after using this method.
- Throws:
WebLabCheckedException - if a JAXBException occurred.
marshalResource
public void marshalResource(Resource resource,
java.io.Writer writer,
boolean checkXML)
throws WebLabCheckedException
- Parameters:
resource - The Resource to be marshaled.writer - The Writer to be written. Note that you need to
close the writer after using this method.checkXML - Whether or not to clean the Resource from any not recommended
XML char. Time of the process will be increased.
- Throws:
WebLabCheckedException - if a JAXBException occurred.- See Also:
XMLStringCleaner
marshal
public void marshal(Resource resource,
java.io.Writer writer,
javax.xml.namespace.QName qname)
throws WebLabCheckedException
- Parameters:
resource - The Resource to be marshaled.writer - The Writer to be written. Note that you need to
close the writer after using this method.qname - The QName of the field containing resource.
- Throws:
WebLabCheckedException - if a JAXBException occurred.
marshal
public void marshal(Resource resource,
java.io.Writer writer,
java.lang.String qnameLocalPart)
throws WebLabCheckedException
- Parameters:
resource - The Resource to be marshaled.writer - The Writer to be written. Note that you need to
close the writer after using this method.qnameLocalPart - The name of the field containing resource.
- Throws:
WebLabCheckedException - if a JAXBException occurred.
setMarshallerProperty
public boolean setMarshallerProperty(java.lang.String key,
java.lang.Object value)
- Parameters:
key - The String key of the property to set.value - The Object value of the property to set.
- Returns:
false if an PropertyException occurred
while setting the property.- See Also:
for key values.
setUnmarshallerProperty
public boolean setUnmarshallerProperty(java.lang.String key,
java.lang.Object value)
- Parameters:
key - The String key of the property to setvalue - The Object value of the property to set
- Returns:
- false if an PropertyException occurred while setting the property
- See Also:
for key values
Copyright © 2004-2011 WebLab Project. All Rights Reserved.