org.jibx.binding.def
Class MappingDefinition

java.lang.Object
  extended by org.jibx.binding.def.PassThroughComponent
      extended by org.jibx.binding.def.LinkableBase
          extended by org.jibx.binding.def.MappingBase
              extended by org.jibx.binding.def.MappingDefinition
All Implemented Interfaces:
IComponent, IMapping

public class MappingDefinition
extends MappingBase

Normal mapping with defined binding. This is used for a mapping definition which includes detailed binding information (rather than marshaller and unmarshaller classes which handle the binding directly).

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
private static java.lang.String ADAPTERCLASS_SUFFIX
           
private static java.lang.String ADDMARSHALLER_METHOD
           
private static java.lang.String ADDMARSHALLER_SIGNATURE
           
private static java.lang.String ADDUNMARSHALLER_METHOD
           
private static java.lang.String ADDUNMARSHALLER_SIGNATURE
           
private static java.lang.String BASEMARSHAL_METHODNAME
           
(package private) static java.lang.String[] BOTH_INTERFACES
           
private static java.lang.String CHECKEXTENDS_METHOD
           
private static java.lang.String CURRENTELEMENT_METHOD
           
private static java.lang.String CURRENTELEMENT_SIGNATURE
           
private static java.lang.String GETINDEX_METHOD
           
private static org.apache.bcel.generic.Type[] ISPRESENT_METHOD_ARGS
           
private static java.lang.String ISPRESENT_METHODNAME
           
private  IMapping m_baseMapping
          Abstract binding this one is based on (null if not an extension.
private  java.lang.String m_baseType
          Name of abstract base type.
private  BoundClass m_class
          Class linked to mapping.
private  IContainer m_container
          Containing binding definition structure.
private  DefinitionContext m_defContext
          Definition context for mapping.
private  java.util.ArrayList m_extensions
          Mapping which extend this one (null if none).
private  boolean m_isAbstract
          Abstract mapping flag.
private  ClassFile m_marshaller
          Constructed marshaller class.
private  NameDefinition m_name
          Mapped element name (may be null if element(s) defined by marshaller and unmarshaller, or if abstract mapping).
private  java.lang.String m_referenceType
          Reference type of mapping, as fully qualifed class name.
private  IComponent m_thisBinding
          Duplicate of component structure for use as "this" reference (null if not yet defined).
private  java.lang.String m_typeName
          Abstract mapping type name.
private  ClassFile m_unmarshaller
          Constructed unmarshaller class.
private static org.apache.bcel.generic.Type[] MARSHAL_METHOD_ARGS
           
private static java.lang.String MARSHAL_METHODNAME
           
private static java.lang.String MARSHALCONTEXT_CLASS
           
private static java.lang.String MARSHALCONTEXT_INTERFACE
           
(package private) static java.lang.String[] MARSHALLER_INTERFACES
           
private static java.lang.String REMOVEMARSHALLER_METHOD
           
private static java.lang.String REMOVEMARSHALLER_SIGNATURE
           
private static java.lang.String REMOVEUNMARSHALLER_METHOD
           
private static java.lang.String REMOVEUNMARSHALLER_SIGNATURE
           
private static java.lang.String UNMARSHAL_ISATMETHOD
           
private static java.lang.String UNMARSHAL_ISATSIGNATURE
           
private static org.apache.bcel.generic.Type[] UNMARSHAL_METHOD_ARGS
           
private static java.lang.String UNMARSHAL_METHODNAME
           
private static java.lang.String UNMARSHALCONTEXT_CLASS
           
private static java.lang.String UNMARSHALCONTEXT_INTERFACE
           
(package private) static java.lang.String[] UNMARSHALLER_INTERFACES
           
private static java.lang.String UNMARSHALLERPRESENT_METHOD
           
private static java.lang.String UNMARSHALLERPRESENT_SIGNATURE
           
 
Fields inherited from class org.jibx.binding.def.MappingBase
ABSTRACTMARSHALLER_INTERFACE, CHECKEXTENDS_METHODNAME, CHECKEXTENDS_SIGNATURE, GETINDEX_METHODNAME, GETINDEX_SIGNATURE, GETMARSHALLER_METHOD, GETMARSHALLER_SIGNATURE, GETUNMARSHALLER_METHOD, GETUNMARSHALLER_SIGNATURE, IMARSHALLABLE_INTERFACE, IUNMARSHALLABLE_INTERFACE, MARSHALLABLE_METHODNAME, MARSHALLABLE_SIGNATURE, MARSHALLER_INTERFACE, MARSHALLERMARSHAL_METHOD, MARSHALLERMARSHAL_SIGNATURE, UNMARSHALLABLE_METHODNAME, UNMARSHALLABLE_SIGNATURE, UNMARSHALLER_INTERFACE, UNMARSHALLERUNMARSHAL_METHOD, UNMARSHALLERUNMARSHAL_SIGNATURE
 
Fields inherited from class org.jibx.binding.def.PassThroughComponent
m_component
 
Constructor Summary
MappingDefinition(IContainer contain, DefinitionContext defc, java.lang.String type, NameDefinition name, java.lang.String tname, boolean abs, java.lang.String base, ObjectBinding bind)
          Constructor.
 
Method Summary
 void addExtension(MappingDefinition mdef)
          Add extension to abstract mapping.
 void addNamespace(NamespaceDefinition ns)
          Add namespace.
 IComponent buildRef(IContainer parent, IContextObj objc, java.lang.String type, PropertyDefinition prop)
          Build reference to mapping.
 void generateCode(boolean force)
          Generate required code for mapping.
(package private)  void genLoadNamespaces(MethodBuilder mb)
          Generate code for loading namespace index and URI arrays.
 BoundClass getBoundClass()
          Get the mapped class information.
 java.lang.String getBoundType()
          Get class name handled by mapping.
 IComponent getImplComponent()
          Get binding component implementing mapping.
 ClassFile getMarshaller()
          Get marshaller class used for mapping.
 NameDefinition getName()
          Get mapped element name.
 java.lang.String getReferenceType()
          Get class name of type to be assumed for references to this mapping.
 java.lang.String getTypeName()
          Get type name.
 ClassFile getUnmarshaller()
          Get unmarshaller class used for mapping.
(package private)  boolean hasNamespace()
          Check if one or more namespaces are defined for element.
 boolean isAbstract()
          Check if mapping is abstract.
 boolean isBase()
          Check if mapping has extensions.
 void linkMappings()
          Links extension mappings to their base mappings.
 void print(int depth)
           
 void setLinkages()
          Establish and validate linkages between binding components.
 
Methods inherited from class org.jibx.binding.def.MappingBase
addIMarshallableMethod, addIUnmarshallableMethod, getIndex
 
Methods inherited from class org.jibx.binding.def.LinkableBase
handleRecursion
 
Methods inherited from class org.jibx.binding.def.PassThroughComponent
checkContentSequence, genAttributeMarshal, genAttributeUnmarshal, genAttrPresentTest, genContentMarshal, genContentPresentTest, genContentUnmarshal, genLoadId, genNewInstance, getType, hasAttribute, hasContent, hasId, isOptional, setWrappedComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jibx.binding.def.IComponent
checkContentSequence, genAttributeMarshal, genAttributeUnmarshal, genAttrPresentTest, genContentMarshal, genContentPresentTest, genContentUnmarshal, genLoadId, genNewInstance, getType, hasAttribute, hasContent, hasId, isOptional
 

Field Detail

ADAPTERCLASS_SUFFIX

private static final java.lang.String ADAPTERCLASS_SUFFIX
See Also:
Constant Field Values

MARSHAL_METHODNAME

private static final java.lang.String MARSHAL_METHODNAME
See Also:
Constant Field Values

BASEMARSHAL_METHODNAME

private static final java.lang.String BASEMARSHAL_METHODNAME
See Also:
Constant Field Values

UNMARSHAL_METHODNAME

private static final java.lang.String UNMARSHAL_METHODNAME
See Also:
Constant Field Values

ISPRESENT_METHODNAME

private static final java.lang.String ISPRESENT_METHODNAME
See Also:
Constant Field Values

UNMARSHALCONTEXT_CLASS

private static final java.lang.String UNMARSHALCONTEXT_CLASS
See Also:
Constant Field Values

MARSHALCONTEXT_CLASS

private static final java.lang.String MARSHALCONTEXT_CLASS
See Also:
Constant Field Values

UNMARSHAL_ISATMETHOD

private static final java.lang.String UNMARSHAL_ISATMETHOD
See Also:
Constant Field Values

UNMARSHAL_ISATSIGNATURE

private static final java.lang.String UNMARSHAL_ISATSIGNATURE
See Also:
Constant Field Values

CHECKEXTENDS_METHOD

private static final java.lang.String CHECKEXTENDS_METHOD
See Also:
Constant Field Values

GETINDEX_METHOD

private static final java.lang.String GETINDEX_METHOD
See Also:
Constant Field Values

UNMARSHALLERPRESENT_METHOD

private static final java.lang.String UNMARSHALLERPRESENT_METHOD
See Also:
Constant Field Values

UNMARSHALLERPRESENT_SIGNATURE

private static final java.lang.String UNMARSHALLERPRESENT_SIGNATURE
See Also:
Constant Field Values

UNMARSHALCONTEXT_INTERFACE

private static final java.lang.String UNMARSHALCONTEXT_INTERFACE
See Also:
Constant Field Values

MARSHALCONTEXT_INTERFACE

private static final java.lang.String MARSHALCONTEXT_INTERFACE
See Also:
Constant Field Values

CURRENTELEMENT_METHOD

private static final java.lang.String CURRENTELEMENT_METHOD
See Also:
Constant Field Values

CURRENTELEMENT_SIGNATURE

private static final java.lang.String CURRENTELEMENT_SIGNATURE
See Also:
Constant Field Values

ADDUNMARSHALLER_METHOD

private static final java.lang.String ADDUNMARSHALLER_METHOD
See Also:
Constant Field Values

ADDUNMARSHALLER_SIGNATURE

private static final java.lang.String ADDUNMARSHALLER_SIGNATURE
See Also:
Constant Field Values

REMOVEUNMARSHALLER_METHOD

private static final java.lang.String REMOVEUNMARSHALLER_METHOD
See Also:
Constant Field Values

REMOVEUNMARSHALLER_SIGNATURE

private static final java.lang.String REMOVEUNMARSHALLER_SIGNATURE
See Also:
Constant Field Values

ADDMARSHALLER_METHOD

private static final java.lang.String ADDMARSHALLER_METHOD
See Also:
Constant Field Values

ADDMARSHALLER_SIGNATURE

private static final java.lang.String ADDMARSHALLER_SIGNATURE
See Also:
Constant Field Values

REMOVEMARSHALLER_METHOD

private static final java.lang.String REMOVEMARSHALLER_METHOD
See Also:
Constant Field Values

REMOVEMARSHALLER_SIGNATURE

private static final java.lang.String REMOVEMARSHALLER_SIGNATURE
See Also:
Constant Field Values

ISPRESENT_METHOD_ARGS

private static final org.apache.bcel.generic.Type[] ISPRESENT_METHOD_ARGS

UNMARSHAL_METHOD_ARGS

private static final org.apache.bcel.generic.Type[] UNMARSHAL_METHOD_ARGS

MARSHAL_METHOD_ARGS

private static final org.apache.bcel.generic.Type[] MARSHAL_METHOD_ARGS

UNMARSHALLER_INTERFACES

static final java.lang.String[] UNMARSHALLER_INTERFACES

MARSHALLER_INTERFACES

static final java.lang.String[] MARSHALLER_INTERFACES

BOTH_INTERFACES

static final java.lang.String[] BOTH_INTERFACES

m_container

private final IContainer m_container
Containing binding definition structure.


m_defContext

private final DefinitionContext m_defContext
Definition context for mapping.


m_class

private final BoundClass m_class
Class linked to mapping.


m_name

private final NameDefinition m_name
Mapped element name (may be null if element(s) defined by marshaller and unmarshaller, or if abstract mapping).


m_typeName

private final java.lang.String m_typeName
Abstract mapping type name.


m_isAbstract

private final boolean m_isAbstract
Abstract mapping flag.


m_baseType

private final java.lang.String m_baseType
Name of abstract base type.


m_baseMapping

private IMapping m_baseMapping
Abstract binding this one is based on (null if not an extension.


m_thisBinding

private IComponent m_thisBinding
Duplicate of component structure for use as "this" reference (null if not yet defined).


m_marshaller

private ClassFile m_marshaller
Constructed marshaller class.


m_unmarshaller

private ClassFile m_unmarshaller
Constructed unmarshaller class.


m_extensions

private java.util.ArrayList m_extensions
Mapping which extend this one (null if none).


m_referenceType

private java.lang.String m_referenceType
Reference type of mapping, as fully qualifed class name.

Constructor Detail

MappingDefinition

public MappingDefinition(IContainer contain,
                         DefinitionContext defc,
                         java.lang.String type,
                         NameDefinition name,
                         java.lang.String tname,
                         boolean abs,
                         java.lang.String base,
                         ObjectBinding bind)
                  throws JiBXException
Constructor. This initializes the new definition context.

Parameters:
contain - containing binding definition structure
defc - definition context for this mapping
type - bound class name
name - mapped element name information (null if defined by marshaller and unmarshaller)
tname - type name for abstract mapping (null if none)
abs - abstract mapping flag
base - abstract mapping extended by this one
bind - binding definition component
Throws:
JiBXException - if class definition not found
Method Detail

hasNamespace

boolean hasNamespace()
Check if one or more namespaces are defined for element.

Returns:
true if namespaces are defined, false if not

genLoadNamespaces

void genLoadNamespaces(MethodBuilder mb)
Generate code for loading namespace index and URI arrays. This default implementation assumes no namespaces are present and does nothing. It must be overridden by subclasses that support namespace declarations.

Parameters:
mb - method builder for generated code

getBoundClass

public BoundClass getBoundClass()
Get the mapped class information. This implements the method used by the base class.

Specified by:
getBoundClass in class MappingBase
Returns:
information for mapped class

linkMappings

public void linkMappings()
                  throws JiBXException
Links extension mappings to their base mappings. This must be done before the more general linking step in order to determine which abstract mappings are standalone and which are extended by other mappings

Throws:
JiBXException - if error in linking

getBoundType

public java.lang.String getBoundType()
Description copied from interface: IMapping
Get class name handled by mapping.

Returns:
name of class bound by mapping

getReferenceType

public java.lang.String getReferenceType()
Description copied from interface: IMapping
Get class name of type to be assumed for references to this mapping.

Returns:
reference type class name name

getImplComponent

public IComponent getImplComponent()
Description copied from interface: IMapping
Get binding component implementing mapping. This call is only valid for mappings with child components, not for mappings defined using marshallers or unmarshallers.

Returns:
binding component implementing this mapping

getMarshaller

public ClassFile getMarshaller()
Description copied from interface: IMapping
Get marshaller class used for mapping.

Returns:
marshaller class information

getUnmarshaller

public ClassFile getUnmarshaller()
Description copied from interface: IMapping
Get unmarshaller class used for mapping.

Returns:
unmarshaller class information

getName

public NameDefinition getName()
Description copied from interface: IMapping
Get mapped element name.

Returns:
mapped element name information (may be null if no element name defined for mapping)

getTypeName

public java.lang.String getTypeName()
Description copied from interface: IMapping
Get type name.

Returns:
type name (null if unnamed)

addNamespace

public void addNamespace(NamespaceDefinition ns)
                  throws JiBXException
Description copied from interface: IMapping
Add namespace. This adds a namespace definition to those active for the mapping.

Parameters:
ns - namespace definition to be added
Throws:
JiBXException - if error in defining namespace

isAbstract

public boolean isAbstract()
Description copied from interface: IMapping
Check if mapping is abstract.

Returns:
true if an abstract mapping, false if not

isBase

public boolean isBase()
Description copied from interface: IMapping
Check if mapping has extensions.

Returns:
true if one or more mappings extend this mapping, false if not

addExtension

public void addExtension(MappingDefinition mdef)
                  throws JiBXException
Description copied from interface: IMapping
Add extension to abstract mapping. This call is only valid for abstract mappings.

Parameters:
mdef - extension mapping definition
Throws:
JiBXException - if configuration error

buildRef

public IComponent buildRef(IContainer parent,
                           IContextObj objc,
                           java.lang.String type,
                           PropertyDefinition prop)
                    throws JiBXException
Description copied from interface: IMapping
Build reference to mapping. Constructs and returns the component for handling the mapping.

Parameters:
parent - containing binding definition structure
objc - current object context
type - mapped value type
prop - property definition (may be null)
Returns:
constructed mapping reference component
Throws:
JiBXException - if configuration error

generateCode

public void generateCode(boolean force)
                  throws JiBXException
Description copied from interface: IMapping
Generate required code for mapping.

Parameters:
force - add marshaller/unmarshaller classes for abstract non-base mappings flag (not passed on to children)
Throws:
JiBXException - if error in transformation

setLinkages

public void setLinkages()
                 throws JiBXException
Description copied from interface: IComponent
Establish and validate linkages between binding components. This is called after the basic binding structures have been set up. All linkages between components must be resolved by this method, in order to prevent problems due to the order of definitions between components. This implies that each component must in turn call the same method for each child component. None of the other method calls defined by this interface are valid until after this call.

Specified by:
setLinkages in interface IComponent
Overrides:
setLinkages in class LinkableBase
Throws:
JiBXException - if error in configuration

print

public void print(int depth)
Specified by:
print in interface IComponent
Overrides:
print in class LinkableBase


Project Web Site