info.bioinfweb.jphyloio.objecttranslation.implementations

## Class StringTranslator

- java.lang.Object
- - info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractObjectTranslator<O>
  - - info.bioinfweb.jphyloio.objecttranslation.implementations.SimpleValueTranslator<java.lang.String>
    - - info.bioinfweb.jphyloio.objecttranslation.implementations.StringTranslator

- All Implemented Interfaces:
    ObjectTranslator<java.lang.String>

      public class StringTranslator
      extends SimpleValueTranslator<java.lang.String>

  An object translator from and to `String`. Both `representationToJava(String, ReaderStreamDataProvider)` and `#javaToRepresentation(String, WriterStreamDataProvider)` return the specified string instance unchanged.
  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Field Summary

    - ### Fields inherited from class info.bioinfweb.jphyloio.objecttranslation.implementations.SimpleValueTranslator

      `MAX_STRING_REPRESENTATION_LENGTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringTranslator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class info.bioinfweb.jphyloio.objecttranslation.implementations.SimpleValueTranslator

      `hasStringRepresentation, readXMLRepresentation, writeXMLRepresentation`

    - ### Methods inherited from class info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractObjectTranslator

      `equals, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StringTranslator

          public StringTranslator()

  - ### Method Detail

    - #### getObjectClass

          public java.lang.Class<java.lang.String> getObjectClass()

      Description copied from interface: `ObjectTranslator`
      Returns the Java class of object instances created by this translator.

      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.

      Returns:
        the class of the handled objects

    - #### representationToJava

          public java.lang.String representationToJava(java.lang.String representation,
                                                       ReaderStreamDataProvider<?> streamDataProvider)
                                                throws InvalidObjectSourceDataException,
                                                       java.lang.UnsupportedOperationException

      Description copied from interface: `ObjectTranslator`
      Converts the specified string representation to a new instance of the according Java object.

      If `#getClass()` returns an interface for this instance, the concrete class of the returned object may depend on the representation.

      Parameters:
        `representation` - the string representation of the object to be created
        `streamDataProvider` - 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.)
      Returns:
        the new object
      Throws:
        `InvalidObjectSourceDataException` - if the specified string representation cannot be parsed to a supported object
        `java.lang.UnsupportedOperationException` - if objects handled by this instance can only be represented as XML

    - #### javaToRepresentation

          public java.lang.String javaToRepresentation(java.lang.Object object,
                                                       WriterStreamDataProvider<?> streamDataProvider)
                                                throws java.lang.UnsupportedOperationException,
                                                       java.lang.ClassCastException

      Description copied from class: `SimpleValueTranslator`
      Converts the object by invoking its `Object.toString()` method.
      Specified by:
        `javaToRepresentation` in interface `ObjectTranslator<java.lang.String>`
      Overrides:
        `javaToRepresentation` in class `SimpleValueTranslator<java.lang.String>`
      Parameters:
        `object` - the object to be converted
        `streamDataProvider` - TODO
      Returns:
        the string representation of the object
      Throws:
        `java.lang.UnsupportedOperationException` - if objects handled by this instance can only be represented as XML
        `java.lang.ClassCastException` - if the specified object is not an instance of the supported class or does not implement the supported interface
      See Also:
        `ObjectTranslator.javaToRepresentation(java.lang.Object, WriterStreamDataProvider)`