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 Details

    • EMPTY_INT_ARRAY

      private static final int[] EMPTY_INT_ARRAY
    • m_bindingName

      private final String m_bindingName
    • m_majorVersion

      private final int m_majorVersion
    • m_minorVersion

      private final int m_minorVersion
    • m_bindingClasses

      private final String[] m_bindingClasses
    • m_mapNames

      private final String[] m_mapNames
    • m_classIndexMap

      private final StringIntHashMap m_classIndexMap
    • m_unmarshallers

      private final String[] m_unmarshallers
    • m_marshallers

      private final String[] m_marshallers
    • m_uris

      private final String[] m_uris
    • m_prefixes

      private final String[] m_prefixes
    • m_globalNames

      private final String[] m_globalNames
    • m_globalUris

      private final String[] m_globalUris
    • m_idClassNames

      private final String[] m_idClassNames
    • m_abstractMappingDetails

      private final String[][] m_abstractMappingDetails
    • m_abstractMappingNamespaces

      private final int[][] m_abstractMappingNamespaces
    • m_baseNames

      private final String[] m_baseNames
    • m_baseHashes

      private final String m_baseHashes
    • m_bindingFactories

      private final String[] m_bindingFactories
    • m_marshallerClasses

      private final Class[] m_marshallerClasses
    • m_unmarshallerClasses

      private final Class[] m_unmarshallerClasses
    • m_bindingNamespaceTables

      private final Map m_bindingNamespaceTables
    • m_hash

      private final int m_hash
    • m_verified

      private boolean m_verified
    • m_bindingClassesClosure

      private String[] m_bindingClassesClosure
    • m_unmarshalMap

      private Map m_unmarshalMap
  • Constructor Details

    • 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 name
      majorver - binding major version number
      minorver - binding minor version number
      boundnames - blob of class names with code for this binding
      mappednames - blob of class or type names for mappings
      umarnames - unmarshaller class names blob (null if output-only binding)
      marnames - marshaller class names blob (null if input-only binding)
      uris - namespace URIs used by binding
      prefixes - namespace prefixes used by binding (null if input-only binding)
      gmapnames - globally-mapped element names blob
      gmapuris - globally-mapped element namespaces blob
      idclasses - names of classes with IDs
      abmapdetails - abstract mapping details blob
      abmapnss - abstract mapping namespace indexes blob
      prenames - precompiled base binding names blob
      prefacts - base binding factory classes blob
      prehashes - base binding hashes blob
      prensmaps - namespace index mapping tables blobs for precompiled bindings
  • Method Details

    • 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:
      loadClass in interface IBindingFactory
      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 interface IBindingFactory
      Returns:
      context
      Throws:
      JiBXException
    • createUnmarshallingContext

      public IUnmarshallingContext createUnmarshallingContext() throws JiBXException
      Create a new unmarshalling context.
      Specified by:
      createUnmarshallingContext in interface IBindingFactory
      Returns:
      context
      Throws:
      JiBXException
    • getBindingName

      public String getBindingName()
      Get the binding name.
      Specified by:
      getBindingName in interface IBindingFactory
      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 the getMarshallerClass(int) and getUnmarshallerClass(int) methods returning Class objects.
      Specified by:
      getHash in interface IBindingFactory
      Returns:
      hash
    • getMajorVersion

      public int getMajorVersion()
      Get major version number.
      Specified by:
      getMajorVersion in interface IBindingFactory
      Returns:
      major version
    • getMinorVersion

      public int getMinorVersion()
      Get minor version number.
      Specified by:
      getMinorVersion in interface IBindingFactory
      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. If verifyBaseBindings() has not already been invoked it will be invoked by this call.
      Specified by:
      getBindingClasses in interface IBindingFactory
      Returns:
      fully-qualified class names
      Throws:
      JiBXException - on base binding verification error
    • getElementNames

      public String[] getElementNames()
      Get global-mapped element names.
      Specified by:
      getElementNames in interface IBindingFactory
      Returns:
      names
    • getMarshallerClasses

      public String[] getMarshallerClasses()
      Get marshaller class names.
      Specified by:
      getMarshallerClasses in interface IBindingFactory
      Returns:
      array of class names
    • getUnmarshallerClasses

      public String[] getUnmarshallerClasses()
      Get unmarshaller class names.
      Specified by:
      getUnmarshallerClasses in interface IBindingFactory
      Returns:
      array of class names
    • getElementNamespaces

      public String[] getElementNamespaces()
      Get global-mapped element namespace URIs.
      Specified by:
      getElementNamespaces in interface IBindingFactory
      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:
      getMappedClasses in interface IBindingFactory
      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 by getMappedClasses(), getMarshallerClasses(), and getUnmarshallerClasses(), and can also be used as input for getMarshallerClass(int) and getUnmarshallerClass(int).
      Specified by:
      getClassIndexMap in interface IBindingFactory
      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. See IBindingFactory.getAbstractMappings() for details.
      Specified by:
      getAbstractMappings in interface IBindingFactory
      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 interface IBindingFactory
      Parameters:
      index - abstract mapping index, corresponding to the abstract mapping information returned by getAbstractMappings().
      Returns:
      namespace indexes, empty array if none
    • getNamespaces

      public String[] getNamespaces()
      Get the namespace URIs used by the binding.
      Specified by:
      getNamespaces in interface IBindingFactory
      Returns:
      uris
    • getBaseBindings

      public String[] getBaseBindings()
      Get the names of the separately-compiled base bindings used by this binding.
      Specified by:
      getBaseBindings in interface IBindingFactory
      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 interface IBindingFactory
      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:
      getBaseBindingFactories in interface IBindingFactory
      Returns:
      binding factory fully-qualified class names
    • getNamespaceTranslationTableMap

      public Map getNamespaceTranslationTableMap()
      Get a map from full-qualified binding factory names to an array of int 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 interface IBindingFactory
      Returns:
      map to namespace index translation
    • getPrefixes

      public String[] getPrefixes()
      Get the namespace prefixes used by the binding.
      Specified by:
      getPrefixes in interface IBindingFactory
      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 an Integer 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 multiple int class indexes, for every class mapped to the name.
      Specified by:
      getUnmarshalMap in interface IBindingFactory
      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:
      getMarshallerClass in interface IBindingFactory
      Parameters:
      index - marshaller class index
      Returns:
      marshaller class, or null if 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:
      getUnmarshallerClass in interface IBindingFactory
      Parameters:
      index - unmarshaller class index
      Returns:
      unmarshaller class, or null if unable to load class