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 boolean
Flag for all child nodes are optional.private boolean
Attribute data present flag.private String
Name to be used for generated class (null
if inherited).private boolean
Character data content data present flag.private boolean
Element data present flag.private boolean
Flag for enumeration value.private TypeData
Generated class information (null
if inlined).private Item
First child (null
if none).private boolean
Inline references to this structure.private int
Number of child items in group.private Item
Last child (null
if none).private static final Logger
Logger for class. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Copy constructor.(package private)
GroupItem
(ReferenceItem reference, ComponentExtension ext) Constructor from a reference.protected
GroupItem
(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) void
adoptChildren
(GroupItem group) Adopt the child items from another group as the child items of this group.private void
appendChild
(Item item) Append an item to the list of children.protected void
Classify the content of this item as attribute, element, and/or character data content.Convert an embedded group to a freestanding definition.void
Handle groups which consist of a single type reference, or of an extension type reference, by subclassing the class generated for the reference.protected Item
Copy the item under a different parent.protected String
describe
(int depth, boolean classified) Generate a description of the item, including all nested items.protected void
Set attribute present in group.protected void
Set character data content present in group.protected void
Set element present in group.protected void
Set required item present in group.int
Get 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.boolean
Check if all immediate child nodes are optional.boolean
Check if an attribute is part of this item.boolean
Check if character data content is part of this item.boolean
Check if a child elements is part of this item.boolean
Check if this value represents an enumeration.boolean
Check if this group represents an extension reference.boolean
Check if the class name is fixed by configuration.boolean
isInline()
Check if structure to be inlined.nestedString
(int depth, boolean classified) Build description of nested items.(package private) void
replaceChild
(Item current, Item replace) Replace an item in this group with another item.void
setClassName
(String name) Set class name directly for this group.void
setEnumeration
(boolean enumeration) Set value represents an enumeration flag.void
setGenerateClass
(TypeData clas) Set information for class to be generated.void
setInline
(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 (null
if inherited). -
m_size
private int m_sizeNumber of child items in group. -
m_head
First child (null
if none). -
m_tail
Last child (null
if none). -
m_generateClass
Generated class information (null
if 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 theDefinitionItem
subclass.- Parameters:
comp
- schema component (should be the simpleType component in the case of an enumeration)parent
- (null
if none)
-
GroupItem
Copy constructor. This creates a deep copy with a new parent.- Parameters:
original
-ref
- reference (for overrides to copy;null
if 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 (null
if 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 (
null
if to be inherited)
-
isFixedClassName
public boolean isFixedClassName()Check if the class name is fixed by configuration.- Returns:
true
if fixed,false
if 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
- (null
if 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 (
null
if 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:
true
if extension reference,false
if 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:
classifyContent
in 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:
true
if all child nodes optional,false
if not
-
isAttributePresent
public boolean isAttributePresent()Check if an attribute is part of this item. This is onlytrue
for 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:
true
if attribute
-
isElementPresent
public boolean isElementPresent()Check if a child elements is part of this item. This istrue
for 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:
true
if content
-
isContentPresent
public boolean isContentPresent()Check if character data content is part of this item. This istrue
for 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:
true
if content
-
describe
Generate a description of the item, including all nested items.
-