Package org.jibx.schema.codegen
Class GroupItem
- java.lang.Object
-
- org.jibx.schema.codegen.Item
-
- org.jibx.schema.codegen.GroupItem
-
- Direct Known Subclasses:
DefinitionItem
public class GroupItem extends Item
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
Fields Modifier and Type Field Description private booleanm_allOptionalFlag for all child nodes are optional.private booleanm_attributePresentAttribute data present flag.private java.lang.Stringm_classNameName to be used for generated class (nullif inherited).private booleanm_contentPresentCharacter data content data present flag.private booleanm_elementPresentElement data present flag.private booleanm_enumerationFlag for enumeration value.private TypeDatam_generateClassGenerated class information (nullif inlined).private Itemm_headFirst child (nullif none).private booleanm_inlineInline references to this structure.private intm_sizeNumber of child items in group.private Itemm_tailLast child (nullif none).private static Loggers_loggerLogger for class.
-
Constructor Summary
Constructors Modifier Constructor Description (package private)GroupItem(GroupItem original, Item ref, GroupItem parent)Copy constructor.(package private)GroupItem(ReferenceItem reference, ComponentExtension ext)Constructor from a reference.protectedGroupItem(AnnotatedBase comp, GroupItem parent)Internal constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnyItemaddAny(AnnotatedBase comp)Add a child any.GroupItemaddGroup(AnnotatedBase comp)Add a child grouping structure.ReferenceItemaddReference(AnnotatedBase comp, DefinitionItem ref)Add a child reference structure.ValueItemaddValue(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 voidclassifyContent()Classify the content of this item as attribute, element, and/or character data content.DefinitionItemconvertToDefinition()Convert an embedded group to a freestanding definition.voidconvertTypeReference()Handle groups which consist of a single type reference, or of an extension type reference, by subclassing the class generated for the reference.protected Itemcopy(Item ref, GroupItem parent)Copy the item under a different parent.protected java.lang.Stringdescribe(int depth, boolean classified)Generate a description of the item, including all nested items.protected voidforceAttributePresent()Set attribute present in group.protected voidforceContentPresent()Set character data content present in group.protected voidforceElementPresent()Set element present in group.protected voidforceRequiredPresent()Set required item present in group.intgetChildCount()Get the number of items present in the group.java.lang.StringgetClassName()Get class name set directly for this group.java.lang.StringgetEffectiveClassName()Get effective item name, applying inheritance if necessary.ItemgetFirstChild()Get head item in list grouped by this structure.TypeDatagetGenerateClass()Get information for class to be generated.booleanisAllOptional()Check if all immediate child nodes are optional.booleanisAttributePresent()Check if an attribute is part of this item.booleanisContentPresent()Check if character data content is part of this item.booleanisElementPresent()Check if a child elements is part of this item.booleanisEnumeration()Check if this value represents an enumeration.booleanisExtensionReference()Check if this group represents an extension reference.booleanisFixedClassName()Check if the class name is fixed by configuration.booleanisInline()Check if structure to be inlined.java.lang.StringnestedString(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(java.lang.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 Detail
-
s_logger
private static final Logger s_logger
Logger for class.
-
m_enumeration
private boolean m_enumeration
Flag for enumeration value.
-
m_inline
private boolean m_inline
Inline references to this structure.
-
m_className
private java.lang.String m_className
Name to be used for generated class (nullif inherited).
-
m_size
private int m_size
Number of child items in group.
-
m_head
private Item m_head
First child (nullif none).
-
m_tail
private Item m_tail
Last child (nullif none).
-
m_generateClass
private TypeData m_generateClass
Generated class information (nullif inlined).
-
m_allOptional
private boolean m_allOptional
Flag 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_attributePresent
Attribute data present flag.
-
m_elementPresent
private boolean m_elementPresent
Element data present flag.
-
m_contentPresent
private boolean m_contentPresent
Character data content data present flag.
-
-
Constructor Detail
-
GroupItem
protected GroupItem(AnnotatedBase comp, GroupItem parent)
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
GroupItem(GroupItem original, Item ref, GroupItem parent)
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 Detail
-
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
private void appendChild(Item item)
Append an item to the list of children.- Parameters:
item-
-
addGroup
public GroupItem addGroup(AnnotatedBase comp)
Add a child grouping structure.- Parameters:
comp- schema component- Returns:
- structure
-
addReference
public ReferenceItem addReference(AnnotatedBase comp, DefinitionItem ref)
Add a child reference structure.- Parameters:
comp- schema componentref- referenced definition item- Returns:
- reference
-
addValue
public ValueItem addValue(AnnotatedBase comp, QName type, JavaType ref)
Add a child value.- Parameters:
comp- schema component extensiontype- schema type nameref- schema type equivalent (nullif not appropriate)- Returns:
- value
-
addAny
public AnyItem addAny(AnnotatedBase comp)
Add a child any.- Parameters:
comp- schema component- Returns:
- value
-
replaceChild
void replaceChild(Item current, Item replace)
Replace an item in this group with another item.- Parameters:
current-replace-
-
adoptChildren
void adoptChildren(GroupItem group)
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
public java.lang.String getEffectiveClassName()
Get effective item name, applying inheritance if necessary.- Returns:
- name
-
getClassName
public java.lang.String 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
public void setClassName(java.lang.String name)
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
public Item getFirstChild()
Get head item in list grouped by this structure.- Returns:
- item (
nullif none)
-
getGenerateClass
public TypeData getGenerateClass()
Get information for class to be generated.- Returns:
- class
-
setGenerateClass
public void setGenerateClass(TypeData clas)
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
-
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
public DefinitionItem 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
public java.lang.String nestedString(int depth, boolean classified)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
-
-