|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectDTDDoc.DTDCommenter.NameInfo
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 |
public final com.wutka.dtd.DTDName name
public final java.util.Set contexts
| Constructor Detail |
public DTDCommenter.NameInfo(com.wutka.dtd.DTDName name,
java.lang.String context)
| Method Detail |
public java.lang.String getName()
public void addContext(java.lang.String context)
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 | ? | + | * | | | , | |
| 1 | 1 | ? | + | * | ? | 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).
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||