Package org.jibx.schema.codegen
Class Item
java.lang.Object
org.jibx.schema.codegen.Item
- Direct Known Subclasses:
AnyItem,GroupItem,ReferenceItem,ValueItem
Base 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
FieldsModifier and TypeFieldDescriptionprivate final booleanFlag for a collection item.private final ComponentExtensionCorresponding schema component extension.private booleanItem is handled by subclassing flag.protected ItemPreceding item in list (nullif none).private StringActual name to be used for item (nullif to be inherited).protected ItemNext item in list (nullif none).private final booleanFlag for a nillable item.private final booleanFlag for an optional item.private GroupItemContaining group item.private final booleanFlag for topmost item associated with a particular schema component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedItem(Item original, Item ref, ComponentExtension ext, GroupItem parent) Copy constructor.protectedItem(AnnotatedBase comp, GroupItem parent) Basic constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClassify 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 the item under a different parent.protected abstract Stringdescribe(int depth, boolean classified) Generate a description of the item.protected GroupItemFind the nearest ancestor group which relates to a different schema component.Get schema component annotation corresponding to this item.Get effective item name, applying inheritance if necessary.getName()Get name set directly for this item.getNext()Get next item in list.Get containing group item.Get schema component corresponding to this item.Get the topmost item associated with the same schema component as this item.booleanCheck if a collection item.booleanCheck if the name is fixed by configuration.booleanCheck if item is ignored.booleanCheck if the item is represented implicitly by subclassing.booleanCheck if item is optional.booleanCheck if topmost item for a particular schema component.protected StringleadString(int depth) Generate the standard leading text for description of the item.protected voidReplace the parent for this item.voidsetImplicit(boolean implicit) Set item represented implicitly by subclassing flag.voidSet name directly for this item.
-
Field Details
-
m_componentExtension
Corresponding schema component extension. -
m_topmost
private final boolean m_topmostFlag for topmost item associated with a particular schema component. -
m_optional
private final boolean m_optionalFlag 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_collectionFlag 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_nillableFlag 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_implicitItem is handled by subclassing flag. -
m_parent
Containing group item. -
m_next
Next item in list (nullif none). -
m_last
Preceding item in list (nullif none). -
m_name
Actual name to be used for item (nullif to be inherited).
-
-
Constructor Details
-
Item
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
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 Details
-
reparent
Replace the parent for this item.- Parameters:
parent-
-
getSchemaComponent
Get schema component corresponding to this item.- Returns:
- schema component
-
getComponentExtension
Get schema component annotation corresponding to this item.- Returns:
- schema component
-
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
Get effective item name, applying inheritance if necessary.- Returns:
- name
-
getName
Get name set directly for this item.- Returns:
- name (
nullif to be inherited)
-
setName
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
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
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
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
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
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
Generate the standard leading text for description of the item.- Parameters:
depth- current nesting depth- Returns:
- leading text for description
-