info.bioinfweb.jphyloio.objecttranslation.implementations

## Class AbstractXMLObjectTranslator<O>

- java.lang.Object
- - info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractObjectTranslator<O>
  - - info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractXMLObjectTranslator<O>

- Type Parameters:
    `O` - the type of Java object this translator instance is able to handle
  All Implemented Interfaces:
    ObjectTranslator<O>

      public abstract class AbstractXMLObjectTranslator<O>
      extends AbstractObjectTranslator<O>

  Abstract implementation for object translators that need XML tags to represent their object and do not support simple string representations.
  Author:
    Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractXMLObjectTranslator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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 specified Java object to its string representation.
    `O` | `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.AbstractObjectTranslator

      `equals, hashCode`

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

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

    - ### Methods inherited from interface info.bioinfweb.jphyloio.objecttranslation.ObjectTranslator

      `getObjectClass, readXMLRepresentation, writeXMLRepresentation`

- - ### Constructor Detail

    - #### AbstractXMLObjectTranslator

          public AbstractXMLObjectTranslator()

  - ### Method Detail

    - #### hasStringRepresentation

          public boolean hasStringRepresentation()

      Description copied from interface: `ObjectTranslator`
      Determines whether the objects handled by this instance have a simple string representation or need a more complex XML representation.

      Instances that return `false here` will throw an `UnsupportedOperationException`, if `ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider)` is called.

      Returns:
        `true` if handled objects have a simple string representation or `false` if XML is necessary to represent the handled objects

    - #### javaToRepresentation

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

      Description copied from interface: `ObjectTranslator`
      Converts the specified Java object to its string representation.
      Parameters:
        `object` - the object to be translated
        `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.hasStringRepresentation()`

    - #### representationToJava

          public O 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