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 Detail

      • CURRENT_VERSION_NUMBER

        static final int CURRENT_VERSION_NUMBER
        Current binary version number. This is a byte-ordered value, allowing for two levels of major and two levels of minor version.
        See Also:
        Constant Field Values
      • CURRENT_VERSION_NAME

        static final java.lang.String CURRENT_VERSION_NAME
        Current distribution file name. This is filled in by the Ant build process to match the current distribution.
        See Also:
        Constant Field Values
      • COMPATIBLE_VERSION_MASK

        static final int COMPATIBLE_VERSION_MASK
        Mask for portions of version number that effect compatibility.
        See Also:
        Constant Field Values
      • ABMAP_MAPPINGNAME_INDEX

        static final int ABMAP_MAPPINGNAME_INDEX
        Abstract mapping details index for mapping (type or class) name.
        See Also:
        Constant Field Values
      • ABMAP_CLASSNAME_INDEX

        static final int ABMAP_CLASSNAME_INDEX
        Abstract mapping details index for class name.
        See Also:
        Constant Field Values
      • ABMAP_CREATEMETH_INDEX

        static final int ABMAP_CREATEMETH_INDEX
        Abstract mapping details index for new instance creation method.
        See Also:
        Constant Field Values
      • ABMAP_COMPLETEMETH_INDEX

        static final int ABMAP_COMPLETEMETH_INDEX
        Abstract mapping details index for unmarshalling complete method.
        See Also:
        Constant Field Values
      • ABMAP_PREPAREMETH_INDEX

        static final int ABMAP_PREPAREMETH_INDEX
        Abstract mapping details index for marshalling prepare method.
        See Also:
        Constant Field Values
      • ABMAP_ATTRPRESMETH_INDEX

        static final int ABMAP_ATTRPRESMETH_INDEX
        Abstract mapping details index for attribute presence test method.
        See Also:
        Constant Field Values
      • ABMAP_ATTRUMARMETH_INDEX

        static final int ABMAP_ATTRUMARMETH_INDEX
        Abstract mapping details index for attribute unmarshalling method.
        See Also:
        Constant Field Values
      • ABMAP_ATTRMARMETH_INDEX

        static final int ABMAP_ATTRMARMETH_INDEX
        Abstract mapping details index for attribute marshalling method.
        See Also:
        Constant Field Values
      • ABMAP_CONTPRESMETH_INDEX

        static final int ABMAP_CONTPRESMETH_INDEX
        Abstract mapping details index for content presence test method.
        See Also:
        Constant Field Values
      • ABMAP_CONTUMARMETH_INDEX

        static final int ABMAP_CONTUMARMETH_INDEX
        Abstract mapping details index for content unmarshalling method.
        See Also:
        Constant Field Values
      • ABMAP_CONTMARMETH_INDEX

        static final int ABMAP_CONTMARMETH_INDEX
        Abstract mapping details index for content marshalling method.
        See Also:
        Constant Field Values
      • ABMAP_COUNT

        static final int ABMAP_COUNT
        Number of abstract mapping details.
        See Also:
        Constant Field Values
    • Method Detail

      • createMarshallingContext

        IMarshallingContext createMarshallingContext()
                                              throws JiBXException
        Create marshalling context instance.
        Returns:
        created marshalling context instance
        Throws:
        JiBXException - if error creating context
        java.lang.UnsupportedOperationException - if marshalling not supported by binding
      • createUnmarshallingContext

        IUnmarshallingContext createUnmarshallingContext()
                                                  throws JiBXException
        Create unmarshalling context instance.
        Returns:
        created unmarshalling context instance
        Throws:
        JiBXException - if error creating context
        java.lang.UnsupportedOperationException - 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

        java.lang.String getCompilerDistribution()
        Get distribution name for binding compiler used.
        Returns:
        name of distribution for binding compiler
      • getBindingName

        java.lang.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 the getMarshallerClass(int) and getUnmarshallerClass(int) methods returning Class objects.
        Returns:
        hash
      • getNamespaces

        java.lang.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

        java.lang.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

        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.
        Returns:
        array of class names
      • getElementNamespaces

        java.lang.String[] getElementNamespaces()
        Get namespaces of elements corresponding to mapped classes. The returned array uses the same ordering as the result of the getMappedClasses() call. Entries in the array are null if there is no element for a class or the element is in the default namespace.
        Returns:
        array of element namespaces
      • getElementNames

        java.lang.String[] getElementNames()
        Get names of elements corresponding to mapped classes. The returned array uses the same ordering as the result of the getMappedClasses() call. Entries in the array are null if there is no element for a class.
        Returns:
        array of element names
      • getMarshallerClasses

        java.lang.String[] getMarshallerClasses()
        Get marshaller class names. The returned array uses the same ordering as the result of the getMappedClasses() call. Entries in the array are null if there is no marshaller class for the mapping.
        Returns:
        array of class names
      • getUnmarshallerClasses

        java.lang.String[] getUnmarshallerClasses()
        Get unmarshaller class names. The returned array uses the same ordering as the result of the getMappedClasses() call. Entries in the array are null if there is no unmarshaller class for the mapping.
        Returns:
        array of class names
      • getTypeIndex

        int getTypeIndex​(java.lang.String type)
        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

        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. If verifyBaseBindings() 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

        java.lang.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)
        The method specifications are in the form of fully qualified class names and method signatures. The methods are only intended for use by the binding compiler when working with a precompiled binding.
        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 by getAbstractMappings().
        Returns:
        namespace indexes, empty array if none
      • getUnmarshalMap

        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 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.
        Returns:
        map from local name to class index array
      • getUnmarshallerClass

        java.lang.Class getUnmarshallerClass​(int index)
        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

        java.lang.Class getMarshallerClass​(int index)
        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

        java.lang.String[] getBaseBindings()
        Get the names of the separately-compiled base bindings used by this binding.
        Returns:
        binding names
      • verifyBaseBindings

        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.
        Throws:
        JiBXException - on verification failure
      • getBaseBindingFactories

        java.lang.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

        java.util.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.
        Returns:
        map to namespace index translation
      • loadClass

        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 core runtime classes.
        Parameters:
        name - fully qualified class name
        Returns:
        loaded class, or null if class not found