public class ObjectTranslatorFactory extends java.lang.Object implements W3CXSConstants, ReadWriteConstants
ObjectTranslator
to be used with readers and writers of JPhyloIO to read
and write literal metadata objects. The factory to be used can be specified using the parameter
ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY
.
After creation this factory is empty. New translators can be added to this factory using
#addTranslator(ObjectTranslator, boolean)
. A default set of translators for XSD types can be added by calling
addXSDTranslators(boolean)
. Support for custom JPhyloIO data types can be added using
addJPhyloIOTranslators(boolean)
.
ObjectTranslator
,
ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY
DATA_TYPE_ANY_URI, DATA_TYPE_BASE_64_BINARY, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTE, DATA_TYPE_DATE, DATA_TYPE_DATE_TIME, DATA_TYPE_DECIMAL, DATA_TYPE_DOUBLE, DATA_TYPE_DURATION, DATA_TYPE_FLOAT, DATA_TYPE_G_DAY, DATA_TYPE_G_MONTH, DATA_TYPE_G_MONTH_DAY, DATA_TYPE_G_YEAR, DATA_TYPE_G_YEAR_MONTH, DATA_TYPE_HEX_BINARY, DATA_TYPE_INT, DATA_TYPE_INTEGER, DATA_TYPE_LONG, DATA_TYPE_NAME, DATA_TYPE_NC_NAME, DATA_TYPE_NEGATIVE_INTEGER, DATA_TYPE_NON_NEGATIVE_INTEGER, DATA_TYPE_NON_POSITIVE_INTEGER, DATA_TYPE_NORMALIZED_STRING, DATA_TYPE_POSITIVE_INTEGER, DATA_TYPE_QNAME, DATA_TYPE_SHORT, DATA_TYPE_STRING, DATA_TYPE_TIME, DATA_TYPE_TOKEN, DATA_TYPE_UNSIGNED_BYTE, DATA_TYPE_UNSIGNED_INT, DATA_TYPE_UNSIGNED_LONG, DATA_TYPE_UNSIGNED_SHORT
ATTRIBUTE_STRING_KEY, ATTRIBUTES_NAMESPACE_FOLDER, DATA_TYPE_NAMESPACE_FOLDER, DATA_TYPE_SIMPLE_VALUE_LIST, DEFAULT_CHAR_SET_ID_PREFIX, DEFAULT_CHARACTER_DEFINITION_ID_PREFIX, DEFAULT_EDGE_ID_PREFIX, DEFAULT_GENERAL_ID_PREFIX, DEFAULT_MATRIX_ID_PREFIX, DEFAULT_MAX_COMMENT_LENGTH, DEFAULT_MAX_TOKENS_TO_READ, DEFAULT_META_ID_PREFIX, DEFAULT_NETWORK_ID_PREFIX, DEFAULT_NODE_EDGE_SET_ID_PREFIX, DEFAULT_NODE_ID_PREFIX, DEFAULT_OTU_ID_PREFIX, DEFAULT_OTU_LIST_ID_PREFIX, DEFAULT_OTU_SET_ID_PREFIX, DEFAULT_SEQUENCE_ID_PREFIX, DEFAULT_SEQUENCE_SET_ID_PREFIX, DEFAULT_TOKEN_DEFINITION_ID_PREFIX, DEFAULT_TOKEN_SET_ID_PREFIX, DEFAULT_TREE_ID_PREFIX, DEFAULT_TREE_NETWORK_GROUP_ID_PREFIX, DEFAULT_TREE_NETWORK_SET_ID_PREFIX, JPHYLOIO_ATTRIBUTES_NAMESPACE, JPHYLOIO_ATTRIBUTES_PREFIX, JPHYLOIO_DATA_TYPE_NAMESPACE, JPHYLOIO_DATA_TYPE_PREFIX, JPHYLOIO_FORMATS_NAMESPACE_PREFIX, JPHYLOIO_GENERAL_NAMESPACE, JPHYLOIO_NAMESPACE_PREFIX, JPHYLOIO_PREDICATE_NAMESPACE, JPHYLOIO_PREDICATE_PREFIX, PREDICATE_CHARACTER_COUNT, PREDICATE_EDGE_LENGTH, PREDICATE_EDGE_SOURCE_NODE, PREDICATE_EDGE_TARGET_NODE, PREDICATE_HAS_CUSTOM_XML, PREDICATE_HAS_LITERAL_METADATA, PREDICATE_HAS_RESOURCE_METADATA, PREDICATE_IS_CROSSLINK, PREDICATE_NAMESPACE_FOLDER, PREDICATE_PART_SEPERATOR, PREDICATE_SEQUENCE_COUNT, RESERVED_ID_PREFIX
Constructor and Description |
---|
ObjectTranslatorFactory() |
Modifier and Type | Method and Description |
---|---|
void |
addJPhyloIOTranslators(boolean asDefault)
Adds all translators for custom types defined in JPhyloIO.
|
void |
addTranslator(ObjectTranslator<?> translator,
boolean asDefault,
javax.xml.namespace.QName dataType,
javax.xml.namespace.QName... additionalDataTypes)
Registers a new translator in this factory for one or more data types.
|
void |
addXSDTranslators(boolean asDefault)
Adds all translators for XSD types available in JPhyloIO.
|
ObjectTranslator<?> |
getDefaultTranslator(javax.xml.namespace.QName dataType) |
ObjectTranslator<?> |
getDefaultTranslatorWithPossiblyInvalidNamespace(javax.xml.namespace.QName dataType) |
<O> ObjectTranslator<O> |
getTranslator(javax.xml.namespace.QName dataType,
java.lang.Class<O> objectClass) |
public ObjectTranslatorFactory()
public void addTranslator(ObjectTranslator<?> translator, boolean asDefault, javax.xml.namespace.QName dataType, javax.xml.namespace.QName... additionalDataTypes)
translator
- the translator to be registeredasDefault
- Determines whether this translator shall become the default translator for its data type. (It will
always become the default, if no other translator is currently registered for this data type.)dataType
- the data type to be associated with this translatoradditionalDataTypes
- additional data types for which the specified translator is also validpublic void addXSDTranslators(boolean asDefault)
asDefault
- Determines whether the added translators shall become the default translators for their data type,
if another default instance is already registered. (If true
is specified, previous defaults will be
overwritten. If false
is specified, previous defaults will be maintained. In all cases previous entries
will remain in the factory, if they have a different object type or will be completely overwritten if they have
the same.)public void addJPhyloIOTranslators(boolean asDefault)
ListTranslator
is registered
under ReadWriteConstants.DATA_TYPE_SIMPLE_VALUE_LIST
.asDefault
- Determines whether the added translators shall become the default translators for their data type,
if another default instance is already registered. (If true
is specified, previous defaults will be
overwritten. If false
is specified, previous defaults will be maintained. In all cases previous entries
will remain in the factory, if they have a different object type and will be completely overwritten if they have
the same.)public <O> ObjectTranslator<O> getTranslator(javax.xml.namespace.QName dataType, java.lang.Class<O> objectClass)
public ObjectTranslator<?> getDefaultTranslator(javax.xml.namespace.QName dataType)
public ObjectTranslator<?> getDefaultTranslatorWithPossiblyInvalidNamespace(javax.xml.namespace.QName dataType)