public class StringTranslator extends SimpleValueTranslator<java.lang.String>
String. Both representationToJava(String, ReaderStreamDataProvider) and #javaToRepresentation(String, WriterStreamDataProvider)
return the specified string instance unchanged.MAX_STRING_REPRESENTATION_LENGTH| Constructor and Description |
|---|
StringTranslator() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class<java.lang.String> |
getObjectClass()
Returns the Java class of object instances created by this translator.
|
java.lang.String |
javaToRepresentation(java.lang.Object object,
WriterStreamDataProvider<?> streamDataProvider)
Converts the object by invoking its
Object.toString() method. |
java.lang.String |
representationToJava(java.lang.String representation,
ReaderStreamDataProvider<?> streamDataProvider)
Converts the specified string representation to a new instance of the according Java object.
|
hasStringRepresentation, readXMLRepresentation, writeXMLRepresentationequals, hashCodepublic StringTranslator()
public java.lang.Class<java.lang.String> getObjectClass()
ObjectTranslator
Note that ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider) and ObjectTranslator.writeXMLRepresentation(XMLStreamWriter, Object, WriterStreamDataProvider) may also
accept instances of other classes. This is independent from the return value here.
public java.lang.String representationToJava(java.lang.String representation, ReaderStreamDataProvider<?> streamDataProvider) throws InvalidObjectSourceDataException, java.lang.UnsupportedOperationException
ObjectTranslator
If #getClass() returns an interface for this instance, the concrete class of the returned object may
depend on the representation.
representation - the string representation of the object to be createdstreamDataProvider - the stream data provider of the calling reader (Maybe null. Some translators will use it to gain
additional status information required for translating, e.g. prefix to namespace mapping for creating QNames.)InvalidObjectSourceDataException - if the specified string representation cannot be parsed to a supported objectjava.lang.UnsupportedOperationException - if objects handled by this instance can only be represented as XMLpublic java.lang.String javaToRepresentation(java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider) throws java.lang.UnsupportedOperationException, java.lang.ClassCastException
SimpleValueTranslatorObject.toString() method.javaToRepresentation in interface ObjectTranslator<java.lang.String>javaToRepresentation in class SimpleValueTranslator<java.lang.String>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)