Package org.jibx.runtime
Interface IBindingFactory
- All Known Implementing Classes:
BindingFactoryBase
public interface IBindingFactory
Binding factory interface definition. This interface is implemented by the
binding factory class generated by each binding definition. All binding
factory instances are guaranteed to be threadsafe and reusable.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Abstract mapping details index for attribute marshalling method.static final int
Abstract mapping details index for attribute presence test method.static final int
Abstract mapping details index for attribute unmarshalling method.static final int
Abstract mapping details index for class name.static final int
Abstract mapping details index for unmarshalling complete method.static final int
Abstract mapping details index for content marshalling method.static final int
Abstract mapping details index for content presence test method.static final int
Abstract mapping details index for content unmarshalling method.static final int
Number of abstract mapping details.static final int
Abstract mapping details index for new instance creation method.static final int
Abstract mapping details index for mapping (type or class) name.static final int
Abstract mapping details index for marshalling prepare method.static final int
Mask for portions of version number that effect compatibility.static final String
Current distribution file name.static final int
Current binary version number. -
Method Summary
Modifier and TypeMethodDescriptionCreate marshalling context instance.Create unmarshalling context instance.int[]
getAbstractMappingNamespaces
(int index) Get the indexes of the namespaces used by an abstract mapping.String[][]
Get the linkage information for global abstract mappings included in the binding.String[]
Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.String[]
Get the names of the separately-compiled base bindings used by this binding.String[]
Get the classes used by the binding.Get the name of this binding.Get map from fully-qualified class name to the index number of the class used for accessing the arrays of class names.Get distribution name for binding compiler used.int
Get version number for binding compiler used.String[]
Get names of elements corresponding to mapped classes.String[]
Get namespaces of elements corresponding to mapped classes.int
getHash()
Get hash for binding.int
Get the major version number for this binding.String[]
Get mapped class names (or type names, in the case of abstract mappings).getMarshallerClass
(int index) Get the marshaller class for a mapping.String[]
Get marshaller class names.int
Get the minor version number for this binding.String[]
Get namespaces defined in mapping.Get a map from full-qualified binding factory names to an array ofint
values used to convert namespace indexes in that binding to this binding.String[]
Get initial prefixes for namespaces defined in mapping.int
getTypeIndex
(String type) Get mapped class index from type name for abstract non-base mappings included in the binding.getUnmarshallerClass
(int index) Get the unmarshaller class for a mapping.String[]
Get unmarshaller class names.Get the mapping from element local name to class indexes.Load a class.void
Verify that separately-compiled base bindings used by this binding can be loaded and are compatible with the base bindings used when this binding was compiled.
-
Field Details
-
CURRENT_VERSION_NUMBER
static final int CURRENT_VERSION_NUMBERCurrent binary version number. This is a byte-ordered value, allowing for two levels of major and two levels of minor version.- See Also:
-
CURRENT_VERSION_NAME
Current distribution file name. This is filled in by the Ant build process to match the current distribution.- See Also:
-
COMPATIBLE_VERSION_MASK
static final int COMPATIBLE_VERSION_MASKMask for portions of version number that effect compatibility.- See Also:
-
ABMAP_MAPPINGNAME_INDEX
static final int ABMAP_MAPPINGNAME_INDEXAbstract mapping details index for mapping (type or class) name.- See Also:
-
ABMAP_CLASSNAME_INDEX
static final int ABMAP_CLASSNAME_INDEXAbstract mapping details index for class name.- See Also:
-
ABMAP_CREATEMETH_INDEX
static final int ABMAP_CREATEMETH_INDEXAbstract mapping details index for new instance creation method.- See Also:
-
ABMAP_COMPLETEMETH_INDEX
static final int ABMAP_COMPLETEMETH_INDEXAbstract mapping details index for unmarshalling complete method.- See Also:
-
ABMAP_PREPAREMETH_INDEX
static final int ABMAP_PREPAREMETH_INDEXAbstract mapping details index for marshalling prepare method.- See Also:
-
ABMAP_ATTRPRESMETH_INDEX
static final int ABMAP_ATTRPRESMETH_INDEXAbstract mapping details index for attribute presence test method.- See Also:
-
ABMAP_ATTRUMARMETH_INDEX
static final int ABMAP_ATTRUMARMETH_INDEXAbstract mapping details index for attribute unmarshalling method.- See Also:
-
ABMAP_ATTRMARMETH_INDEX
static final int ABMAP_ATTRMARMETH_INDEXAbstract mapping details index for attribute marshalling method.- See Also:
-
ABMAP_CONTPRESMETH_INDEX
static final int ABMAP_CONTPRESMETH_INDEXAbstract mapping details index for content presence test method.- See Also:
-
ABMAP_CONTUMARMETH_INDEX
static final int ABMAP_CONTUMARMETH_INDEXAbstract mapping details index for content unmarshalling method.- See Also:
-
ABMAP_CONTMARMETH_INDEX
static final int ABMAP_CONTMARMETH_INDEXAbstract mapping details index for content marshalling method.- See Also:
-
ABMAP_COUNT
static final int ABMAP_COUNTNumber of abstract mapping details.- See Also:
-
-
Method Details
-
createMarshallingContext
Create marshalling context instance.- Returns:
- created marshalling context instance
- Throws:
JiBXException
- if error creating contextUnsupportedOperationException
- if marshalling not supported by binding
-
createUnmarshallingContext
Create unmarshalling context instance.- Returns:
- created unmarshalling context instance
- Throws:
JiBXException
- if error creating contextUnsupportedOperationException
- if unmarshalling not supported by binding
-
getCompilerVersion
int getCompilerVersion()Get version number for binding compiler used.- Returns:
- version number of code used to compile binding
-
getCompilerDistribution
String getCompilerDistribution()Get distribution name for binding compiler used.- Returns:
- name of distribution for binding compiler
-
getBindingName
String getBindingName()Get the name of this binding.- Returns:
- name
-
getMajorVersion
int getMajorVersion()Get the major version number for this binding.- Returns:
- major version
-
getMinorVersion
int getMinorVersion()Get the minor version number for this binding.- Returns:
- minor version
-
getHash
int getHash()Get hash for binding. The computed hash value is based on all the values returned by all the methods of this interface, with the exception of thegetMarshallerClass(int)
andgetUnmarshallerClass(int)
methods returningClass
objects.- Returns:
- hash
-
getNamespaces
String[] getNamespaces()Get namespaces defined in mapping. The returned array is indexed by the namespace index number used when marshalling.- Returns:
- array of namespaces defined in binding (
null
if not an output binding)
-
getPrefixes
String[] getPrefixes()Get initial prefixes for namespaces defined in mapping. The returned array is indexed by the namespace index number used when marshalling. Note that these are only the first prefixes associated with each namespace; it's possible to reuse the namespace in the binding with a different prefix.- Returns:
- array of prefixes for namespaces defined in binding
(
null
if not an output binding)
-
getMappedClasses
String[] getMappedClasses()Get mapped class names (or type names, in the case of abstract mappings). Returns array of fully-qualified class and/or type names, ordered by index number of the class.- Returns:
- array of class names
-
getClassIndexMap
StringIntHashMap getClassIndexMap()Get map from fully-qualified class name to the index number of the class used for accessing the arrays of class names. The value returned is the index for the class in the arrays returned bygetMappedClasses()
,getMarshallerClasses()
, andgetUnmarshallerClasses()
, and can also be used as input forgetMarshallerClass(int)
andgetUnmarshallerClass(int)
.- Returns:
- map from fully-qualified class name to index number
-
getElementNamespaces
String[] getElementNamespaces()Get namespaces of elements corresponding to mapped classes. The returned array uses the same ordering as the result of thegetMappedClasses()
call. Entries in the array arenull
if there is no element for a class or the element is in the default namespace.- Returns:
- array of element namespaces
-
getElementNames
String[] getElementNames()Get names of elements corresponding to mapped classes. The returned array uses the same ordering as the result of thegetMappedClasses()
call. Entries in the array arenull
if there is no element for a class.- Returns:
- array of element names
-
getMarshallerClasses
String[] getMarshallerClasses()Get marshaller class names. The returned array uses the same ordering as the result of thegetMappedClasses()
call. Entries in the array arenull
if there is no marshaller class for the mapping.- Returns:
- array of class names
-
getUnmarshallerClasses
String[] getUnmarshallerClasses()Get unmarshaller class names. The returned array uses the same ordering as the result of thegetMappedClasses()
call. Entries in the array arenull
if there is no unmarshaller class for the mapping.- Returns:
- array of class names
-
getTypeIndex
Get mapped class index from type name for abstract non-base mappings included in the binding. This is intended to allow identifying and using abstract mappings (basically type mappings) at runtime. The method only returns a non-negative result if the "force-classes" option is used for the binding definition (since otherwise no marshaller/unmarshaller classes are created for abstract non-base mappings).- Parameters:
type
- fully-qualified class or type name- Returns:
- mapping index for type, or
-1
if type is not an abstract non-base mapping
-
getBindingClasses
Get the classes used by the binding. Every class which includes code generated by the binding compiler for this binding or any precompiled base binding is included in the returned array. IfverifyBaseBindings()
has not already been invoked it will be invoked by this call.- Returns:
- fully-qualified class names
- Throws:
JiBXException
- on base binding verification error
-
getAbstractMappings
String[][] getAbstractMappings()Get the linkage information for global abstract mappings included in the binding. The returned array has a primary (first index) dimension of 11 and a secondary (second index) dimension equal to the number of global abstract mappings. The different index values for the first index give the following information:- 0 - mapping name (type or class)
- 1 - class name
- 2 - new instance creation method (
null
if none) - 3 - unmarshalling complete method (
null
if none) - 4 - prepare for marshalling method (
null
if none) - 5 - attribute presence test method (
null
if none) - 6 - attribute unmarshaller method (
null
if none) - 7 - attribute marshaller method (
null
if none) - 8 - content presence test method (
null
if none) - 9 - content unmarshaller method (
null
if none) - 10 - content marshaller method (
null
if none)
- Returns:
- method information array
-
getAbstractMappingNamespaces
int[] getAbstractMappingNamespaces(int index) Get the indexes of the namespaces used by an abstract mapping.- Parameters:
index
- abstract mapping index, corresponding to the abstract mapping information returned bygetAbstractMappings()
.- Returns:
- namespace indexes, empty array if none
-
getUnmarshalMap
Map getUnmarshalMap()Get the mapping from element local name to class indexes. If a local name is only used with a single namespace, the value for that name is anInteger
giving the index of the class mapped to the name; if the local name is used with multiple namespaces, the value for that name is an array with multipleint
class indexes, for every class mapped to the name.- Returns:
- map from local name to class index array
-
getUnmarshallerClass
Get the unmarshaller class for a mapping. This can only be used for global mappings.- Parameters:
index
- unmarshaller class index- Returns:
- unmarshaller class, or
null
if unable to load class
-
getMarshallerClass
Get the marshaller class for a mapping. This can only be used for global mappings.- Parameters:
index
- marshaller class index- Returns:
- marshaller class, or
null
if unable to load class
-
getBaseBindings
String[] getBaseBindings()Get the names of the separately-compiled base bindings used by this binding.- Returns:
- binding names
-
verifyBaseBindings
Verify that separately-compiled base bindings used by this binding can be loaded and are compatible with the base bindings used when this binding was compiled.- Throws:
JiBXException
- on verification failure
-
getBaseBindingFactories
String[] getBaseBindingFactories()Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.- Returns:
- binding factory fully-qualified class names
-
getNamespaceTranslationTableMap
Map getNamespaceTranslationTableMap()Get a map from full-qualified binding factory names to an array ofint
values used to convert namespace indexes in that binding to this binding. If the binding uses the same namespaces as this binding (or a subset of the same namespaces, with the same index values) there is no entry in the map.- Returns:
- map to namespace index translation
-
loadClass
Load a class. This first tries to load the specified class using the classloader that loaded the binding factory instance, then tries the thread context classloader, then finally tries the classloader used to load core runtime classes.- Parameters:
name
- fully qualified class name- Returns:
- loaded class, or
null
if class not found
-