Package org.jibx.schema
Class UsageFinder.UsageVisitor
- java.lang.Object
-
- org.jibx.schema.SchemaVisitor
-
- org.jibx.schema.UsageFinder.UsageVisitor
-
- Enclosing class:
- UsageFinder
private static class UsageFinder.UsageVisitor extends SchemaVisitor
Visitor to accumulate usage of definitions.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList
m_newReferences
Added references list (null
if unused).private java.util.Set
m_nonSingletonSet
Set of definitions referenced as non-required or repeating items.private SchemaContextTracker
m_tracker
Tracker for schema context information.private ReferenceCountMap
m_usageMap
Usage counts found for each global definition.
-
Constructor Summary
Constructors Constructor Description UsageVisitor()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addNonSingleton(java.lang.Object obj)
Convenience method for recording a non-singleton reference.void
addReferenceClosure(AnnotatedBase comp)
Add usage counts for the reference closure of a definition.private void
countUse(java.lang.Object obj)
Convenience method for incrementing a use count.void
exit(AttributeElement node)
Exit attribute element.void
exit(AttributeGroupRefElement node)
Exit attributeGroup element for reference.void
exit(ComplexExtensionElement node)
Exit extension element used for complex type.void
exit(ComplexRestrictionElement node)
Exit restriction element used for complex type.void
exit(ElementElement node)
Exit element element.void
exit(GroupRefElement node)
Exit group element for reference.void
exit(ListElement node)
Exit list element.void
exit(SimpleExtensionElement node)
Exit extension element for simple type.void
exit(SimpleRestrictionElement node)
Exit restriction element for simple type.void
exit(UnionElement node)
Exit union element.ISchemaListener
getListener()
Get the schema change listener for this visitor.java.util.Set
getNonSingletonSet()
Get the set of definitions referenced as optional or repeating.ReferenceCountMap
getUsageMap()
Get map of reference counts per component.void
reset()
Clear all state information.void
setNameRegister(NameRegister reg)
Set the register to be used for resolving name references.-
Methods inherited from class org.jibx.schema.SchemaVisitor
exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, exit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
-
-
-
Field Detail
-
m_tracker
private final SchemaContextTracker m_tracker
Tracker for schema context information.
-
m_usageMap
private final ReferenceCountMap m_usageMap
Usage counts found for each global definition.
-
m_nonSingletonSet
private final java.util.Set m_nonSingletonSet
Set of definitions referenced as non-required or repeating items.
-
m_newReferences
private java.util.ArrayList m_newReferences
Added references list (null
if unused).
-
-
Method Detail
-
getListener
public ISchemaListener getListener()
Get the schema change listener for this visitor.- Returns:
- listener
-
countUse
private void countUse(java.lang.Object obj)
Convenience method for incrementing a use count. If tracking of added references is enabled this also adds the referenced object to the list if it's a first-time reference.- Parameters:
obj
- referenced object (null
if none, ignored if a schema type)
-
addNonSingleton
private void addNonSingleton(java.lang.Object obj)
Convenience method for recording a non-singleton reference.- Parameters:
obj
- referenced object (null
if none)
-
addReferenceClosure
public void addReferenceClosure(AnnotatedBase comp)
Add usage counts for the reference closure of a definition. This counts all references from the definition, then all references from the definitions referenced by the original definition, and so on until no new references are found. This method may be called repeatedly, with the final results representing the closure of the union of the specified definitions (or the union of the closure, since these are the same).- Parameters:
comp
- definition to be processed
-
setNameRegister
public void setNameRegister(NameRegister reg)
Set the register to be used for resolving name references.- Parameters:
reg
-
-
getUsageMap
public ReferenceCountMap getUsageMap()
Get map of reference counts per component.- Returns:
- count map
-
getNonSingletonSet
public java.util.Set getNonSingletonSet()
Get the set of definitions referenced as optional or repeating.- Returns:
- set
-
reset
public void reset()
Clear all state information. This allows an instance to be reused.
-
exit
public void exit(AttributeElement node)
Description copied from class:SchemaVisitor
Exit attribute element.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(AttributeGroupRefElement node)
Description copied from class:SchemaVisitor
Exit attributeGroup element for reference.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(ComplexExtensionElement node)
Description copied from class:SchemaVisitor
Exit extension element used for complex type.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(ComplexRestrictionElement node)
Description copied from class:SchemaVisitor
Exit restriction element used for complex type.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(ElementElement node)
Description copied from class:SchemaVisitor
Exit element element.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(GroupRefElement node)
Description copied from class:SchemaVisitor
Exit group element for reference.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(ListElement node)
Description copied from class:SchemaVisitor
Exit list element.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(SimpleExtensionElement node)
Description copied from class:SchemaVisitor
Exit extension element for simple type.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(SimpleRestrictionElement node)
Description copied from class:SchemaVisitor
Exit restriction element for simple type.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
exit
public void exit(UnionElement node)
Description copied from class:SchemaVisitor
Exit union element.- Overrides:
exit
in classSchemaVisitor
- Parameters:
node
- element being exited
-
-