Javolution 6.0.0 java
|
Public Member Functions | |
XMLObjectWriter () | |
XMLStreamWriter | getStreamWriter () |
XMLObjectWriter | setOutput (OutputStream out) throws XMLStreamException |
XMLObjectWriter | setOutput (OutputStream out, String encoding) throws XMLStreamException |
XMLObjectWriter | setOutput (Writer out) throws XMLStreamException |
XMLObjectWriter | setBinding (XMLBinding binding) |
XMLObjectWriter | setIndentation (String indentation) |
XMLObjectWriter | setReferenceResolver (XMLReferenceResolver referenceResolver) |
void | write (Object obj) throws XMLStreamException |
void | write (Object obj, String name) throws XMLStreamException |
void | write (Object obj, String localName, String uri) throws XMLStreamException |
void | flush () throws XMLStreamException |
void | close () throws XMLStreamException |
void | reset () |
Static Public Member Functions | |
static XMLObjectWriter | newInstance (OutputStream out) throws XMLStreamException |
static XMLObjectWriter | newInstance (OutputStream out, String encoding) throws XMLStreamException |
static XMLObjectWriter | newInstance (Writer out) throws XMLStreamException |
Package Functions | |
public< T > void | write (T obj, String name, Class< T > cls) throws XMLStreamException |
public< T > void | write (T obj, String localName, String uri, Class< T > cls) throws XMLStreamException |
Private Attributes | |
final XMLFormat.OutputElement | _xml = new XMLFormat.OutputElement() |
Writer | _writer |
OutputStream | _outputStream |
This class takes an object and formats it to XML; the resulting XML can be deserialized using a XMLObjectReader.
When an object is formatted, the XMLFormat of the object's class as identified by the XMLBinding is used to write its XML representation.
Multiple objects can be written to the same XML output. For example:[code] XMLObjectWriter writer = XMLObjectWriter.newInstance(outputStream); while (true)) { Message message = ... writer.write(message, "Message", Message.class); } writer.close(); // The underlying stream is closed. [/code]
Definition at line 40 of file XMLObjectWriter.java.
javolution.xml.XMLObjectWriter.XMLObjectWriter | ( | ) |
Default constructor.
Definition at line 60 of file XMLObjectWriter.java.
Referenced by javolution.xml.XMLObjectWriter.newInstance().
void javolution.xml.XMLObjectWriter.close | ( | ) | throws XMLStreamException |
Ends document writting, closes this writer and its underlying output then reset this Writer for potential reuse.
Definition at line 284 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._outputStream, javolution.xml.XMLObjectWriter._writer, javolution.xml.XMLObjectWriter._xml, and javolution.xml.XMLObjectWriter.reset().
Referenced by javolution.xml.ws.WebServiceClient.invoke().
void javolution.xml.XMLObjectWriter.flush | ( | ) | throws XMLStreamException |
Flushes the output stream of this writer (automatically done when closing).
Definition at line 276 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
XMLStreamWriter javolution.xml.XMLObjectWriter.getStreamWriter | ( | ) |
Returns the stream writer used by this object writer (it can be used to write prolog, write namespaces, etc). The stream writer is setup to automatically repair namespaces and to automatically output empty elements when a start element is immediately followed by matching end element.
Definition at line 111 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
Referenced by javolution.xml.ws.WebServiceClient.invoke().
|
static |
Returns a XML object writer (potentially recycled) having the specified output stream as output.
out | the output stream. |
Definition at line 68 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter.setOutput(), and javolution.xml.XMLObjectWriter.XMLObjectWriter().
|
static |
Returns a XML object writer (potentially recycled) having the specified output stream/encoding as output.
out | the output stream. |
encoding | the output stream encoding. |
Definition at line 82 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter.setOutput(), and javolution.xml.XMLObjectWriter.XMLObjectWriter().
|
static |
Returns a XML object writer (potentially recycled) having the specified writer as output.
out | the writer output. |
Definition at line 95 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter.setOutput(), and javolution.xml.XMLObjectWriter.XMLObjectWriter().
void javolution.xml.XMLObjectWriter.reset | ( | ) |
Resets this object writer for reuse.
Definition at line 306 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._outputStream, javolution.xml.XMLObjectWriter._writer, and javolution.xml.XMLObjectWriter._xml.
Referenced by javolution.xml.XMLObjectWriter.close(), and javolution.xml.ws.WebServiceClient.invoke().
XMLObjectWriter javolution.xml.XMLObjectWriter.setBinding | ( | XMLBinding | binding | ) |
Sets the XML binding to use with this object writer.
binding | the XML binding to use. |
this
Definition at line 172 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
XMLObjectWriter javolution.xml.XMLObjectWriter.setIndentation | ( | String | indentation | ) |
Sets the indentation to be used by this writer (no indentation by default).
indentation | the indentation string. |
this
Definition at line 184 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
XMLObjectWriter javolution.xml.XMLObjectWriter.setOutput | ( | OutputStream | out | ) | throws XMLStreamException |
Sets the output stream for this XML object writer.
out | the output stream destination. |
this
Definition at line 122 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._outputStream, javolution.xml.XMLObjectWriter._writer, and javolution.xml.XMLObjectWriter._xml.
Referenced by javolution.xml.ws.WebServiceClient.invoke(), and javolution.xml.XMLObjectWriter.newInstance().
XMLObjectWriter javolution.xml.XMLObjectWriter.setOutput | ( | OutputStream | out, |
String | encoding | ||
) | throws XMLStreamException |
Sets the output stream and encoding for this XML object writer.
out | the output stream destination. |
encoding | the stream encoding. |
this
Definition at line 140 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._outputStream, javolution.xml.XMLObjectWriter._writer, and javolution.xml.XMLObjectWriter._xml.
XMLObjectWriter javolution.xml.XMLObjectWriter.setOutput | ( | Writer | out | ) | throws XMLStreamException |
Sets the output writer for this XML object writer.
out | the writer destination. |
this
Definition at line 157 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._outputStream, javolution.xml.XMLObjectWriter._writer, and javolution.xml.XMLObjectWriter._xml.
XMLObjectWriter javolution.xml.XMLObjectWriter.setReferenceResolver | ( | XMLReferenceResolver | referenceResolver | ) |
Sets the XML reference resolver to use with this object writer (the same reference resolver can be used accross multiple writers).
referenceResolver | the XML reference resolver. |
this
Definition at line 196 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
void javolution.xml.XMLObjectWriter.write | ( | Object | obj | ) | throws XMLStreamException |
Writes the specified object as an anonymous nested element of unknown type. This result in the actual type of the object being identified by the element name.
obj | the object written as nested element or null . |
Definition at line 210 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
void javolution.xml.XMLObjectWriter.write | ( | Object | obj, |
String | localName, | ||
String | uri | ||
) | throws XMLStreamException |
Writes the specified object as a fully qualified nested element of unknown type (null
objects are ignored). The nested XML element may contain a class attribute identifying the object type.
obj | the object added as nested element or null . |
localName | the local name of the nested element. |
uri | the namespace URI of the nested element. |
Definition at line 238 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
void javolution.xml.XMLObjectWriter.write | ( | Object | obj, |
String | name | ||
) | throws XMLStreamException |
Writes the specified object as a named nested element of unknown type (null
objects are ignored). The nested XML element may contain a class attribute identifying the object type.
obj | the object added as nested element or null . |
name | the name of the nested element. |
Definition at line 223 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
|
package |
Writes the specified object as a fully qualified nested element of actual type known (null
objects are ignored).
obj | the object added as nested element or null . |
localName | the local name of the nested element. |
uri | the namespace URI of the nested element. |
cls | the class identifying the XML format to use. |
Definition at line 267 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
|
package |
Writes the specified object as a named nested element of actual type known (null
objects are ignored).
obj | the object added as nested element or null . |
name | the name of the nested element. |
cls | the non-abstract class identifying the XML format to use. |
Definition at line 252 of file XMLObjectWriter.java.
References javolution.xml.XMLObjectWriter._xml.
|
private |
Holds input stream if any.
Definition at line 55 of file XMLObjectWriter.java.
Referenced by javolution.xml.XMLObjectWriter.close(), javolution.xml.XMLObjectWriter.reset(), and javolution.xml.XMLObjectWriter.setOutput().
|
private |
Holds writer if any.
Definition at line 50 of file XMLObjectWriter.java.
Referenced by javolution.xml.XMLObjectWriter.close(), javolution.xml.XMLObjectWriter.reset(), and javolution.xml.XMLObjectWriter.setOutput().
|
private |
Hold the xml element used when formatting.
Definition at line 45 of file XMLObjectWriter.java.
Referenced by javolution.xml.XMLObjectWriter.close(), javolution.xml.XMLObjectWriter.flush(), javolution.xml.XMLObjectWriter.getStreamWriter(), javolution.xml.XMLObjectWriter.reset(), javolution.xml.XMLObjectWriter.setBinding(), javolution.xml.XMLObjectWriter.setIndentation(), javolution.xml.XMLObjectWriter.setOutput(), javolution.xml.XMLObjectWriter.setReferenceResolver(), and javolution.xml.XMLObjectWriter.write().