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 boolean
Flag for a collection item.private final ComponentExtension
Corresponding schema component extension.private boolean
Item is handled by subclassing flag.protected Item
Preceding item in list (null
if none).private String
Actual name to be used for item (null
if to be inherited).protected Item
Next item in list (null
if none).private final boolean
Flag for a nillable item.private final boolean
Flag for an optional item.private GroupItem
Containing group item.private final boolean
Flag for topmost item associated with a particular schema component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Item
(Item original, Item ref, ComponentExtension ext, GroupItem parent) Copy constructor.protected
Item
(AnnotatedBase comp, GroupItem parent) Basic constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
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 Item
Copy the item under a different parent.protected abstract String
describe
(int depth, boolean classified) Generate a description of the item.protected GroupItem
Find 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.boolean
Check if a collection item.boolean
Check if the name is fixed by configuration.boolean
Check if item is ignored.boolean
Check if the item is represented implicitly by subclassing.boolean
Check if item is optional.boolean
Check if topmost item for a particular schema component.protected String
leadString
(int depth) Generate the standard leading text for description of the item.protected void
Replace the parent for this item.void
setImplicit
(boolean implicit) Set item represented implicitly by subclassing flag.void
Set 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 (null
if none). -
m_last
Preceding item in list (null
if none). -
m_name
Actual name to be used for item (null
if 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 flagsfalse
to avoid redundant handling.- Parameters:
comp
- schema componentparent
- containing group (null
if a top-level group)
-
Item
Copy constructor. This creates a copy with a new parent.- Parameters:
original
-ref
- reference (for name override;null
if 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 (
null
if a top-level group)
-
isFixedName
public boolean isFixedName()Check if the name is fixed by configuration.- Returns:
true
if fixed,false
if not
-
getEffectiveName
Get effective item name, applying inheritance if necessary.- Returns:
- name
-
getName
Get name set directly for this item.- Returns:
- name (
null
if 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
- (null
if 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:
true
if 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;null
if none)parent
-- Returns:
- copy
-
findDisjointParent
Find the nearest ancestor group which relates to a different schema component.- Returns:
- ancestor with different schema component, or
null
if 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
-