FileDocCategorySizeDatePackage
TagStack.javaAPI DocJava SE 5 API4620Fri Aug 26 14:58:20 BST 2005javax.swing.text.html.parser

TagStack

public final class TagStack extends Object implements DTDConstants
A stack of tags. Used while parsing an HTML document. It, together with the ContentModelStates, defines the complete state of the parser while reading a document. When a start tag is encountered an element is pushed onto the stack, when an end tag is enountered an element is popped of the stack.
see
Parser
see
DTD
see
ContentModelState
version
1.10, 12/19/03
author
Arthur van Hoff

Fields Summary
TagElement
tag
Element
elem
ContentModelState
state
TagStack
next
BitSet
inclusions
BitSet
exclusions
boolean
net
boolean
pre
Constructors Summary
TagStack(TagElement tag, TagStack next)
Construct a stack element.

	this.tag = tag;
	this.elem = tag.getElement();
	this.next = next;

	Element elem = tag.getElement();
	if (elem.getContent() != null) {
	    this.state = new ContentModelState(elem.getContent());
	}

	if (next != null) {
	    inclusions = next.inclusions;
	    exclusions = next.exclusions;
	    pre = next.pre;
	}
	if (tag.isPreformatted()) {
	    pre = true;
	}

	if (elem.inclusions != null) {
	    if (inclusions != null) {
		inclusions = (BitSet)inclusions.clone();
		inclusions.or(elem.inclusions);
	    } else {
		inclusions = elem.inclusions;
	    }
	}
	if (elem.exclusions != null) {
	    if (exclusions != null) {
		exclusions = (BitSet)exclusions.clone();
		exclusions.or(elem.exclusions);
	    } else {
		exclusions = elem.exclusions;
	    }
	}
    
Methods Summary
booleanadvance(javax.swing.text.html.parser.Element elem)
Advance the state by reducing the given element. Returns false if the element is not legal and the state is not advanced.

	if ((exclusions != null) && exclusions.get(elem.getIndex())) {
	    return false;
	}
	if (state != null) {
	    ContentModelState newState = state.advance(elem);
	    if (newState != null) {
		state = newState;
		return true;
	    }
	} else if (this.elem.getType() == ANY) {
	    return true;
	}
	return (inclusions != null) && inclusions.get(elem.getIndex());
    
public javax.swing.text.html.parser.ContentModelcontentModel()
Return the ContentModel that must be satisfied by what comes next in the input stream.

	if (state == null) {
	    return null;
	} else {
	    return state.getModel();
	}
    
booleanexcluded(int elemIndex)
Return true if the element that is contained at the index specified by the parameter is part of the exclusions specified in the DTD for the element currently on the TagStack.

	return (exclusions != null) && exclusions.get(elem.getIndex());
    
public javax.swing.text.html.parser.Elementfirst()
Return the element that must come next in the input stream.

	return (state != null) ? state.first() : null;
    
booleanincluded(java.util.Vector elemVec, javax.swing.text.html.parser.DTD dtd)
Update the Vector elemVec with all the elements that are part of the inclusions listed in DTD for the element currently on the TagStack.


	for (int i = 0 ; i < inclusions.size(); i++) {
	    if (inclusions.get(i)) {
		elemVec.addElement(dtd.getElement(i));
		System.out.println("Element add thru' inclusions: " + dtd.getElement(i).getName());
	    }
	}
	return (!elemVec.isEmpty());
    
booleanterminate()
Return true if the current state can be terminated.

	return (state == null) || state.terminate();
    
public java.lang.StringtoString()
Convert to a string.

	return (next == null) ?
	    "<" + tag.getElement().getName() + ">" :
	    next + " <" + tag.getElement().getName() + ">";