Class UsageFinder.UsageVisitor

  • Enclosing class:
    UsageFinder

    private static class UsageFinder.UsageVisitor
    extends SchemaVisitor
    Visitor to accumulate usage of definitions.
    • Field Detail

      • 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).
    • Constructor Detail

      • UsageVisitor

        public UsageVisitor()
        Constructor.
    • 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.