Package org.jibx.binding.def
Class NestedBase
- java.lang.Object
-
- org.jibx.binding.def.NestedBase
-
- All Implemented Interfaces:
IComponent,IContainer,ILinkable
- Direct Known Subclasses:
NestedCollection,NestedStructure
public abstract class NestedBase extends Object implements IComponent, IContainer
Base class for structure and collection binding definitions. This handles one or more child components, which may be ordered or unordered.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_accessLevelAccess level for default mappings.protected ArrayListm_attributesIncluded attribute definitions (lazy create, only if needed).protected intm_autoLinkAuto-link style for default mappings.protected IContainerm_containerContaining binding component.protected ArrayListm_contentsNested content definitions (initially used for all child components).protected booleanm_isFlexibleFlag for flexible element handling (used by subclasses).protected booleanm_isOrderedFlag for ordered child content (used by subclasses).protected intm_nameStyleStyle used for generating element or attribute names.protected Stringm_stripPrefixPrefix text to be stripped from names.protected Stringm_stripSuffixSuffix text to be stripped from names.protected intm_styleDefaultDefault style for value expression.
-
Constructor Summary
Constructors Constructor Description NestedBase(IContainer contain, IContextObj objc, boolean ord, boolean flex, boolean defc)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComponent(IComponent comp)Add child component to nested structure.voidgenContentPresentTest(ContextMethodBuilder mb)Generate code to test for content present.ArrayListgetAttributes()Get the attribute children of this mapping.BindingDefinitiongetBindingRoot()Get root of binding definition.ArrayListgetContents()Get the content children of this mapping.DefinitionContextgetDefinitionContext()Get definition context for binding element.intgetStyleDefault()StringgetType()Get type expected by component.NameDefinitiongetWrapperName()Get element wrapper name.booleanhasContent()Check if component defines one or more elements or text values as children of the containing element.booleanhasNamespaces()booleanisContentOrdered()Check if content children are ordered.booleanisFlexible()Check if flexible unmarshalling.booleanisOptional()Check if component is an optional item.voidsetObjectContext(IContextObj objc)Set the object context.voidunmarshal(org.jibx.runtime.impl.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, genNewInstance, hasAttribute, hasId, print
-
Methods inherited from interface org.jibx.binding.def.IContainer
getStyleDefault
-
Methods inherited from interface org.jibx.binding.def.ILinkable
setLinkages
-
-
-
-
Field Detail
-
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_attributes
protected ArrayList m_attributes
Included attribute definitions (lazy create, only if needed).
-
m_contents
protected 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 String m_stripPrefix
Prefix text to be stripped from names.
-
m_stripSuffix
protected 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 contextobjc- current object contextord- ordered content flagflex- flexible element handling flagdefc- define context for structure flag
-
-
Method Detail
-
setObjectContext
public void setObjectContext(IContextObj objc)
Set the object context.- Parameters:
objc- object context
-
getAttributes
public ArrayList getAttributes()
Get the attribute children of this mapping.- Returns:
- list of attribute children (
nullif none; should not be modified)
-
getContents
public 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. WhenILinkable.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:IContainerCheck if content children are ordered.- Specified by:
isContentOrderedin interfaceIContainer- Returns:
trueif ordered,falseif not
-
hasNamespaces
public boolean hasNamespaces()
-
getBindingRoot
public BindingDefinition getBindingRoot()
Description copied from interface:IContainerGet root of binding definition.- Specified by:
getBindingRootin interfaceIContainer- Returns:
- binding definition root
-
getDefinitionContext
public DefinitionContext getDefinitionContext()
Description copied from interface:IContainerGet definition context for binding element.- Specified by:
getDefinitionContextin interfaceIContainer- Returns:
- binding definition context
-
isOptional
public boolean isOptional()
Description copied from interface:IComponentCheck if component is an optional item.- Specified by:
isOptionalin interfaceIComponent- Returns:
trueif optional,falseif required
-
hasContent
public boolean hasContent()
Description copied from interface:IComponentCheck if component defines one or more elements or text values as children of the containing element. This method is only valid after the call toILinkable.setLinkages().- Specified by:
hasContentin interfaceIComponent- Returns:
trueif one or more content values defined for containing element,falseif not
-
genContentPresentTest
public void genContentPresentTest(ContextMethodBuilder mb) throws org.jibx.runtime.JiBXException
Description copied from interface:IComponentGenerate 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:
genContentPresentTestin interfaceIComponent- Parameters:
mb- method builder- Throws:
org.jibx.runtime.JiBXException- if configuration error
-
getType
public String getType()
Description copied from interface:IComponentGet type expected by component.- Specified by:
getTypein interfaceIComponent- Returns:
- fully qualified class name of expected type
-
getWrapperName
public NameDefinition getWrapperName()
Description copied from interface:IComponentGet element wrapper name. If the component defines an element as the container for content, this returns the name information for that element.- Specified by:
getWrapperNamein interfaceIComponent- Returns:
- component element name,
nullif no wrapper element
-
unmarshal
public void unmarshal(org.jibx.runtime.impl.UnmarshallingContext ctx) throws org.jibx.runtime.JiBXExceptionUnmarshal common container attributes.- Parameters:
ctx- unmarshalling context information- Throws:
org.jibx.runtime.JiBXException- if error in unmarshalling
-
getStyleDefault
public int getStyleDefault()
-
-