public class ListTranslator extends SimpleValueTranslator<java.util.List<java.lang.Object>> implements NewickConstants
Example:
{18.2, 'AB C', 22}For a possible format independent use, the data type
ReadWriteConstants.DATA_TYPE_SIMPLE_VALUE_LIST
allows to use this translator also in NeXML, although it primarily meant for Newick and Nexus.ReadWriteConstants.DATA_TYPE_SIMPLE_VALUE_LIST
,
ObjectTranslatorFactory.addJPhyloIOTranslators(boolean)
MAX_STRING_REPRESENTATION_LENGTH
ALLOCATION_SEPARATOR_SYMBOL, ALLOCATION_SYMBOL, ALTERNATIVE_NAME_DELIMITER, COMMENT_END, COMMENT_START, DATA_TYPE_NEWICK_ARRAY, E_NEWICK_EDGE_TYPE_HYBRIDIZATION, E_NEWICK_EDGE_TYPE_LATERAL_GENE_TRANSFER, E_NEWICK_EDGE_TYPE_RECOMBINATION, E_NEWICK_NAMESPACE_PREFIX, E_NEWICK_NETWORK_DATA_SEPARATOR, ELEMENT_SEPERATOR, FIELD_END_SYMBOL, FIELD_START_SYMBOL, FIELD_VALUE_SEPARATOR_SYMBOL, FREE_NAME_BLANK, HOT_COMMENT_START_SYMBOL, INDEX_END_SYMBOL, INDEX_START_SYMBOL, LENGTH_SEPERATOR, NAME_DELIMITER, NEWICK_DATA_TYPE_NAMESPACE, NEWICK_FORMAT_NAME, NEWICK_NAMESPACE_PREFIX, NHX_KEY_CONFIDENCE, NHX_KEY_EVENT, NHX_KEY_GENE_NAME, NHX_KEY_PREFIX, NHX_KEY_SCIENTIFIC_NAME, NHX_KEY_SEQUENCE_ACCESSION, NHX_KEY_TAXONOMY_ID, NHX_START, NHX_VALUE_SEPARATOR_SYMBOL, PREDICATE_E_NEWICK_EDGE_TYPE, ROOTED_HOT_COMMENT, SUBTREE_END, SUBTREE_START, TERMINAL_SYMBOL, UNROOTED_HOT_COMMENT
Constructor and Description |
---|
ListTranslator() |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<java.util.List<java.lang.Object>> |
getObjectClass()
Returns the Java class of object instances created by this translator.
|
java.lang.String |
javaToRepresentation(java.lang.Object object,
WriterStreamDataProvider<?> streamDataProvider)
Creates the string representation of a simple value list from any object that implements
Iterable . |
static java.lang.String |
listToString(java.lang.Iterable<?> list) |
static java.util.List<java.lang.Object> |
parseList(java.lang.String representation)
Reads a string representation of a simple value list into an implementation of
List . |
java.util.List<java.lang.Object> |
representationToJava(java.lang.String representation,
ReaderStreamDataProvider<?> streamDataProvider)
Reads a string representation of a simple value list into an implementation of
List . |
hasStringRepresentation, readXMLRepresentation, writeXMLRepresentation
equals, hashCode
public ListTranslator()
public java.lang.Class<java.util.List<java.lang.Object>> 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.
getObjectClass
in interface ObjectTranslator<java.util.List<java.lang.Object>>
public static java.util.List<java.lang.Object> parseList(java.lang.String representation) throws InvalidObjectSourceDataException
List
. The single elements are either
instances of String
or any implementation of Number
. Double
will be used by default, for values
having a higher precision, BigDecimal
will be used instead.representation
- the string representation of the listInvalidObjectSourceDataException
public java.util.List<java.lang.Object> representationToJava(java.lang.String representation, ReaderStreamDataProvider<?> streamDataProvider) throws InvalidObjectSourceDataException, java.lang.UnsupportedOperationException
List
. The single elements are either
instances of String
or any implementation of Number
. Double
will be used by default, for values
having a higher precision, BigDecimal
will be used instead.representationToJava
in interface ObjectTranslator<java.util.List<java.lang.Object>>
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 XMLObjectTranslator.representationToJava(java.lang.String, info.bioinfweb.jphyloio.ReaderStreamDataProvider)
public static java.lang.String listToString(java.lang.Iterable<?> list) throws java.lang.ClassCastException
java.lang.ClassCastException
public java.lang.String javaToRepresentation(java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider) throws java.lang.ClassCastException
Iterable
.javaToRepresentation
in interface ObjectTranslator<java.util.List<java.lang.Object>>
javaToRepresentation
in class SimpleValueTranslator<java.util.List<java.lang.Object>>
object
- the Iterable
to be convertedstreamDataProvider
- TODOjava.lang.ClassCastException
- if object
does not implement Iterable
ObjectTranslator.javaToRepresentation(java.lang.Object, WriterStreamDataProvider)