javax.swing.text.html.parser

Class ContentModel

Implemented Interfaces:
Serializable

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:
See Also:
Serialized Form

Field Summary

Object
content
The document content, containing either Element or the enclosed content model (that would be in the parentheses in BNF expression).
ContentModel
next
The next content model model ( = pointer to the next element of the linked list) for the binary expression (',','&' or '|').
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 Summary

ContentModel()
Create a content model initializing all fields to default values.
ContentModel(int a_type, Object a_content, ContentModel a_next)
Create a content model, involving binary expression of the given type.
ContentModel(int a_type, ContentModel a_content)
Create a content model, involving expression of the given type.
ContentModel(Element a_content)
Create a content model, consisting of the single element.

Method Summary

boolean
empty()
Checks if the content model matches an empty input stream.
Element
first()
Get the element, stored in the next.content.
boolean
first(Object token)
Checks if this object can potentially be the first token in the ContenModel list.
void
getElements(Vector elements)
Adds all list elements to the given vector, ignoring the operations between the elements.
String
toString()
Returns a string representation (an expression) of this content model.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

content

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

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 Details

ContentModel

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

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.

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(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

Method Details

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 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.
Overrides:
toString in interface Object

ContentModel.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.