Package org.jibx.schema.codegen
Class Item
- java.lang.Object
-
- org.jibx.schema.codegen.Item
-
- Direct Known Subclasses:
AnyItem,GroupItem,ReferenceItem,ValueItem
public abstract class Item extends java.lang.ObjectBase class for code generation items. Each instance corresponds to a particular schema component, and this base class tracks that schema component (by way of the extension information), along with related details and linkage information. The linkage uses embedded list links, which allows replacing one instance with another with minimal overhead.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private booleanm_collectionFlag for a collection item.private ComponentExtensionm_componentExtensionCorresponding schema component extension.private booleanm_implicitItem is handled by subclassing flag.protected Itemm_lastPreceding item in list (nullif none).private java.lang.Stringm_nameActual name to be used for item (nullif to be inherited).protected Itemm_nextNext item in list (nullif none).private booleanm_nillableFlag for a nillable item.private booleanm_optionalFlag for an optional item.private GroupItemm_parentContaining group item.private booleanm_topmostFlag for topmost item associated with a particular schema component.
-
Constructor Summary
Constructors Modifier Constructor Description protectedItem(Item original, Item ref, ComponentExtension ext, GroupItem parent)Copy constructor.protectedItem(AnnotatedBase comp, GroupItem parent)Basic constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclassifyContent()Classify the content of this item as attribute, element, and/or character data content, and as requiring content of some form if appropriate.protected abstract Itemcopy(Item ref, GroupItem parent)Copy the item under a different parent.protected abstract java.lang.Stringdescribe(int depth, boolean classified)Generate a description of the item.protected GroupItemfindDisjointParent()Find the nearest ancestor group which relates to a different schema component.ComponentExtensiongetComponentExtension()Get schema component annotation corresponding to this item.java.lang.StringgetEffectiveName()Get effective item name, applying inheritance if necessary.java.lang.StringgetName()Get name set directly for this item.ItemgetNext()Get next item in list.GroupItemgetParent()Get containing group item.AnnotatedBasegetSchemaComponent()Get schema component corresponding to this item.ItemgetTopmost()Get the topmost item associated with the same schema component as this item.booleanisCollection()Check if a collection item.booleanisFixedName()Check if the name is fixed by configuration.booleanisIgnored()Check if item is ignored.booleanisImplicit()Check if the item is represented implicitly by subclassing.booleanisOptional()Check if item is optional.booleanisTopmost()Check if topmost item for a particular schema component.protected java.lang.StringleadString(int depth)Generate the standard leading text for description of the item.protected voidreparent(GroupItem parent)Replace the parent for this item.voidsetImplicit(boolean implicit)Set item represented implicitly by subclassing flag.voidsetName(java.lang.String name)Set name directly for this item.
-
-
-
Field Detail
-
m_componentExtension
private final ComponentExtension m_componentExtension
Corresponding schema component extension.
-
m_topmost
private final boolean m_topmost
Flag for topmost item associated with a particular schema component.
-
m_optional
private final boolean m_optional
Flag for an optional item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
-
m_collection
private final boolean m_collection
Flag for a collection item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
-
m_nillable
private final boolean m_nillable
Flag for a nillable item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
-
m_implicit
private boolean m_implicit
Item is handled by subclassing flag.
-
m_parent
private GroupItem m_parent
Containing group item.
-
m_next
protected Item m_next
Next item in list (nullif none).
-
m_last
protected Item m_last
Preceding item in list (nullif none).
-
m_name
private java.lang.String m_name
Actual name to be used for item (nullif to be inherited).
-
-
Constructor Detail
-
Item
protected Item(AnnotatedBase comp, GroupItem parent)
Basic constructor. This uses the schema component to determine all information other than the parent item group, including the optional/nillable/collection flags. As a special case, if the parent group is associated with the same component this sets all three of these flagsfalseto avoid redundant handling.- Parameters:
comp- schema componentparent- containing group (nullif a top-level group)
-
Item
protected Item(Item original, Item ref, ComponentExtension ext, GroupItem parent)
Copy constructor. This creates a copy with a new parent.- Parameters:
original-ref- reference (for name override;nullif none)ext- component extension to be linked with copyparent- (non-null)
-
-
Method Detail
-
reparent
protected void reparent(GroupItem parent)
Replace the parent for this item.- Parameters:
parent-
-
getSchemaComponent
public AnnotatedBase getSchemaComponent()
Get schema component corresponding to this item.- Returns:
- schema component
-
getComponentExtension
public ComponentExtension getComponentExtension()
Get schema component annotation corresponding to this item.- Returns:
- schema component
-
getParent
public GroupItem getParent()
Get containing group item.- Returns:
- group (
nullif a top-level group)
-
isFixedName
public boolean isFixedName()
Check if the name is fixed by configuration.- Returns:
trueif fixed,falseif not
-
getEffectiveName
public java.lang.String getEffectiveName()
Get effective item name, applying inheritance if necessary.- Returns:
- name
-
getName
public java.lang.String getName()
Get name set directly for this item.- Returns:
- name (
nullif to be inherited)
-
setName
public void setName(java.lang.String name)
Set name directly for this item. It is an error to call this method if the name is fixed.- Parameters:
name- (nullif to be inherited)
-
getNext
public Item getNext()
Get next item in list.- Returns:
- next
-
isTopmost
public boolean isTopmost()
Check if topmost item for a particular schema component. The methodsisCollection(),isOptional(),GroupItem.isAllOptional(),GroupItem.isAttributePresent(),GroupItem.isContentPresent(), andGroupItem.isElementPresent()are all only meaningful for the topmost item associated with a schema component.- Returns:
- topmost
-
getTopmost
public Item getTopmost()
Get the topmost item associated with the same schema component as this item. The methodsisCollection(),isOptional(),GroupItem.isAllOptional(),GroupItem.isAttributePresent(),GroupItem.isContentPresent(), andGroupItem.isElementPresent()are all only meaningful for the topmost item associated with a schema component.- Returns:
- topmost
-
isOptional
public boolean isOptional()
Check if item is optional. This method is only meaningful for the topmost item associated with a particular schema component (those for whichisTopmost()returnstrue).- Returns:
- optional
-
isIgnored
public boolean isIgnored()
Check if item is ignored. This method is only meaningful for the topmost item associated with a particular schema component (those for whichisTopmost()returnstrue).- Returns:
- optional
-
isCollection
public boolean isCollection()
Check if a collection item. This method is only meaningful for the topmost item associated with a particular schema component (those for whichisTopmost()returnstrue).- Returns:
trueif collection
-
isImplicit
public boolean isImplicit()
Check if the item is represented implicitly by subclassing.- Returns:
- implicit
-
setImplicit
public void setImplicit(boolean implicit)
Set item represented implicitly by subclassing flag.- Parameters:
implicit-
-
copy
protected abstract Item copy(Item ref, GroupItem parent)
Copy the item under a different parent. This is intended for replacing a reference with a copy, and allows the reference to override settings from the original.- Parameters:
ref- reference (for overrides to copy;nullif none)parent-- Returns:
- copy
-
findDisjointParent
protected GroupItem findDisjointParent()
Find the nearest ancestor group which relates to a different schema component.- Returns:
- ancestor with different schema component, or
nullif none
-
classifyContent
protected void classifyContent()
Classify the content of this item as attribute, element, and/or character data content, and as requiring content of some form if appropriate. This needs to be done as a separate step after construction in order to handle references, which must assume the content of the definition, and also to work after inlining. This base class implementation does the classification based solely on the schema component type. Any subclasses which override this method should generally call the base class implementation before doing their own classification handling, unless they use a substitute component.
-
describe
protected abstract java.lang.String describe(int depth, boolean classified)Generate a description of the item. For items with nested items this will show the complete structure.- Parameters:
depth- current nesting depthclassified- include classification details flag- Returns:
- description
-
leadString
protected java.lang.String leadString(int depth)
Generate the standard leading text for description of the item.- Parameters:
depth- current nesting depth- Returns:
- leading text for description
-
-