org.jibx.binding.def
Class NestedBase

java.lang.Object
  extended byorg.jibx.binding.def.BindingBuilder.ContainerBase
      extended byorg.jibx.binding.def.NestedBase
All Implemented Interfaces:
IComponent, IContainer
Direct Known Subclasses:
NestedCollection, NestedStructure

public abstract class NestedBase
extends BindingBuilder.ContainerBase
implements IComponent, IContainer

Base class for structure and collection binding definitions. This handles one or more child components, which may be ordered or unordered.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
protected  int m_accessLevel
          Access level for default mappings.
protected  java.util.ArrayList m_attributes
          Included attribute definitions (lazy create, only if needed).
protected  int m_autoLink
          Auto-link style for default mappings.
protected  IContainer m_container
          Containing binding component.
protected  java.util.ArrayList m_contents
          Nested content definitions (initially used for all child components).
private  IContextObj m_contextObject
          Context object for this definition.
private  DefinitionContext m_defContext
          Definition context for container (may be same as parent).
private  boolean m_hasContext
          Flag for context defined at level.
protected  boolean m_isFlexible
          Flag for flexible element handling (used by subclasses).
protected  boolean m_isOrdered
          Flag for ordered child content (used by subclasses).
protected  int m_nameStyle
          Style used for generating element or attribute names.
protected  java.lang.String m_stripPrefix
          Prefix text to be stripped from names.
protected  java.lang.String m_stripSuffix
          Suffix text to be stripped from names.
protected  int m_styleDefault
          Default style for value expression.
 
Constructor Summary
NestedBase(IContainer contain, IContextObj objc, boolean ord, boolean flex, boolean defc)
          Constructor.
 
Method Summary
 void addComponent(IComponent comp)
          Add child component to nested structure.
 void genContentPresentTest(ContextMethodBuilder mb)
          Generate code to test for content present.
 void genNewInstance(ContextMethodBuilder mb)
          Generate code to create new instance of object.
 java.util.ArrayList getAttributes()
          Get the attribute children of this mapping.
 BindingDefinition getBindingRoot()
          Get root of binding definition.
 java.util.ArrayList getContents()
          Get the content children of this mapping.
 DefinitionContext getDefinitionContext()
          Get definition context for binding element.
 int getStyleDefault()
          Get default style for value expression.
 java.lang.String getType()
          Get type expected by component.
 NameDefinition getWrapperName()
          Get element wrapper name.
 boolean hasContent()
          Check if component defines one or more elements or text values as children of the containing element.
 boolean hasNamespaces()
           
 boolean isContentOrdered()
          Check if content children are ordered.
 boolean isFlexible()
          Check if flexible unmarshalling.
 boolean isOptional()
          Check if component is an optional item.
 void setObjectContext(IContextObj objc)
          Set the object context.
 void unmarshal(UnmarshallingContext ctx)
          Unmarshal common container attributes.
 
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
genAttributeMarshal, genAttributeUnmarshal, genAttrPresentTest, genContentMarshal, genContentUnmarshal, genLoadId, hasAttribute, hasId, print, setLinkages
 
Methods inherited from interface org.jibx.binding.def.IContainer
getStyleDefault
 

Field Detail

m_contextObject

private IContextObj m_contextObject
Context object for this definition.


m_hasContext

private final boolean m_hasContext
Flag for context defined at level.


m_isOrdered

protected final boolean m_isOrdered
Flag for ordered child content (used by subclasses).


m_isFlexible

protected final boolean m_isFlexible
Flag for flexible element handling (used by subclasses).


m_defContext

private final DefinitionContext m_defContext
Definition context for container (may be same as parent).


m_attributes

protected java.util.ArrayList m_attributes
Included attribute definitions (lazy create, only if needed).


m_contents

protected java.util.ArrayList m_contents
Nested content definitions (initially used for all child components).


m_container

protected IContainer m_container
Containing binding component.


m_styleDefault

protected int m_styleDefault
Default style for value expression.


m_autoLink

protected int m_autoLink
Auto-link style for default mappings.


m_accessLevel

protected int m_accessLevel
Access level for default mappings.


m_stripPrefix

protected java.lang.String m_stripPrefix
Prefix text to be stripped from names.


m_stripSuffix

protected java.lang.String m_stripSuffix
Suffix text to be stripped from names.


m_nameStyle

protected int m_nameStyle
Style used for generating element or attribute names.

Constructor Detail

NestedBase

public NestedBase(IContainer contain,
                  IContextObj objc,
                  boolean ord,
                  boolean flex,
                  boolean defc)
Constructor.

Parameters:
contain - containing binding definition context
objc - current object context
ord - ordered content flag
flex - flexible element handling flag
defc - define context for structure flag
Method Detail

setObjectContext

public void setObjectContext(IContextObj objc)
Set the object context.

Parameters:
objc - object context

getAttributes

public java.util.ArrayList getAttributes()
Get the attribute children of this mapping.

Returns:
list of attribute children (null if none; should not be modified)

getContents

public java.util.ArrayList getContents()
Get the content children of this mapping.

Returns:
list of content children (should not be modified)

addComponent

public void addComponent(IComponent comp)
Add child component to nested structure. All components are initially assumed to contain content. When IComponent.setLinkages() is called the components are checked to determine whether they actually supply attribute(s), content, or both.

Parameters:
comp - child component to be added to structure

isFlexible

public boolean isFlexible()
Check if flexible unmarshalling.

Returns:
flexible flag

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()

getBindingRoot

public BindingDefinition getBindingRoot()
Description copied from interface: IContainer
Get root of binding definition.

Specified by:
getBindingRoot in interface IContainer
Returns:
binding definition root

getDefinitionContext

public DefinitionContext getDefinitionContext()
Description copied from interface: IContainer
Get definition context for binding element.

Specified by:
getDefinitionContext in interface IContainer
Returns:
binding definition context

isOptional

public boolean isOptional()
Description copied from interface: IComponent
Check if component is an optional item.

Specified by:
isOptional in interface IComponent
Returns:
true if optional, false if required

hasContent

public boolean hasContent()
Description copied from interface: IComponent
Check if component defines one or more elements or text values as children of the containing element. This method is only valid after the call to IComponent.setLinkages().

Specified by:
hasContent in interface IComponent
Returns:
true if one or more content values defined for containing element, false if not

genContentPresentTest

public void genContentPresentTest(ContextMethodBuilder mb)
                           throws JiBXException
Description copied from interface: IComponent
Generate code to test for content present. This generates code that tests if a required element is present, leaving the result of the test (zero if missing, nonzero if present) on the stack. This call is only valid if this component has one or more content components for the containing element.

Specified by:
genContentPresentTest in interface IComponent
Parameters:
mb - method builder
Throws:
JiBXException - if configuration error

genNewInstance

public void genNewInstance(ContextMethodBuilder mb)
Description copied from interface: IComponent
Generate code to create new instance of object. This is called within the code generation for the unmarshaller of the class associated with the containing element. It needs to generate the necessary code for creating an instance of the object to be unmarshalled, leaving the object reference on the stack.

Specified by:
genNewInstance in interface IComponent
Parameters:
mb - method builder

getType

public java.lang.String getType()
Description copied from interface: IComponent
Get type expected by component.

Specified by:
getType in interface IComponent
Returns:
fully qualified class name of expected type

getWrapperName

public NameDefinition getWrapperName()
Description copied from interface: IComponent
Get element wrapper name. If the component defines an element as the container for content, this returns the name information for that element.

Specified by:
getWrapperName in interface IComponent
Returns:
component element name, null if no wrapper element

unmarshal

public void unmarshal(UnmarshallingContext ctx)
               throws JiBXException
Unmarshal common container attributes.

Parameters:
ctx - unmarshalling context information
Throws:
JiBXException - if error in unmarshalling

getStyleDefault

public int getStyleDefault()


Project Web Site