org.apache.crimson.parser
Class ContentModel

java.lang.Object
  extended byorg.apache.crimson.parser.ContentModel

final class ContentModel
extends Object

A representation of a "children" content model. These are basically a regular expression; other content models are simpler. There is an SGML compatibility restriction on DTDs that such content models be deterministic, which in this sense just means that backtracking isn't needed to validate against it.

At the moment, for expediency, nondeterministic models are neither tested for nor are they handled reasonably. This could be done after each element's content model is fully parsed.

The most efficient way to do this would be to compile each content model pattern into a deterministic finite automaton (no stack) and just walk the DFA's graph ... but for now, these aren't compiled.

Author:
Arthur van Hoff, David Brownell

Field Summary
private  SimpleHashtable cache
           
 Object content
          The content.
 ContentModel next
          The next content model (in a ',' or '|' connective expression).
 char type
          Type.
 
Constructor Summary
ContentModel(char type, ContentModel content)
          Create a content model of a particular type.
ContentModel(String element)
          Create a content model for an element.
 
Method Summary
 boolean empty()
          Return true if the content model could match an empty input stream.
 boolean first(String token)
          Return true if the token could potentially be the first token in the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public char type
Type. Either '*', '?', '+'; or connectives ',', '|'; or zero for content that's an element.


content

public Object content
The content. Either an Element name, or a ContentModel.


next

public ContentModel next
The next content model (in a ',' or '|' connective expression). "next" has a list of connectives of the same type.


cache

private SimpleHashtable cache
Constructor Detail

ContentModel

public ContentModel(String element)
Create a content model for an element.


ContentModel

public ContentModel(char type,
                    ContentModel content)
Create a content model of a particular type. Normally used to specify a frequency, or to start a connective.

Method Detail

empty

public boolean empty()
Return true if the content model could match an empty input stream.


first

public boolean first(String token)
Return true if the token could potentially be the first token in the input stream.