public class ListTranslator extends SimpleValueTranslator<List<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, 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, ROOTED_HOT_COMMENT, SUBTREE_END, SUBTREE_START, TERMINAL_SYMBOL, UNROOTED_HOT_COMMENT
Constructor and Description |
---|
ListTranslator() |
Modifier and Type | Method and Description |
---|---|
Class<List<Object>> |
getObjectClass()
Returns the Java class of object instances created by this translator.
|
String |
javaToRepresentation(Object object,
WriterStreamDataProvider<?> streamDataProvider)
Creates the string representation of a simple value list from any object that implements
Iterable . |
static String |
listToString(Iterable<?> list) |
static List<Object> |
parseList(String representation)
Reads a string representation of a simple value list into an implementation of
List . |
List<Object> |
representationToJava(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 Class<List<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<List<Object>>
public static List<Object> parseList(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 List<Object> representationToJava(String representation, ReaderStreamDataProvider<?> streamDataProvider) throws InvalidObjectSourceDataException, 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<List<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 objectUnsupportedOperationException
- if objects handled by this instance can only be represented as XMLObjectTranslator.representationToJava(java.lang.String, info.bioinfweb.jphyloio.ReaderStreamDataProvider)
public static String listToString(Iterable<?> list) throws ClassCastException
ClassCastException
public String javaToRepresentation(Object object, WriterStreamDataProvider<?> streamDataProvider) throws ClassCastException
Iterable
.javaToRepresentation
in interface ObjectTranslator<List<Object>>
javaToRepresentation
in class SimpleValueTranslator<List<Object>>
object
- the Iterable
to be convertedstreamDataProvider
- TODOClassCastException
- if object
does not implement Iterable
ObjectTranslator.javaToRepresentation(java.lang.Object, WriterStreamDataProvider)