T - The typepublic interface XmlWriter<T> extends HasModelWriteHandler<T>
The setup of the XmlWriter is inspired by the UiBinder and is typically specified as an inner class:
pubilc RunnableMessageContext
{
interface Writer extends XmlWriter<RunnableMessageContext> {}
public static final Writer JSON_WRITER = GWT.create(Writer.class);
// The properties of this POJO
}
XML can then be generated by calling
RunnableMessageContext rmc = new RunnableMessageContext(); ... String xml = RunnableMessageContext.XML_WRITER.toXml(rmc);
| Modifier and Type | Method and Description |
|---|---|
String |
toXml(List<T> models)
Serializes the specified models to XML.
|
String |
toXml(List<T> models,
String rootElement)
Serializes the specified models to XML using the specified name for the
root element.
|
String |
toXml(List<T> models,
String rootElement,
String nestedRootElement)
Serializes the specified models to XML using the specified names for the
root and nested elements.
|
String |
toXml(T model)
Serializes the specified model to XML.
|
String |
toXml(T model,
String rootElement)
Serializes the specified model to XML using the specified name for the
root element.
|
addModelWriteHandlerString toXml(List<T> models)
Given you want to serialize a list of books:
List<Book> books = ...; XmlWriter<Book> xmlWriter = ...; String xml = xmlWriter.toXml(books);Then the xml will have the following structure:
<books>
<book>
...
</book>
...
</books>
models - the models to serializenull if models is
nullString toXml(List<T> models, String rootElement)
models - the models to serializerootElement - the name for the root elementnull if models and/or
rootElement is nullString toXml(List<T> models, String rootElement, String nestedRootElement)
models - the models to serializerootElement - the name for the root elementnestedRootElement - the name of the nested elementsnull if models,
rootElement and/or nestedRootElement is
nullString toXml(T model)
Given you want to serialize a book:
Book book = ...; XmlWriter<Book> xmlWriter = ...; String xml = xmlWriter.toXml(book);Then the xml will have the following structure:
<book>
...
</book>
model - the model to serializenull if model is
nullCopyright © 2013 Harald Pehl. All Rights Reserved.