DTDDoc
Class DTDCommenter.NameInfo

java.lang.Object
  extended byDTDDoc.DTDCommenter.NameInfo
All Implemented Interfaces:
java.lang.Comparable
Enclosing class:
DTDCommenter

class DTDCommenter.NameInfo
extends java.lang.Object
implements java.lang.Comparable

This class encapsulates the context related to a DTDName. In this particular case, the DTDName is expected to represent a child of an element in the element model.

A context describes the cardinality modifiers that are applying to the name. For example if an element model is (alpha | beta)* then the context is described by both the star and the vertical bar. The star states that the cardinality is "zero or many" and the vertical bar states that alpha or beta might appear, therefore the cardinalities of alpha and beta are the same, that is "one at most".


Field Summary
 java.util.Set contexts
           
 com.wutka.dtd.DTDName name
           
 
Constructor Summary
DTDCommenter.NameInfo(com.wutka.dtd.DTDName name, java.lang.String context)
           
 
Method Summary
 void addContext(java.lang.String context)
           
 int compareTo(java.lang.Object o)
           
 java.lang.String getCardinality()
          This method establishes the overall cardinality of a child of an element.
 java.lang.String getName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public final com.wutka.dtd.DTDName name

contexts

public final java.util.Set contexts
Constructor Detail

DTDCommenter.NameInfo

public DTDCommenter.NameInfo(com.wutka.dtd.DTDName name,
                             java.lang.String context)
Method Detail

getName

public java.lang.String getName()

addContext

public void addContext(java.lang.String context)

getCardinality

public java.lang.String getCardinality()

This method establishes the overall cardinality of a child of an element. The necessary information is taken from the context field.

The basic principle is to "reduce" the context element by element, starting at the end of the context. After each reduction we have the overall cardinality of the child in respect to the part of context that was processed so far.

The reduction opeartion consists in comparing the current cardinality with the "current" one in the context. Those two cardinalities are used as selector in a two dimensional table that will give the new overall cardinality for the context explored so far (thus the previous one extended by the "current" cardinality). The table is like this:

1?+*|,
11?+*?1
???**??
++*+**+
*******
|??**||
,1?+*|,

Some side notes here:

This method for finding cardinality gives good results in most cases and gives correct but hardly usable results for complicated cases (those where a children is deeply nested in cardinality modifiers).

Returns:
A string stating the cardinality, ready to be displayed.

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable


Copyright © 2002-2007 DTDDoc. All Rights Reserved.