Class BindingBuilder

java.lang.Object
org.jibx.binding.def.BindingBuilder

public abstract class BindingBuilder extends Object
Binding definition builder. This processes the binding definition file to generate the code generation structure.
Author:
Dennis M. Sosnoski
  • Field Details

  • Constructor Details

    • BindingBuilder

      public BindingBuilder()
  • Method Details

    • isNamePresent

      private static boolean isNamePresent(UnmarshallingContext ctx)
      Check if attributes supply a name definition.
      Parameters:
      ctx - unmarshalling context information
      Returns:
      true if attributes define a name, false if not
    • isPropertyPresent

      private static boolean isPropertyPresent(UnmarshallingContext ctx)
      Check for property definition present. Just checks the attributes of the current element.
      Parameters:
      ctx - unmarshalling context information
    • isDirectObject

      private static boolean isDirectObject(UnmarshallingContext ctx)
      Check if attributes define a direct object reference. Just checks the attributes of the current element.
      Parameters:
      ctx - unmarshalling context information
    • isMappingRef

      private static boolean isMappingRef(UnmarshallingContext ctx) throws JiBXException
      Check if attributes define a mapping reference.
      Parameters:
      ctx - unmarshalling context information
      Returns:
      true if attributes define a mapping reference, false if not
      Throws:
      JiBXException - if error in unmarshalling
    • isObjectBinding

      private static boolean isObjectBinding(UnmarshallingContext ctx) throws JiBXException
      Check for component object present. Just checks the attributes of the current element, so this is not definitive - there may still be child binding definitions even without attributes.
      Parameters:
      ctx - unmarshalling context information
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalName

      private static NameDefinition unmarshalName(UnmarshallingContext ctx, boolean attr) throws JiBXException
      Unmarshal name definition. This unmarshals directly from attributes of the current element.
      Parameters:
      ctx - unmarshalling context information
      attr - flag for attribute name definition
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalNamespace

      private static NamespaceDefinition unmarshalNamespace(UnmarshallingContext ctx) throws JiBXException
      Unmarshal namespace definition.
      Parameters:
      ctx - unmarshalling context information
      Throws:
      JiBXException - if error in unmarshalling
    • buildEnumValueMethods

      private static void buildEnumValueMethods(boolean exists, String type, String evmeth) throws JiBXException
      Add (or verify) serializer and deserializer methods to enum class with special value method. This allows enums to be used even when the values present in XML are not valid Java names.
      Parameters:
      exists - only verify existing methods flag
      type -
      evmeth -
      Throws:
      JiBXException
    • buildEnumSerializeMethod

      private static void buildEnumSerializeMethod(String evfull, ExceptionMethodBuilder smeth)
      Fill in the body of an enum serialization method.
      Parameters:
      evfull -
      smeth -
    • buildEnumDeserializeMethod

      private static void buildEnumDeserializeMethod(String type, String typesig, String evfull, ExceptionMethodBuilder dmeth)
      Fill in the body of an enum deserialization method.
      Parameters:
      type -
      typesig -
      evfull -
      dmeth -
    • unmarshalStringConversion

      private static StringConversion unmarshalStringConversion(UnmarshallingContext ctx, boolean exists, StringConversion base, String type) throws JiBXException
      Unmarshal string conversion. Unmarshals conversion information directly from the attributes of the current start tag.
      Parameters:
      ctx - unmarshalling context information
      exists - only verify existing methods flag
      base - conversion used as base for this conversion
      type - fully qualified class name of type handled by conversion
      Throws:
      JiBXException - if error in unmarshalling
    • isOptionalProperty

      private static boolean isOptionalProperty(UnmarshallingContext ctx) throws JiBXException
      Check for optional property. Just checks for the attribute and makes sure it has a valid value if present, returning either the default or the defined value.
      Parameters:
      ctx - unmarshalling context information
      Returns:
      true if attribute present with value "true", false otherwise
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalProperty

      private static PropertyDefinition unmarshalProperty(UnmarshallingContext ctx, IContainer parent, IContextObj cobj, boolean opt) throws JiBXException
      Unmarshal property definition. This unmarshals directly from attributes of the current element.
      Parameters:
      ctx - unmarshalling context information
      parent - containing binding definition structure
      cobj - context object information
      opt - force optional value flag
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalValue

      private static ValueChild unmarshalValue(UnmarshallingContext ctx, IContainer parent, IContextObj cobj, boolean uord, boolean impl, String itype) throws JiBXException
      Unmarshal value definition. This handles the complete element supplying the value binding.
      Parameters:
      ctx - unmarshalling context information
      parent - containing binding definition structure
      cobj - context object information
      uord - unordered collection member flag
      impl - implicit value from collection flag
      itype - base type for value
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalDirectObj

      private static DirectObject unmarshalDirectObj(UnmarshallingContext ctx, String type, IContainer parent, DefinitionContext defc, String mapname, NameDefinition name) throws JiBXException
      Unmarshal direct object component. Just constructs the component to be returned along with the supporting objects, and verifies that no disallowed properties are present.
      Parameters:
      ctx - unmarshalling context information
      type - fully qualified class name of object type handled
      parent - containing binding definition structure
      defc - definition context to be used (if separate from parent, otherwise null)
      mapname - marshaller/unmarshaller name
      name - element name information (null if no element name)
      Returns:
      constructed direct object component
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalMappingRef

      private static IComponent unmarshalMappingRef(UnmarshallingContext ctx, IContainer parent, IContextObj objc, PropertyDefinition prop, NameDefinition name) throws JiBXException
      Unmarshal mapping reference component. Just constructs the component to be returned along with the supporting objects, and verifies that no disallowed properties are present.
      Parameters:
      ctx - unmarshalling context information
      parent - containing binding definition structure
      objc - current object context
      prop - property definition
      name - reference name definition (only allowed with abstract mappings)
      Returns:
      constructed mapping reference component
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalStructureRef

      private static IComponent unmarshalStructureRef(UnmarshallingContext ctx, IContainer contain, NameDefinition name, PropertyDefinition prop, IContextObj cobj) throws JiBXException
      Unmarshal structure reference component. Just constructs the component to be returned along with the supporting objects, and verifies that no disallowed properties are present.
      Parameters:
      ctx - unmarshalling context information
      contain - containing binding component
      name - element name information (null if no element name)
      prop - property definition (null if no separate property)
      cobj - context object
      Returns:
      constructed structure reference component
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalStructureChildren

      private static void unmarshalStructureChildren(UnmarshallingContext ctx, NestedBase nest, IContextObj objc, boolean impl, String itype) throws JiBXException
      Unmarshal child bindings for a nested structure definition.
      Parameters:
      ctx - unmarshalling context information
      nest - nested structure definition
      objc - context object definition
      impl - property value implicit flag
      itype - item type for child components
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalObjectBinding

      private static ObjectBinding unmarshalObjectBinding(UnmarshallingContext ctx, IContextObj objc, IContainer parent, String type) throws JiBXException
      Unmarshal object binding component. Just constructs the component to be returned along with the supporting objects. This handles both the unmarshalling of attributes, and of nested binding components.
      Parameters:
      ctx - unmarshalling context information
      objc - current object context
      parent - containing binding definition structure
      type - fully qualified name of object class
      Returns:
      constructed structure reference component
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalNamespaces

      private static void unmarshalNamespaces(UnmarshallingContext ctx, DefinitionContext defc) throws JiBXException
      Unmarshal namespace definitions. Any namespace definitions present are unmarshalled and added to the supplied definition context.
      Parameters:
      ctx - unmarshalling context information
      defc - definition context for defined namespaces
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalFormats

      private static void unmarshalFormats(UnmarshallingContext ctx, boolean exists, DefinitionContext defc) throws JiBXException
      Unmarshal format definitions. Any format definitions present are unmarshalled and added to the supplied definition context.
      Parameters:
      ctx - unmarshalling context information
      exists - only verify existing methods flag
      defc - definition context for defined formats
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalMappings

      private static void unmarshalMappings(UnmarshallingContext ctx, IContainer parent, ArrayList nss, boolean uord) throws JiBXException
      Unmarshal mapping definitions. Any mapping definitions present are unmarshalled and added to the supplied definition context.
      Parameters:
      ctx - unmarshalling context information
      parent - containing binding definition structure
      nss - extra namespaces to be included in this mapping definition (may be null)
      uord - container is unordered structure flag
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalStructure

      public static IComponent unmarshalStructure(UnmarshallingContext ctx, IContainer contain, IContextObj cobj, boolean coll, boolean uord, boolean implic) throws JiBXException
      Unmarshal subclass instance for structure definition. This handles all combinations of attributes on the start tag, generating the appropriate structure of nested components and other classes to represent the binding information within the current element. This must be called with the parse positioned at the start tag of the element to be unmarshalled. TODO: At least split this up, or organize a better way to build binding
      Parameters:
      ctx - unmarshalling context information
      contain - containing binding definition structure
      cobj - context object information
      coll - collection structure flag
      uord - container is unordered structure flag
      implic - property value implicit flag
      Returns:
      root of component tree constructed from binding
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalMapping

      public static IMapping unmarshalMapping(UnmarshallingContext ctx, IContainer parent, ArrayList nss, boolean uord) throws JiBXException
      Unmarshal mapping definition. This handles all combinations of attributes on the start tag, generating the appropriate structure of nested components and other classes to represent the binding information within the current element. This must be called with the parse positioned at the start tag of the element to be unmarshalled.
      Parameters:
      ctx - unmarshalling context information
      parent - containing binding definition structure
      nss - extra namespaces to be included in this mapping definition (may be null)
      uord - container is unordered structure flag
      Returns:
      mapping definition constructed from binding
      Throws:
      JiBXException - if error in unmarshalling
    • preserveMethodClass

      private static void preserveMethodClass(String name)
      Force the class containing a method to be preserved from modification.
      Parameters:
      name -
    • unmarshalPrecompiledMappings

      private static void unmarshalPrecompiledMappings(UnmarshallingContext ctx, IBindingFactory factory, IContainer parent, int[] nsxlate) throws JiBXException
      Unmarshal precompiled mapping definitions. Any mapping definitions present are unmarshalled and added to the supplied definition context.
      Parameters:
      ctx - unmarshalling context information
      factory - binding factory for mapping information
      parent - containing binding definition structure
      nsxlate - namespace index translation table (null if none)
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalInclude

      public static void unmarshalInclude(UnmarshallingContext ctx, boolean precomp, BindingDefinition bdef, URL root, ArrayList nslist, HashSet paths, IBindingFactory factory, int[] nsxlate) throws JiBXException
      Unmarshal included binding. This handles the actual include element along with the actual included binding. The current implementation allows for nested includes, but requires that all the included bindings use compatible settings for the attributes of the root element, and only allows mapping elements as children of the included bindings (no namespace or format elements).
      Parameters:
      ctx - unmarshalling context information
      precomp - in precompiled bindings flag
      bdef - binding definition at root of includes
      root - base URL for binding, or null if unknown
      nslist - list of namespaces defined
      paths - set of binding paths processed
      factory - precompiled binding factory (null if not in precompiled binding)
      nsxlate - namespace translation table for precompiled binding (null if not in precompiled binding)
      Throws:
      JiBXException - if error in unmarshalling
    • unmarshalBindingDefinition

      public static BindingDefinition unmarshalBindingDefinition(UnmarshallingContext ctx, String name, URL root) throws JiBXException
      Unmarshal binding definition. This handles the entire binding definition document.
      Parameters:
      ctx - unmarshalling context information
      name - default name for binding
      root - base URL for binding, or null if unknown
      Returns:
      binding definition
      Throws:
      JiBXException - if error in unmarshalling