Package org.jibx.runtime.impl
Class BindingFactoryBase
- java.lang.Object
-
- org.jibx.runtime.impl.BindingFactoryBase
-
- All Implemented Interfaces:
IBindingFactory
public abstract class BindingFactoryBase extends 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 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 protectedBindingFactoryBase(String name, int majorver, int minorver, String boundnames, String mappednames, String umarnames, String marnames, String[] uris, String[] prefixes, String gmapnames, String gmapuris, String[] idclasses, String abmapdetails, String abmapnss, String prenames, String prefacts, String prehashes, String[] prensmaps)Constructor used in generated binding factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMarshallingContextcreateMarshallingContext()Create a new marshalling context.IUnmarshallingContextcreateUnmarshallingContext()Create a new unmarshalling context.int[]getAbstractMappingNamespaces(int index)Get the indexes of the namespaces used by an abstract mapping.String[][]getAbstractMappings()Get the linkage information for global abstract mappings included in the binding.String[]getBaseBindingFactories()Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.String[]getBaseBindings()Get the names of the separately-compiled base bindings used by this binding.String[]getBindingClasses()Get the classes used by the binding.StringgetBindingName()Get the binding name.StringIntHashMapgetClassIndexMap()Get map from fully-qualified class name to the index number of the class used for accessing the arrays of class names.String[]getElementNames()Get global-mapped element names.String[]getElementNamespaces()Get global-mapped element namespace URIs.intgetHash()Get hash for binding.intgetMajorVersion()Get major version number.String[]getMappedClasses()Get mapped class names (or type names, in the case of abstract mappings).ClassgetMarshallerClass(int index)Get the marshaller class for a mapping.String[]getMarshallerClasses()Get marshaller class names.intgetMinorVersion()Get minor version number.String[]getNamespaces()Get the namespace URIs used by the binding.MapgetNamespaceTranslationTableMap()Get a map from full-qualified binding factory names to an array ofintvalues used to convert namespace indexes in that binding to this binding.String[]getPrefixes()Get the namespace prefixes used by the binding.ClassgetUnmarshallerClass(int index)Get the unmarshaller class for a mapping.String[]getUnmarshallerClasses()Get unmarshaller class names.MapgetUnmarshalMap()Get the mapping from element local name to class indexes.ClassloadClass(String name)Load a class.voidverifyBaseBindings()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
-
-
-
-
Constructor Detail
-
BindingFactoryBase
protected BindingFactoryBase(String name, int majorver, int minorver, String boundnames, String mappednames, String umarnames, String marnames, String[] uris, String[] prefixes, String gmapnames, String gmapuris, String[] idclasses, String abmapdetails, String abmapnss, String prenames, String prefacts, String prehashes, 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 (nullif output-only binding)marnames- marshaller class names blob (nullif input-only binding)uris- namespace URIs used by bindingprefixes- namespace prefixes used by binding (nullif 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 Class loadClass(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:
loadClassin interfaceIBindingFactory- Parameters:
name- fully qualified class name- Returns:
- loaded class, or
nullif class not found
-
createMarshallingContext
public IMarshallingContext createMarshallingContext() throws JiBXException
Create a new marshalling context.- Specified by:
createMarshallingContextin interfaceIBindingFactory- Returns:
- context Marshalling context
- Throws:
JiBXException- If error
-
createUnmarshallingContext
public IUnmarshallingContext createUnmarshallingContext() throws JiBXException
Create a new unmarshalling context.- Specified by:
createUnmarshallingContextin interfaceIBindingFactory- Returns:
- context Unmarshalling context
- Throws:
JiBXException- If error
-
getBindingName
public String getBindingName()
Get the binding name.- Specified by:
getBindingNamein interfaceIBindingFactory- Returns:
- name Binding 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 returningClassobjects.- Specified by:
getHashin interfaceIBindingFactory- Returns:
- hash
-
getMajorVersion
public int getMajorVersion()
Get major version number.- Specified by:
getMajorVersionin interfaceIBindingFactory- Returns:
- major version
-
getMinorVersion
public int getMinorVersion()
Get minor version number.- Specified by:
getMinorVersionin interfaceIBindingFactory- Returns:
- minor version
-
getBindingClasses
public 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:
getBindingClassesin interfaceIBindingFactory- Returns:
- fully-qualified class names
- Throws:
JiBXException- on base binding verification error
-
getElementNames
public String[] getElementNames()
Get global-mapped element names.- Specified by:
getElementNamesin interfaceIBindingFactory- Returns:
- names
-
getMarshallerClasses
public String[] getMarshallerClasses()
Get marshaller class names.- Specified by:
getMarshallerClassesin interfaceIBindingFactory- Returns:
- array of class names
-
getUnmarshallerClasses
public String[] getUnmarshallerClasses()
Get unmarshaller class names.- Specified by:
getUnmarshallerClassesin interfaceIBindingFactory- Returns:
- array of class names
-
getElementNamespaces
public String[] getElementNamespaces()
Get global-mapped element namespace URIs.- Specified by:
getElementNamespacesin interfaceIBindingFactory- Returns:
- uris
-
getMappedClasses
public 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:
getMappedClassesin 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:
getClassIndexMapin interfaceIBindingFactory- Returns:
- map from fully-qualified class name to index number
-
getAbstractMappings
public String[][] getAbstractMappings()
Get the linkage information for global abstract mappings included in the binding. SeeIBindingFactory.getAbstractMappings()for details.- Specified by:
getAbstractMappingsin interfaceIBindingFactory- Returns:
- method information array
-
getAbstractMappingNamespaces
public int[] getAbstractMappingNamespaces(int index)
Get the indexes of the namespaces used by an abstract mapping.- Specified by:
getAbstractMappingNamespacesin interfaceIBindingFactory- Parameters:
index- abstract mapping index, corresponding to the abstract mapping information returned bygetAbstractMappings().- Returns:
- namespace indexes, empty array if none
-
getNamespaces
public String[] getNamespaces()
Get the namespace URIs used by the binding.- Specified by:
getNamespacesin interfaceIBindingFactory- Returns:
- uris
-
getBaseBindings
public String[] getBaseBindings()
Get the names of the separately-compiled base bindings used by this binding.- Specified by:
getBaseBindingsin interfaceIBindingFactory- Returns:
- binding names
-
verifyBaseBindings
public void verifyBaseBindings() throws JiBXExceptionVerify 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:
verifyBaseBindingsin interfaceIBindingFactory- Throws:
JiBXException- on verification failure
-
getBaseBindingFactories
public String[] getBaseBindingFactories()
Get the names of the binding factory classes for the separately-compiled base bindings used by this binding.- Specified by:
getBaseBindingFactoriesin interfaceIBindingFactory- Returns:
- binding factory fully-qualified class names
-
getNamespaceTranslationTableMap
public Map getNamespaceTranslationTableMap()
Get a map from full-qualified binding factory names to an array ofintvalues 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:
getNamespaceTranslationTableMapin interfaceIBindingFactory- Returns:
- map to namespace index translation
-
getPrefixes
public String[] getPrefixes()
Get the namespace prefixes used by the binding.- Specified by:
getPrefixesin interfaceIBindingFactory- Returns:
- prefixes
-
getUnmarshalMap
public 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 anIntegergiving 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 multipleintclass indexes, for every class mapped to the name.- Specified by:
getUnmarshalMapin interfaceIBindingFactory- Returns:
- map from local name to class index array
-
getMarshallerClass
public Class getMarshallerClass(int index)
Get the marshaller class for a mapping. This can only be used for global mappings.- Specified by:
getMarshallerClassin interfaceIBindingFactory- Parameters:
index- marshaller class index- Returns:
- marshaller class, or
nullif unable to load class
-
getUnmarshallerClass
public Class getUnmarshallerClass(int index)
Get the unmarshaller class for a mapping. This can only be used for global mappings.- Specified by:
getUnmarshallerClassin interfaceIBindingFactory- Parameters:
index- unmarshaller class index- Returns:
- unmarshaller class, or
nullif unable to load class
-
-