com.endeca.infront.serialization
Class XmlSerializer
java.lang.Object
com.endeca.infront.serialization.XmlSerializer
public class XmlSerializer
- extends Object
A class for serializing java objects to XML. The following objects can be serialized.
- Map (with String keys)
- List
- Number and its primitive equivalents
- Boolean and boolean
- Character and char
- String
- Java Bean
Circular references will throw an Exception.
The following rules apply.
- Map objects serialize to <Item /> elements, whose children are the map's serialized entries.
Entries in the map are serialized as <Property name="[key]">[value]</Property>,
where [key] is the entry's key, and [value] is the entry's serialized value.
- List objects serialize to <List /> elements, whose children are the list's serialized values.
- Number and its primitive equivalents serialize to <Number>[value]</Number> elements,
where [value] is the value returned by
Object.toString()
.
- Boolean and boolean serialize to <Boolean>[value]</Boolean> elements,
where [value] is the value
returned by Boolean.toString()
.
- String, Character and char serialize to <String>[value]</String> elements,
where [value] is the value of the string, or the
returned by Character.toString()
.
- Java Beans serialize as <Item class="[className]" /> elements,
where [className] is the bean's class name. Properties of the bean get serialized the same
as entries in a Map.
The namespace for these elements is http://endeca.com/schema/xavia/2010.
Constructor Summary |
XmlSerializer(Writer pWriter)
Create a XmlSerializer with the given Writer. |
Method Summary |
void |
write(Object pObject)
Serialize the given object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XmlSerializer
public XmlSerializer(Writer pWriter)
- Create a XmlSerializer with the given Writer.
- Parameters:
pWriter
- The writer to be used as a character stream
write
public void write(Object pObject)
throws IOException
- Serialize the given object.
- Parameters:
pObject
- The object to be serialized
- Throws:
IOException
- Any exception thrown by the underlying writer.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.