Class Statistics

java.lang.Object
eu.bandm.tools.dtd.Statistics

public class Statistics extends Object
Collects and analyses references between elements, attlists and entities. Searches for common attributes and possible abstract declarations. Offers some printstream-based visualisation of the results.
For simplicity, all result fields are declared "public", but meant only to be read. (Since these statistic data is mostly for information purpose, protection mechanisms seem an over-do. Every map and every set must be wrapped into an "immutable" one, etc.!)
Sets/maps which do MIX elements, GEs, PEs, etc., represent all those by their "canonical key", see Utilities.canonicalKey_element(String), Utilities.canonicalKey_attribute(String) and Utilities.canonicalKey_entity(String,boolean).
The same encoding has already been employed by the TunedDTDParser when the field DTD.Dtd.entityUsage is filled. It collects all references to PEs and GEs from Element content models (PE only), attribute lists(PE), attribute value contents(GE), PE definition text (PE / GE) and GE definition text (GE):
The statistic data heavily relies on this field, and on the partial analyses done by ElementIndex and AttlistIndex.
  • Field Details

    • dtd

      protected DTD.Dtd dtd
    • msg

    • elementIndex

      public ElementIndex elementIndex
    • attlistIndex

      public AttlistIndex attlistIndex
    • has_pi

      public boolean has_pi
    • has_comment

      public boolean has_comment
    • has_insert

      public boolean has_insert
    • has_element

      public boolean has_element
    • has_attlist

      public boolean has_attlist
    • has_pe

      public boolean has_pe
    • has_ge

      public boolean has_ge
    • piTargets

      public Set<String> piTargets
    • el2el

      public final Multimap<DTD.Element,DTD.Element> el2el
      Left elements refer to right elements in their contents model.
    • abstractCandidates

      public final Map<DTD.Element,Set<DTD.AttDef>> abstractCandidates
      Elements which have (nested) disjunctions of singletons as contents model.
    • abstractEntityCandidates

      public final Set<DTD.Entity> abstractEntityCandidates
      Entities used for content models, possibly candidates for abstract elements.
    • abstractEntityCandidates_decorated

      public final Set<DTD.Entity> abstractEntityCandidates_decorated
      Entities used for content models, possibly candidates for abstract elements when removing decoration.
    • el2att

      public final Multimap<DTD.Element,String> el2att
      Elements refer to attributes in their attlist. Attributes encoded with name and type by using Utilities.canonicalKey_att_name_type(AttDef).
    • peByName

      public final Map<String,DTD.Entity> peByName
      Map of names (without prefix) to the parameter entity.
    • peByKey

      public final Map<String,DTD.Entity> peByKey
      Map of keys (with prefix) to the parameter entity.
    • geByName

      public final Map<String,DTD.Entity> geByName
      Map of names (without prefix) to the general entity.
    • geByKey

      public final Map<String,DTD.Entity> geByKey
      Map of keys (with prefix) to the general entity.
    • element2topLevelEntity

      public final Multimap<String,String> element2topLevelEntity
      Elements refer directly to entity in their contents model.
    • entityKeysUsedForContent

      public Set<String> entityKeysUsedForContent
      Entities contained directly OR IN-directly in content models.
    • transitiveUsage

      public final Multimap<String,String> transitiveUsage
      Transitive closure of reference relations (from ent/el/att/ent) into entities.
    • elRefsUndef

      public final Set<String> elRefsUndef
      Element names referred to, but not defined.
    • peRefsUndef

      public final Set<String> peRefsUndef
      PEs referred to, but not defined. FIXME MISSING
    • geRefsUndef

      public final Set<String> geRefsUndef
      GEs referred to, but not defined. FIXME MISSING
  • Constructor Details

    • Statistics

      public Statistics()
  • Method Details

    • check_abstract_precondition

      protected boolean check_abstract_precondition(DTD.Element el)
      Returns whether the contents are an undecorated choice of undecorated singletons, and thus are a candidate for an "abstract" Tdom class.
    • checkUpdated

      protected void checkUpdated()
    • update

      public void update(DTD.Dtd dtd, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg)
    • printOrdered

      public void printOrdered(PrintStream p)