O - the type of Java object this translator instance is able to handlepublic abstract class SimpleValueTranslator<O> extends AbstractObjectTranslator<O>
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_STRING_REPRESENTATION_LENGTH |
| Constructor and Description |
|---|
SimpleValueTranslator() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasStringRepresentation()
Determines whether the objects handled by this instance have a simple string representation or need a more complex
XML representation.
|
java.lang.String |
javaToRepresentation(java.lang.Object object,
WriterStreamDataProvider<?> streamDataProvider)
Converts the object by invoking its
Object.toString() method. |
O |
readXMLRepresentation(javax.xml.stream.XMLEventReader reader,
ReaderStreamDataProvider<?> streamDataProvider)
Reads an object from the character data available at the current position of the XML reader.
|
void |
writeXMLRepresentation(javax.xml.stream.XMLStreamWriter writer,
java.lang.Object object,
WriterStreamDataProvider<?> streamDataProvider)
Writes the string representation of the specified object to an XML stream.
|
equals, hashCodeclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetObjectClass, representationToJavapublic static final int MAX_STRING_REPRESENTATION_LENGTH
public SimpleValueTranslator()
public boolean hasStringRepresentation()
ObjectTranslator
Instances that return false here will throw an UnsupportedOperationException, if
ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider) is called.
true if handled objects have a simple string representation or false if XML is necessary to
represent the handled objectspublic java.lang.String javaToRepresentation(java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider) throws java.lang.UnsupportedOperationException, java.lang.ClassCastException
Object.toString() method.object - the object to be convertedstreamDataProvider - TODOjava.lang.UnsupportedOperationException - if objects handled by this instance can only be represented as XMLjava.lang.ClassCastException - if the specified object is not an instance of the supported class or does not implement the supported
interfaceObjectTranslator.javaToRepresentation(java.lang.Object, WriterStreamDataProvider)public void writeXMLRepresentation(javax.xml.stream.XMLStreamWriter writer, java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider) throws java.io.IOException, javax.xml.stream.XMLStreamException
javaToRepresentation(Object, WriterStreamDataProvider)
internally.)writer - the XML stream writerobject - the object to be convertedstreamDataProvider - TODOjava.io.IOException - if an I/O error occurs while trying to write to the specified writerjavax.xml.stream.XMLStreamException - if an XML stream exception occurs while trying to write to the specified writerpublic O readXMLRepresentation(javax.xml.stream.XMLEventReader reader, ReaderStreamDataProvider<?> streamDataProvider) throws java.io.IOException, javax.xml.stream.XMLStreamException, InvalidObjectSourceDataException
XMLStreamConstants.CHARACTERS is consumed. If no event of this type is available, parsing the
empty string is tried. (Calls ObjectTranslator.representationToJava(String, ReaderStreamDataProvider) internally.)reader - the XML event reader to read the data fromstreamDataProvider - TODOJPhyloIOReaderException - if the textual data found at the current position is longer than
MAX_STRING_REPRESENTATION_LENGTHjava.io.IOException - if an I/O error occurs while trying to read from the specified readerjavax.xml.stream.XMLStreamException - if an XML stream exception occurs while trying to read from the specified readerInvalidObjectSourceDataException - if an unexpected XML event was encountered or an XML event has unexpected contents