Class BindingDefinition

    • Field Detail

      • OBJECT_DEFAULT_NAME

        static final QName OBJECT_DEFAULT_NAME
        Name of object default conversion.
      • BASE_USER_NAMESPACE

        public static final int BASE_USER_NAMESPACE
        First namespace index available for user definitions.
        See Also:
        Constant Field Values
      • CURRENT_VERSION_NAME

        public 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
      • DEFAULT_AUTOPREFIX

        static final java.lang.String DEFAULT_AUTOPREFIX
        Default prefix for automatic ID generation.
        See Also:
        Constant Field Values
      • TYPEMAP_MINIMUM_SIZE

        private static final int TYPEMAP_MINIMUM_SIZE
        Minimum size to use map for index from type name.
        See Also:
        Constant Field Values
      • s_bindings

        private static java.util.ArrayList s_bindings
        Table of defined bindings.
      • s_mappedClasses

        private static ArrayMap s_mappedClasses
        Classes included in any binding.
      • s_booleanConversion

        private static final StringConversion s_booleanConversion
      • s_sqlDateConversion

        private static final StringConversion s_sqlDateConversion
      • s_sqlTimeConversion

        private static final StringConversion s_sqlTimeConversion
      • s_timestampConversion

        private static final StringConversion s_timestampConversion
      • s_jodaLocalDateConversion

        private static final StringConversion s_jodaLocalDateConversion
      • s_jodaZonedDateMidnightConversion

        private static final StringConversion s_jodaZonedDateMidnightConversion
      • s_jodaLocalUnzonedDateMidnightConversion

        private static final StringConversion s_jodaLocalUnzonedDateMidnightConversion
      • s_jodaUTCDateMidnightConversion

        private static final StringConversion s_jodaUTCDateMidnightConversion
      • s_jodaUnzonedLocalTimeConversion

        private static final StringConversion s_jodaUnzonedLocalTimeConversion
      • s_jodaUnzonedUTCLocalTimeConversion

        private static final StringConversion s_jodaUnzonedUTCLocalTimeConversion
      • s_jodaZonedDateTimeConversion

        private static final StringConversion s_jodaZonedDateTimeConversion
      • s_jodaUTCDateTimeConversion

        private static final StringConversion s_jodaUTCDateTimeConversion
      • s_jodaLocalDateTimeConversion

        private static final StringConversion s_jodaLocalDateTimeConversion
      • s_jodaStrictLocalDateTimeConversion

        private static final StringConversion s_jodaStrictLocalDateTimeConversion
      • s_jodaStrictUTCDateTimeConversion

        private static final StringConversion s_jodaStrictUTCDateTimeConversion
      • s_java5DecimalConversion

        private static final StringConversion s_java5DecimalConversion
      • s_wrappedBooleanConversion

        private static final StringConversion s_wrappedBooleanConversion
      • FACTORY_INTERFACE

        private static final java.lang.String FACTORY_INTERFACE
        See Also:
        Constant Field Values
      • FACTORY_INTERFACES

        private static final java.lang.String[] FACTORY_INTERFACES
      • FACTORY_INSTNAME

        private static final java.lang.String FACTORY_INSTNAME
        See Also:
        Constant Field Values
      • PRIVATESTATIC_ACCESS

        private static final int PRIVATESTATIC_ACCESS
      • PRIVATESTATICFINAL_ACCESS

        private static final int PRIVATESTATICFINAL_ACCESS
      • GETINST_METHODNAME

        private static final java.lang.String GETINST_METHODNAME
        See Also:
        Constant Field Values
      • GETVERSION_METHODNAME

        private static final java.lang.String GETVERSION_METHODNAME
        See Also:
        Constant Field Values
      • GETDISTRIB_METHODNAME

        private static final java.lang.String GETDISTRIB_METHODNAME
        See Also:
        Constant Field Values
      • GETTYPEINDEX_METHODNAME

        private static final java.lang.String GETTYPEINDEX_METHODNAME
        See Also:
        Constant Field Values
      • STRINGINT_MAPTYPE

        private static final java.lang.String STRINGINT_MAPTYPE
        See Also:
        Constant Field Values
      • STRINGINTINIT_SIGNATURE

        private static final java.lang.String STRINGINTINIT_SIGNATURE
        See Also:
        Constant Field Values
      • STRINGINTADD_METHOD

        private static final java.lang.String STRINGINTADD_METHOD
        See Also:
        Constant Field Values
      • STRINGINTADD_SIGNATURE

        private static final java.lang.String STRINGINTADD_SIGNATURE
        See Also:
        Constant Field Values
      • STRINGINTGET_METHOD

        private static final java.lang.String STRINGINTGET_METHOD
        See Also:
        Constant Field Values
      • STRINGINTGET_SIGNATURE

        private static final java.lang.String STRINGINTGET_SIGNATURE
        See Also:
        Constant Field Values
      • CLASSLIST_METHOD_NAME

        private static final java.lang.String CLASSLIST_METHOD_NAME
        See Also:
        Constant Field Values
      • CLASSLIST_METHOD_SIGNATURE

        private static final java.lang.String CLASSLIST_METHOD_SIGNATURE
        See Also:
        Constant Field Values
      • m_name

        private final java.lang.String m_name
        Binding name.
      • m_index

        private final int m_index
        Index number of this binding.
      • m_isInput

        private final boolean m_isInput
        Input binding flag.
      • m_isOutput

        private final boolean m_isOutput
        Output binding flag.
      • m_isIdGlobal

        private final boolean m_isIdGlobal
        Use global ID values flag.
      • m_isForwards

        private final boolean m_isForwards
        Support forward references to IDs flag.
      • m_isTrackSource

        private final boolean m_isTrackSource
        Generate souce tracking interface flag.
      • m_isForceClasses

        private final boolean m_isForceClasses
        Generate marshaller/unmarshaller classes for top-level non-base abstract mappings flag.
      • m_majorVersion

        private final int m_majorVersion
        Major version of binding.
      • m_minorVersion

        private final int m_minorVersion
        Minor version of binding.
      • m_isAddConstructors

        private boolean m_isAddConstructors
        Add default constructors where needed flag.
      • m_targetPackage

        private java.lang.String m_targetPackage
        Package for generated context factory.
      • m_targetRoot

        private java.io.File m_targetRoot
        File root for generated context factory.
      • m_factoryName

        private java.lang.String m_factoryName
        Fully-qualified name of binding factory.
      • m_uniqueIds

        private ArrayMap m_uniqueIds
        Classes using unique (per class) identifiers. This is null and unused when using global ID values.
      • m_namespaceUris

        private ArrayMap m_namespaceUris
        Namespaces URIs included in binding.
      • m_namespacePrefixes

        private GrowableStringArray m_namespacePrefixes
        Original prefixes for namespaces.
      • m_highBasePrefix

        private int m_highBasePrefix
        High mark in prefixes from from precompiled base bindings.
      • m_outerContext

        private DefinitionContext m_outerContext
        Outer definition context with default definitions.
      • m_activeContext

        private DefinitionContext m_activeContext
        Inner definition context constructed for binding.
      • m_isMappedDone

        private boolean m_isMappedDone
        Flag for done assigning indexes to mapped classes.
      • m_isSchemaInstanceUsed

        private boolean m_isSchemaInstanceUsed
        Flag for schema instance namespace used in binding.
      • m_mumIndex

        private int m_mumIndex
        Next index number for marshaller/unmarshaller slots used in-line.
      • m_extraClasses

        private ArrayMap m_extraClasses
        Classes handled by in-line marshaller/unmarshaller references.
      • m_extraMarshallers

        private GrowableStringArray m_extraMarshallers
        Marshaller classes used in-line.
      • m_extraUnmarshallers

        private GrowableStringArray m_extraUnmarshallers
        Unmarshaller classes used in-line.
      • m_baseBindings

        private GrowableStringArray m_baseBindings
        Precompiled base binding names used by this binding.
      • m_baseBindingFactories

        private GrowableStringArray m_baseBindingFactories
        Factory class names for precompiled base bindings (same order as binding names).
      • m_baseHashes

        private java.util.ArrayList m_baseHashes
        Hashes for base binding factories (same order as binding names).
      • m_baseNamespaceTables

        private java.util.ArrayList m_baseNamespaceTables
        Namespace index mapping tables for base bindings (same order as binding names).
      • m_closureFactories

        private GrowableStringArray m_closureFactories
        Factory classes for base bindings of base bindings.
      • m_closureNamespaceTables

        private java.util.ArrayList m_closureNamespaceTables
        Namespace index mapping tables for base bindings of base bindings (same order as factories).
      • m_factoryClass

        private ClassFile m_factoryClass
        Generated binding factory class.
      • s_blanks

        private static byte[] s_blanks
    • Constructor Detail

      • BindingDefinition

        public BindingDefinition​(java.lang.String name,
                                 boolean ibind,
                                 boolean obind,
                                 java.lang.String tpack,
                                 boolean glob,
                                 boolean forward,
                                 boolean source,
                                 boolean force,
                                 boolean add,
                                 boolean trim,
                                 int major,
                                 int minor)
                          throws JiBXException
        Constructor. Sets all defaults, including the default name provided, and initializes the definition context for the outermost level of the binding.
        Parameters:
        name - binding name
        ibind - input binding flag
        obind - output binding flag
        tpack - target package
        glob - global IDs flag
        forward - support forward referenced IDs flag
        source - add source tracking for unmarshalled objects flag
        force - create marshaller/unmarshaller classes for top-level non-base mappings
        add - add default constructors where necessary flag
        trim - trim whitespace from simple values before conversion flag
        major - major version number
        minor - minor version number
        Throws:
        JiBXException - if error in transformation
    • Method Detail

      • getBoundClass

        public BoundClass getBoundClass()
        Get class linked to binding element. Implementation of IContainer interface, just returns null in this case.
        Returns:
        information for class linked by binding
      • setIdChild

        public boolean setIdChild​(IComponent child)
        Set ID property. This parent binding component interface method should never be called for the binding definition, and will throw a runtime exception if it is called.
        Parameters:
        child - child defining the ID property
        Returns:
        false
      • getDefaultPackage

        public java.lang.String getDefaultPackage()
        Get default package used for code generation.
        Returns:
        default code generation package
      • getDefaultRoot

        public java.io.File getDefaultRoot()
        Get root directory for default code generation package.
        Returns:
        root for default code generation
      • setFactoryLocation

        public void setFactoryLocation​(java.lang.String tpack,
                                       java.io.File root)
        Set location for binding factory class generation.
        Parameters:
        tpack - target package for generated context factory
        root - target root for generated context factory
      • getIndex

        public int getIndex()
        Get index number of binding.
        Returns:
        index number for this binding definition
      • isInput

        public boolean isInput()
        Check if binding is defined for unmarshalling.
        Returns:
        true if defined, false if not
      • isOutput

        public boolean isOutput()
        Check if binding is defined for marshalling.
        Returns:
        true if defined, false if not
      • isIdGlobal

        public boolean isIdGlobal()
        Check if global ids are used by binding.
        Returns:
        true if defined, false if not
      • isForwards

        public boolean isForwards()
        Check if forward ids are supported by unmarshalling binding.
        Returns:
        true if supported, false if not
      • isTrackSource

        public boolean isTrackSource()
        Check if source tracking is supported by unmarshalling binding.
        Returns:
        true if defined, false if not
      • isAddConstructors

        public boolean isAddConstructors()
        Check if default constructor generation is enabled.
        Returns:
        true if default constructor generation enabled, false if not
      • getPrefix

        public java.lang.String getPrefix()
        Get prefix for method or class generation.
        Returns:
        prefix for names created by this binding
      • addMappingName

        public void addMappingName​(java.lang.String name)
        Add mapping name to binding. If the name is not already included in any binding it is first added to the list of mapping names. This method is intended for use with <mapping> definitions. It is an error to call this method after calling the getMarshallerUnmarshallerName(java.lang.String) method.
        Parameters:
        name - mapping name (type name if given, otherwise the fully qualified mapped class name)
      • getMarshallerUnmarshallerName

        public java.lang.String getMarshallerUnmarshallerName​(java.lang.String clas)
        Get marshaller/unmarshaller name in binding. The same class may have more than one marshaller/unmarshaller pair defined, so this uses the supplied class name as a base and appends a numeric suffix as necessary to generate a unique name. After the name has been assigned by this method, the setMarshallerUnmarshallerClasses(java.lang.String, java.lang.String, java.lang.String) method must be used to set the actual class names.
        Parameters:
        clas - fully qualified name of class handled by marshaller/unmarshaller
        Returns:
        unique name for marshaller/unmarshaller pair
      • setMarshallerUnmarshallerClasses

        public void setMarshallerUnmarshallerClasses​(java.lang.String name,
                                                     java.lang.String mclas,
                                                     java.lang.String uclas)
        Set marshaller and unmarshaller class names.
        Parameters:
        name - assigned marshaller/unmarshaller name
        mclas - fully qualified name of marshaller class
        uclas - fully qualified name of unmarshaller class
      • getIdClassIndex

        public int getIdClassIndex​(java.lang.String name)
        Get index for ID'ed class from binding. If the class is not already included it is first added to the binding. If globally unique IDs are used this always returns 0.
        Parameters:
        name - fully qualified name of ID'ed class
        Returns:
        index number of class
      • getNamespaceUriIndex

        public int getNamespaceUriIndex​(java.lang.String uri,
                                        java.lang.String prefix)
        Get index for namespace URI in binding. If the URI is not already included it is first added to the binding. The empty namespace URI is always given index number 0.
        Parameters:
        uri - namespace URI to be included in binding
        prefix - prefix used with namespace
        Returns:
        index number of namespace
      • setSchemaInstanceUsed

        public void setSchemaInstanceUsed()
        Set flag for schema instance namespace used in binding.
      • addPrecompiledBinding

        public int[] addPrecompiledBinding​(IBindingFactory factory,
                                           int major,
                                           int minor)
        Add a precompiled binding reference to this binding. This records the reference and makes sure that all the namespaces used in the precompiled binding are defined in this binding, also generating a namespace index mapping table if this binding supports output and the indexes differ.
        Parameters:
        factory - actual binding factory for precompiled binding
        major - required major version number
        minor - required minor version number
        Returns:
        namespace index translation table (null if none)
      • fixPrefixes

        private void fixPrefixes()
        Fix the prefixes for namespaces imported from precompiled base bindings. If there are no namespaces from precompiled base bindings, or these namespaces use prefixes which are unique from each other and from those used in this binding, nothing is done. If there are conflicts or namespaces used without prefixes this sets unique prefixes for each namespace.
      • getPrefix

        public java.lang.String getPrefix​(java.lang.String uri)
        Get the prefix assigned for a namespace. This is intended mainly for use with precompiled bindings, where the fixPrefixes() method may change the initial prefixes (if any) in order to avoid conflicts.
        Parameters:
        uri - namespace URI
        Returns:
        prefix for namespace
      • buildClassNamesBlob

        private static java.lang.String buildClassNamesBlob​(java.lang.String[] names)
        Build a class or method name blob from an array of fully-qualified class and/or method names. The returned string consists of compacted fully-qualified names separated by '|' delimiter characters. If some number of package (and potentially class) name levels are the same as the last name, these components are replaced with simple '.' characters (and '$' characters, in the case of class name components) in the compacted name. null values are represented as empty names.
        Parameters:
        names - fully-qualified class and/or method names list
        Returns:
        compacted name blob
      • buildClassNamesBlob

        private static java.lang.String buildClassNamesBlob​(java.util.List names)
        Build a class or method name blob from a list of fully-qualified class and/or method names. This just converts the list to an array and delegates to buildClassNamesBlob(String[]).
        Parameters:
        names - fully-qualified class and/or method names list
        Returns:
        compacted name blob
      • buildNamespaceIndexBlob

        private static java.lang.String buildNamespaceIndexBlob​(java.lang.String[] uris,
                                                                java.lang.String[] nss)
        Build a namespace index blob from an array of namespace URIs. The returned string consists of one character per namespace, giving the index of the namespace URI within the array of definitions, biased by +2 to avoid use of null characters (with +1 used for null values).
        Parameters:
        uris - table of namespaces defined in binding
        nss - namespaces for index blob
        Returns:
        index blob
      • buildNamesBlob

        private static java.lang.String buildNamesBlob​(java.lang.String[] names)
        Build a name blob from an array of names. The returned string consists of names separated by '|' delimiter characters. null values are represented as empty names.
        Parameters:
        names - names for blob
        Returns:
        name blob
      • buildIntsBlob

        private static java.lang.String buildIntsBlob​(int[] ints)
        Convert an array of int values into a string blob.
        Parameters:
        ints -
        Returns:
        string with int values as characters
      • buildIntsBlob

        private static java.lang.String buildIntsBlob​(java.util.List values)
        Convert a list of Integer values into a string blob. This is just a convenience wrapper for buildIntsBlob(int[]).
        Parameters:
        values -
        Returns:
        string with int values as characters
      • codegenString

        private static void codegenString​(java.lang.String string,
                                          MethodBuilder mb)
        Generate code to load a string value, which may be longer than the maximum string length. This either loads the string directly (if within the limit) or recreates it by concatenating two or more shorter strings.
        Parameters:
        string -
        mb -
      • getFactoryName

        public java.lang.String getFactoryName()
        Get the fully-qualified name of the binding factory class for this binding.
        Returns:
        class name
      • generateCode

        public void generateCode​(boolean verbose1,
                                 boolean verbose2)
                          throws JiBXException
        Generate code. First sets linkages and executes code generation for each top-level mapping defined in this binding, which in turn propagates the code generation all the way down. Then generates the actual binding factory for this binding.
        Parameters:
        verbose1 - flag for verbose output from first pass
        verbose2 - flag for verbose output from second pass
        Throws:
        JiBXException - if error in code generation
      • generateCode

        public void generateCode​(boolean verbose)
                          throws JiBXException
        Generate code. This version preserves compatibility with the older form of the call, always passing false for the second-pass verbose flag. See generateCode(boolean, boolean) for details of processing.
        Parameters:
        verbose - flag for verbose output from first pass
        Throws:
        JiBXException - if error in code generation
      • addClassList

        public void addClassList​(ClassFile[] adds,
                                 ClassFile[] keeps)
        Add the list of classes used by the binding compiler to the binding factory. This needs to be done as a separate step after the normal binding process has completed in order to make sure that the full set of classes is available. Ugly, but necessary because the class handling doesn't finalize newly-generated class names until they're actually written (too much sophistication, in retrospect).
        Parameters:
        adds - classes added by binding
        keeps - classes used but kept unchanged by binding
      • methodNameOrNull

        private static java.lang.String methodNameOrNull​(ClassItem item)
        Convenience method to get an name, if the item is defined.
        Parameters:
        item - information, or null if none
        Returns:
        item name, or null if no item
      • getBinding

        public static BindingDefinition getBinding​(int index)
        Get indexed binding.
        Parameters:
        index - number of binding to be returned
        Returns:
        binding at the specified index
      • reset

        public static void reset()
        Discard cached information and reset in preparation for a new binding run.
      • isContentOrdered

        public boolean isContentOrdered()
        Description copied from interface: IContainer
        Check if content children are ordered.
        Specified by:
        isContentOrdered in interface IContainer
        Returns:
        true if ordered, false if not
      • hasNamespaces

        public boolean hasNamespaces()
      • indent

        public static void indent​(int depth)
      • print

        public void print()