Package org.jibx.schema
Class UsageFinder
- java.lang.Object
-
- org.jibx.schema.UsageFinder
-
public class UsageFinder extends java.lang.Object
Visitor to generate usage counts for schema components. This is somewhat messy, since there are so many different types of references in schema: 'ref' (attribute, attributeGroup, element, and group, to reference a global definition of same type), 'type' (attribute and element, reference a global type definition), 'base' (extension and restriction), 'itemType' (list), 'memberTypes' (union), 'substitutionGroup' (element), and 'refer' (unique). References can be recursively expanded by matching the reference set against the set of components processed, and processing any new references until the closure is obtained.- Author:
- Dennis M. Sosnoski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
UsageFinder.UsageVisitor
Visitor to accumulate usage of definitions.
-
Field Summary
Fields Modifier and Type Field Description private UsageFinder.UsageVisitor
m_visitor
Visitor used for finding references.private static Logger
s_logger
Logger for class.
-
Constructor Summary
Constructors Constructor Description UsageFinder()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReferenceClosure(java.util.List list)
Add usage counts for the reference closure of a supplied list of components.void
addReferenceClosure(AnnotatedBase comp)
Add usage counts for the reference closure of a definition.void
countSchemaTree(SchemaElement schema)
Add usage counts for a schema tree.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 the accumulated usage counts.void
setNameRegister(NameRegister reg)
Set the register to be used for resolving name references.
-
-
-
Field Detail
-
s_logger
private static final Logger s_logger
Logger for class.
-
m_visitor
private final UsageFinder.UsageVisitor m_visitor
Visitor used for finding references.
-
-
Method Detail
-
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
-
countSchemaTree
public void countSchemaTree(SchemaElement schema)
Add usage counts for a schema tree. This counts all references from the supplied schema, including references in other schemas referenced by the schema.- Parameters:
schema
-
-
addReferenceClosure
public void addReferenceClosure(AnnotatedBase comp)
Add usage counts for the reference closure of a definition.- Parameters:
comp
- definition to be processed
-
addReferenceClosure
public void addReferenceClosure(java.util.List list)
Add usage counts for the reference closure of a supplied list of components.- Parameters:
list
- starting schema components
-
setNameRegister
public void setNameRegister(NameRegister reg)
Set the register to be used for resolving name references. This is not needed if counting references from a schema tree usingcountSchemaTree(SchemaElement)
, which always sets the register associated with the supplied schema.- Parameters:
reg
-
-
reset
public void reset()
Clear the accumulated usage counts.
-
-