Package org.jibx.runtime.impl
Class BindingFactoryBase
- java.lang.Object
-
- org.jibx.runtime.impl.BindingFactoryBase
-
- All Implemented Interfaces:
IBindingFactory
public abstract class BindingFactoryBase extends java.lang.Object implements IBindingFactory
Base class for generated binding factories. This provides common implementation code, so that the code does not need to be duplicated in every generated binding factory.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private static int[]
EMPTY_INT_ARRAY
private java.lang.String[][]
m_abstractMappingDetails
private int[][]
m_abstractMappingNamespaces
private java.lang.String
m_baseHashes
private java.lang.String[]
m_baseNames
private java.lang.String[]
m_bindingClasses
private java.lang.String[]
m_bindingClassesClosure
private java.lang.String[]
m_bindingFactories
private java.lang.String
m_bindingName
private java.util.Map
m_bindingNamespaceTables
private StringIntHashMap
m_classIndexMap
private java.lang.String[]
m_globalNames
private java.lang.String[]
m_globalUris
private int
m_hash
private java.lang.String[]
m_idClassNames
private int
m_majorVersion
private java.lang.String[]
m_mapNames
private java.lang.Class[]
m_marshallerClasses
private java.lang.String[]
m_marshallers
private int
m_minorVersion
private java.lang.String[]
m_prefixes
private java.lang.Class[]
m_unmarshallerClasses
private java.lang.String[]
m_unmarshallers
private java.util.Map
m_unmarshalMap
private java.lang.String[]
m_uris
private boolean
m_verified
-
Fields inherited from interface org.jibx.runtime.IBindingFactory
ABMAP_ATTRMARMETH_INDEX, ABMAP_ATTRPRESMETH_INDEX, ABMAP_ATTRUMARMETH_INDEX, ABMAP_CLASSNAME_INDEX, ABMAP_COMPLETEMETH_INDEX, ABMAP_CONTMARMETH_INDEX, ABMAP_CONTPRESMETH_INDEX, ABMAP_CONTUMARMETH_INDEX, ABMAP_COUNT, ABMAP_CREATEMETH_INDEX, ABMAP_MAPPINGNAME_INDEX, ABMAP_PREPAREMETH_INDEX, COMPATIBLE_VERSION_MASK, CURRENT_VERSION_NAME, CURRENT_VERSION_NUMBER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BindingFactoryBase(java.lang.String name, int majorver, int minorver, java.lang.String boundnames, java.lang.String mappednames, java.lang.String umarnames, java.lang.String marnames, java.lang.String[] uris, java.lang.String[] prefixes, java.lang.String gmapnames, java.lang.String gmapuris, java.lang.String[] idclasses, java.lang.String abmapdetails, java.lang.String abmapnss, java.lang.String prenames, java.lang.String prefacts, java.lang.String prehashes, java.lang.String[] prensmaps)
Constructor used in generated binding factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMarshallingContext
createMarshallingContext()
Create a new marshalling context.IUnmarshallingContext
createUnmarshallingContext()
Create a new unmarshalling context.int[]
getAbstractMappingNamespaces(int index)
Get the indexes of the namespaces used by an abstract mapping.java.lang.String[][]
getAbstractMappings()
Get the linkage information for global abstract mappings included in the binding.java.lang.String[]
getBaseBindingFactories()
Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.java.lang.String[]
getBaseBindings()
Get the names of the separately-compiled base bindings used by this binding.java.lang.String[]
getBindingClasses()
Get the classes used by the binding.java.lang.String
getBindingName()
Get the binding name.StringIntHashMap
getClassIndexMap()
Get map from fully-qualified class name to the index number of the class used for accessing the arrays of class names.java.lang.String[]
getElementNames()
Get global-mapped element names.java.lang.String[]
getElementNamespaces()
Get global-mapped element namespace URIs.int
getHash()
Get hash for binding.int
getMajorVersion()
Get major version number.java.lang.String[]
getMappedClasses()
Get mapped class names (or type names, in the case of abstract mappings).java.lang.Class
getMarshallerClass(int index)
Get the marshaller class for a mapping.java.lang.String[]
getMarshallerClasses()
Get marshaller class names.int
getMinorVersion()
Get minor version number.java.lang.String[]
getNamespaces()
Get the namespace URIs used by the binding.java.util.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.java.lang.String[]
getPrefixes()
Get the namespace prefixes used by the binding.java.lang.Class
getUnmarshallerClass(int index)
Get the unmarshaller class for a mapping.java.lang.String[]
getUnmarshallerClasses()
Get unmarshaller class names.java.util.Map
getUnmarshalMap()
Get the mapping from element local name to class indexes.java.lang.Class
loadClass(java.lang.String name)
Load a class.void
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jibx.runtime.IBindingFactory
getCompilerDistribution, getCompilerVersion, getTypeIndex
-
-
-
-
Field Detail
-
EMPTY_INT_ARRAY
private static final int[] EMPTY_INT_ARRAY
-
m_bindingName
private final java.lang.String m_bindingName
-
m_majorVersion
private final int m_majorVersion
-
m_minorVersion
private final int m_minorVersion
-
m_bindingClasses
private final java.lang.String[] m_bindingClasses
-
m_mapNames
private final java.lang.String[] m_mapNames
-
m_classIndexMap
private final StringIntHashMap m_classIndexMap
-
m_unmarshallers
private final java.lang.String[] m_unmarshallers
-
m_marshallers
private final java.lang.String[] m_marshallers
-
m_uris
private final java.lang.String[] m_uris
-
m_prefixes
private final java.lang.String[] m_prefixes
-
m_globalNames
private final java.lang.String[] m_globalNames
-
m_globalUris
private final java.lang.String[] m_globalUris
-
m_idClassNames
private final java.lang.String[] m_idClassNames
-
m_abstractMappingDetails
private final java.lang.String[][] m_abstractMappingDetails
-
m_abstractMappingNamespaces
private final int[][] m_abstractMappingNamespaces
-
m_baseNames
private final java.lang.String[] m_baseNames
-
m_baseHashes
private final java.lang.String m_baseHashes
-
m_bindingFactories
private final java.lang.String[] m_bindingFactories
-
m_marshallerClasses
private final java.lang.Class[] m_marshallerClasses
-
m_unmarshallerClasses
private final java.lang.Class[] m_unmarshallerClasses
-
m_bindingNamespaceTables
private final java.util.Map m_bindingNamespaceTables
-
m_hash
private final int m_hash
-
m_verified
private boolean m_verified
-
m_bindingClassesClosure
private java.lang.String[] m_bindingClassesClosure
-
m_unmarshalMap
private java.util.Map m_unmarshalMap
-
-
Constructor Detail
-
BindingFactoryBase
protected BindingFactoryBase(java.lang.String name, int majorver, int minorver, java.lang.String boundnames, java.lang.String mappednames, java.lang.String umarnames, java.lang.String marnames, java.lang.String[] uris, java.lang.String[] prefixes, java.lang.String gmapnames, java.lang.String gmapuris, java.lang.String[] idclasses, java.lang.String abmapdetails, java.lang.String abmapnss, java.lang.String prenames, java.lang.String prefacts, java.lang.String prehashes, java.lang.String[] prensmaps)
Constructor used in generated binding factories.- Parameters:
name
- binding namemajorver
- binding major version numberminorver
- binding minor version numberboundnames
- blob of class names with code for this bindingmappednames
- blob of class or type names for mappingsumarnames
- unmarshaller class names blob (null
if output-only binding)marnames
- marshaller class names blob (null
if input-only binding)uris
- namespace URIs used by bindingprefixes
- namespace prefixes used by binding (null
if input-only binding)gmapnames
- globally-mapped element names blobgmapuris
- globally-mapped element namespaces blobidclasses
- names of classes with IDsabmapdetails
- abstract mapping details blobabmapnss
- abstract mapping namespace indexes blobprenames
- precompiled base binding names blobprefacts
- base binding factory classes blobprehashes
- base binding hashes blobprensmaps
- namespace index mapping tables blobs for precompiled bindings
-
-
Method Detail
-
loadClass
public java.lang.Class loadClass(java.lang.String name)
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 this class.- Specified by:
loadClass
in interfaceIBindingFactory
- Parameters:
name
- fully qualified class name- Returns:
- loaded class, or
null
if class not found
-
createMarshallingContext
public IMarshallingContext createMarshallingContext() throws JiBXException
Create a new marshalling context.- Specified by:
createMarshallingContext
in interfaceIBindingFactory
- Returns:
- context
- Throws:
JiBXException
-
createUnmarshallingContext
public IUnmarshallingContext createUnmarshallingContext() throws JiBXException
Create a new unmarshalling context.- Specified by:
createUnmarshallingContext
in interfaceIBindingFactory
- Returns:
- context
- Throws:
JiBXException
-
getBindingName
public java.lang.String getBindingName()
Get the binding name.- Specified by:
getBindingName
in interfaceIBindingFactory
- Returns:
- name
-
getHash
public 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.- Specified by:
getHash
in interfaceIBindingFactory
- Returns:
- hash
-
getMajorVersion
public int getMajorVersion()
Get major version number.- Specified by:
getMajorVersion
in interfaceIBindingFactory
- Returns:
- major version
-
getMinorVersion
public int getMinorVersion()
Get minor version number.- Specified by:
getMinorVersion
in interfaceIBindingFactory
- Returns:
- minor version
-
getBindingClasses
public java.lang.String[] getBindingClasses() throws JiBXException
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.- Specified by:
getBindingClasses
in interfaceIBindingFactory
- Returns:
- fully-qualified class names
- Throws:
JiBXException
- on base binding verification error
-
getElementNames
public java.lang.String[] getElementNames()
Get global-mapped element names.- Specified by:
getElementNames
in interfaceIBindingFactory
- Returns:
- names
-
getMarshallerClasses
public java.lang.String[] getMarshallerClasses()
Get marshaller class names.- Specified by:
getMarshallerClasses
in interfaceIBindingFactory
- Returns:
- array of class names
-
getUnmarshallerClasses
public java.lang.String[] getUnmarshallerClasses()
Get unmarshaller class names.- Specified by:
getUnmarshallerClasses
in interfaceIBindingFactory
- Returns:
- array of class names
-
getElementNamespaces
public java.lang.String[] getElementNamespaces()
Get global-mapped element namespace URIs.- Specified by:
getElementNamespaces
in interfaceIBindingFactory
- Returns:
- uris
-
getMappedClasses
public java.lang.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.- Specified by:
getMappedClasses
in interfaceIBindingFactory
- Returns:
- array of class names
-
getClassIndexMap
public 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)
.- Specified by:
getClassIndexMap
in interfaceIBindingFactory
- Returns:
- map from fully-qualified class name to index number
-
getAbstractMappings
public java.lang.String[][] getAbstractMappings()
Get the linkage information for global abstract mappings included in the binding. SeeIBindingFactory.getAbstractMappings()
for details.- Specified by:
getAbstractMappings
in interfaceIBindingFactory
- Returns:
- method information array
-
getAbstractMappingNamespaces
public int[] getAbstractMappingNamespaces(int index)
Get the indexes of the namespaces used by an abstract mapping.- Specified by:
getAbstractMappingNamespaces
in interfaceIBindingFactory
- Parameters:
index
- abstract mapping index, corresponding to the abstract mapping information returned bygetAbstractMappings()
.- Returns:
- namespace indexes, empty array if none
-
getNamespaces
public java.lang.String[] getNamespaces()
Get the namespace URIs used by the binding.- Specified by:
getNamespaces
in interfaceIBindingFactory
- Returns:
- uris
-
getBaseBindings
public java.lang.String[] getBaseBindings()
Get the names of the separately-compiled base bindings used by this binding.- Specified by:
getBaseBindings
in interfaceIBindingFactory
- Returns:
- binding names
-
verifyBaseBindings
public void verifyBaseBindings() throws JiBXException
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.- Specified by:
verifyBaseBindings
in interfaceIBindingFactory
- Throws:
JiBXException
- on verification failure
-
getBaseBindingFactories
public java.lang.String[] getBaseBindingFactories()
Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.- Specified by:
getBaseBindingFactories
in interfaceIBindingFactory
- Returns:
- binding factory fully-qualified class names
-
getNamespaceTranslationTableMap
public java.util.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.- Specified by:
getNamespaceTranslationTableMap
in interfaceIBindingFactory
- Returns:
- map to namespace index translation
-
getPrefixes
public java.lang.String[] getPrefixes()
Get the namespace prefixes used by the binding.- Specified by:
getPrefixes
in interfaceIBindingFactory
- Returns:
- prefixes
-
getUnmarshalMap
public java.util.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.- Specified by:
getUnmarshalMap
in interfaceIBindingFactory
- Returns:
- map from local name to class index array
-
getMarshallerClass
public java.lang.Class getMarshallerClass(int index)
Get the marshaller class for a mapping. This can only be used for global mappings.- Specified by:
getMarshallerClass
in interfaceIBindingFactory
- Parameters:
index
- marshaller class index- Returns:
- marshaller class, or
null
if unable to load class
-
getUnmarshallerClass
public java.lang.Class getUnmarshallerClass(int index)
Get the unmarshaller class for a mapping. This can only be used for global mappings.- Specified by:
getUnmarshallerClass
in interfaceIBindingFactory
- Parameters:
index
- unmarshaller class index- Returns:
- unmarshaller class, or
null
if unable to load class
-
-