Package org.jibx.schema.codegen
Class GroupItem
java.lang.Object
org.jibx.schema.codegen.Item
org.jibx.schema.codegen.GroupItem
- Direct Known Subclasses:
DefinitionItem
Information for a grouping of components (attributes, elements, compositors, and/or wildcards). This is used for
both local groupings and global definitions.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag for all child nodes are optional.private booleanAttribute data present flag.private StringName to be used for generated class (nullif inherited).private booleanCharacter data content data present flag.private booleanElement data present flag.private booleanFlag for enumeration value.private TypeDataGenerated class information (nullif inlined).private ItemFirst child (nullif none).private booleanInline references to this structure.private intNumber of child items in group.private ItemLast child (nullif none).private static final LoggerLogger for class. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Copy constructor.(package private)GroupItem(ReferenceItem reference, ComponentExtension ext) Constructor from a reference.protectedGroupItem(AnnotatedBase comp, GroupItem parent) Internal constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddAny(AnnotatedBase comp) Add a child any.addGroup(AnnotatedBase comp) Add a child grouping structure.addReference(AnnotatedBase comp, DefinitionItem ref) Add a child reference structure.addValue(AnnotatedBase comp, QName type, JavaType ref) Add a child value.(package private) voidadoptChildren(GroupItem group) Adopt the child items from another group as the child items of this group.private voidappendChild(Item item) Append an item to the list of children.protected voidClassify the content of this item as attribute, element, and/or character data content.Convert an embedded group to a freestanding definition.voidHandle groups which consist of a single type reference, or of an extension type reference, by subclassing the class generated for the reference.protected ItemCopy the item under a different parent.protected Stringdescribe(int depth, boolean classified) Generate a description of the item, including all nested items.protected voidSet attribute present in group.protected voidSet character data content present in group.protected voidSet element present in group.protected voidSet required item present in group.intGet the number of items present in the group.Get class name set directly for this group.Get effective item name, applying inheritance if necessary.Get head item in list grouped by this structure.Get information for class to be generated.booleanCheck if all immediate child nodes are optional.booleanCheck if an attribute is part of this item.booleanCheck if character data content is part of this item.booleanCheck if a child elements is part of this item.booleanCheck if this value represents an enumeration.booleanCheck if this group represents an extension reference.booleanCheck if the class name is fixed by configuration.booleanisInline()Check if structure to be inlined.nestedString(int depth, boolean classified) Build description of nested items.(package private) voidreplaceChild(Item current, Item replace) Replace an item in this group with another item.voidsetClassName(String name) Set class name directly for this group.voidsetEnumeration(boolean enumeration) Set value represents an enumeration flag.voidsetGenerateClass(TypeData clas) Set information for class to be generated.voidsetInline(boolean inline) Set structure to be inlined flag.Methods inherited from class org.jibx.schema.codegen.Item
findDisjointParent, getComponentExtension, getEffectiveName, getName, getNext, getParent, getSchemaComponent, getTopmost, isCollection, isFixedName, isIgnored, isImplicit, isOptional, isTopmost, leadString, reparent, setImplicit, setName
-
Field Details
-
s_logger
private static final Logger s_loggerLogger for class. -
m_enumeration
private boolean m_enumerationFlag for enumeration value. -
m_inline
private boolean m_inlineInline references to this structure. -
m_className
Name to be used for generated class (nullif inherited). -
m_size
private int m_sizeNumber of child items in group. -
m_head
First child (nullif none). -
m_tail
Last child (nullif none). -
m_generateClass
Generated class information (nullif inlined). -
m_allOptional
private boolean m_allOptionalFlag for all child nodes are optional. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item. -
m_attributePresent
private boolean m_attributePresentAttribute data present flag. -
m_elementPresent
private boolean m_elementPresentElement data present flag. -
m_contentPresent
private boolean m_contentPresentCharacter data content data present flag.
-
-
Constructor Details
-
GroupItem
Internal constructor. This is used both for creating a new child group directly, and by theDefinitionItemsubclass.- Parameters:
comp- schema component (should be the simpleType component in the case of an enumeration)parent- (nullif none)
-
GroupItem
Copy constructor. This creates a deep copy with a new parent.- Parameters:
original-ref- reference (for overrides to copy;nullif none)parent- (non-null)
-
GroupItem
GroupItem(ReferenceItem reference, ComponentExtension ext) Constructor from a reference. This is only used for inlining a referenced definition. It merges usage information from the reference with a deep copy of the item structure of the definition.- Parameters:
reference-ext- component extension to be linked with inlined definition
-
-
Method Details
-
isEnumeration
public boolean isEnumeration()Check if this value represents an enumeration.- Returns:
- enumeration
-
setEnumeration
public void setEnumeration(boolean enumeration) Set value represents an enumeration flag.- Parameters:
enumeration-
-
appendChild
Append an item to the list of children.- Parameters:
item-
-
addGroup
Add a child grouping structure.- Parameters:
comp- schema component- Returns:
- structure
-
addReference
Add a child reference structure.- Parameters:
comp- schema componentref- referenced definition item- Returns:
- reference
-
addValue
Add a child value.- Parameters:
comp- schema component extensiontype- schema type nameref- schema type equivalent (nullif not appropriate)- Returns:
- value
-
addAny
Add a child any.- Parameters:
comp- schema component- Returns:
- value
-
replaceChild
Replace an item in this group with another item.- Parameters:
current-replace-
-
adoptChildren
Adopt the child items from another group as the child items of this group.- Parameters:
group-
-
isInline
public boolean isInline()Check if structure to be inlined.- Returns:
- inline
-
setInline
public void setInline(boolean inline) Set structure to be inlined flag.- Parameters:
inline-
-
getEffectiveClassName
Get effective item name, applying inheritance if necessary.- Returns:
- name
-
getClassName
Get class name set directly for this group.- Returns:
- name (
nullif to be inherited)
-
isFixedClassName
public boolean isFixedClassName()Check if the class name is fixed by configuration.- Returns:
trueif fixed,falseif not
-
setClassName
Set class name directly for this group. It is an error to call this method if the class name is fixed.- Parameters:
name- (nullif to be inherited)
-
getChildCount
public int getChildCount()Get the number of items present in the group.- Returns:
- count
-
getFirstChild
Get head item in list grouped by this structure.- Returns:
- item (
nullif none)
-
getGenerateClass
Get information for class to be generated.- Returns:
- class
-
setGenerateClass
Set information for class to be generated. If this group is a complexType extension and the base type is not being inlined, this sets the generated class to extend the base type class.- Parameters:
clas-
-
isExtensionReference
public boolean isExtensionReference()Check if this group represents an extension reference.- Returns:
trueif extension reference,falseif not
-
convertTypeReference
public void convertTypeReference()Handle groups which consist of a single type reference, or of an extension type reference, by subclassing the class generated for the reference. TODO: instead use separate extension test, since this won't be called for embedded types -
copy
Copy the item under a different parent. -
forceAttributePresent
protected void forceAttributePresent()Set attribute present in group. This cascades the attribute present flag upward through containing groups until one is found which defines an element name. -
forceElementPresent
protected void forceElementPresent()Set element present in group. This cascades the element present flag upward through containing groups until one is found which defines an element name. -
forceContentPresent
protected void forceContentPresent()Set character data content present in group. This cascades the content present flag upward through all containing groups until one is found which defines an element name. -
forceRequiredPresent
protected void forceRequiredPresent()Set required item present in group. This cascades the required item present flag upward through all containing groups until one is found which defines either a wrapping element or a compositor other than a required sequence (because a required item present within a required sequence means that there will always be something present in the document, while any other type of compositor does not have this meaning). -
classifyContent
protected void classifyContent()Classify the content of this item as attribute, element, and/or character data content. For a group item, this just needs to call the corresponding method for each child item.- Overrides:
classifyContentin classItem
-
convertToDefinition
Convert an embedded group to a freestanding definition. This creates a definition using a cloned copy of the structure of this group, then replaces this group with a reference to the definition. TODO: just adopt the child items, rather than cloning? minor performance gain.- Returns:
- definition
-
nestedString
Build description of nested items.- Parameters:
depth- current nesting depthclassified- include classification details flag- Returns:
- description
-
isAllOptional
public boolean isAllOptional()Check if all immediate child nodes are optional. This is needed when handling code generation for a reference to a group or attributeGroup handled as a separate object, since that object only needs to be present if one or more of the values are present. This method is only meaningful for the topmost item associated with a particular schema component (those for whichItem.isTopmost()returnstrue).- Returns:
trueif all child nodes optional,falseif not
-
isAttributePresent
public boolean isAttributePresent()Check if an attribute is part of this item. This is onlytruefor items corresponding to attribute definitions, and groupings including these items which do not define an element name. This method is only meaningful for the topmost item associated with a particular schema component (those for whichItem.isTopmost()returnstrue).- Returns:
trueif attribute
-
isElementPresent
public boolean isElementPresent()Check if a child elements is part of this item. This istruefor all items corresponding to element definitions, and all groupings which include such an item. This method is only meaningful for the topmost item associated with a particular schema component (those for whichItem.isTopmost()returnstrue).- Returns:
trueif content
-
isContentPresent
public boolean isContentPresent()Check if character data content is part of this item. This istruefor all items corresponding to simpleContent definitions, and all groupings which include such an item. This method is only meaningful for the topmost item associated with a particular schema component (those for whichItem.isTopmost()returnstrue).- Returns:
trueif content
-
describe
Generate a description of the item, including all nested items.
-