javax.swing.text.html.parser

Class ContentModel

public final class ContentModel extends Object implements Serializable

A representation of the element content. The instances of this class can be arranged into the linked list, representing a BNF expression. The content model is constructed as a branched tree structure in the following way:
 a = new ContentModel('+', A, null); // a reprensents A+
 b = new ContentModel('&', B, a); // b represents B & A+
 c = new ContentModel('*', b, null); // c represents ( B & A+) *
 d = new ContentModel('|', new ContentModel('*', A, null),
          new ContentModel('?', B, null)); // d represents ( A* | B? )
 
where the valid operations are:
Field Summary
Objectcontent
The document content, containing either Element or the enclosed content model (that would be in the parentheses in BNF expression).
ContentModelnext
The next content model model ( = pointer to the next element of the linked list) for the binary expression (',','&' or '|').
inttype
Specifies the BNF operation between this node and the node, stored in the field next (or for this node, if it is an unary operation.
Constructor Summary
ContentModel()
Create a content model initializing all fields to default values.
ContentModel(Element a_content)
Create a content model, consisting of the single element.
ContentModel(int a_type, ContentModel a_content)
Create a content model, involving expression of the given type.
ContentModel(int a_type, Object a_content, ContentModel a_next)
Create a content model, involving binary expression of the given type.
Method Summary
booleanempty()
Checks if the content model matches an empty input stream.
Elementfirst()
Get the element, stored in the next.content.
booleanfirst(Object token)
Checks if this object can potentially be the first token in the ContenModel list.
voidgetElements(Vector<Element> elements)
Adds all list elements to the given vector, ignoring the operations between the elements.
StringtoString()
Returns a string representation (an expression) of this content model.

Field Detail

content

public Object content
The document content, containing either Element or the enclosed content model (that would be in the parentheses in BNF expression).

public ContentModel next
The next content model model ( = pointer to the next element of the linked list) for the binary expression (',','&' or '|'). Null for the last element in the list.

type

public int type
Specifies the BNF operation between this node and the node, stored in the field next (or for this node, if it is an unary operation.

Constructor Detail

ContentModel

public ContentModel()
Create a content model initializing all fields to default values.

ContentModel

public ContentModel(Element a_content)
Create a content model, consisting of the single element. Examples: a = new ContentModel('+', A, null); // a reprensents A+ b = new ContentModel('&', B, a); // b represents B & A+ c = new ContentModel('*', b, null); // c represents ( B & A+) * d = new ContentModel('|', A, new ContentModel('?',b, null); // d represents

ContentModel

public ContentModel(int a_type, ContentModel a_content)
Create a content model, involving expression of the given type.

Parameters: a_type The expression operation type ('*','?' or '+' a_content The content for that the expression is applied.

ContentModel

public ContentModel(int a_type, Object a_content, ContentModel a_next)
Create a content model, involving binary expression of the given type.

Parameters: a_type The expression operation type ( ',', '|' or '&'). a_content The content of the left part of the expression. a_next The content model, representing the right part of the expression.

Method Detail

empty

public boolean empty()
Checks if the content model matches an empty input stream. The empty content is created using SGML DTD keyword EMPTY. The empty model is a model with the content field equal to null.

Returns: true if the content field is equal to null.

first

public Element first()
Get the element, stored in the next.content. The method is programmed as the part of the standard API, but not used in this implementation.

Returns: the value of the field next.

first

public boolean first(Object token)
Checks if this object can potentially be the first token in the ContenModel list. The method is programmed as the part of the standard API, but not used in this implementation.

getElements

public void getElements(Vector<Element> elements)
Adds all list elements to the given vector, ignoring the operations between the elements. The old vector values are not discarded.

Parameters: elements - a vector to add the values to.

toString

public String toString()
Returns a string representation (an expression) of this content model. The expression has BNF-like syntax, except the absence of the unary operator is additionally indicated by " ' ". It is advisable to check the created models for correctness using this method.