FileDocCategorySizeDatePackage
Node.javaAPI DocApache Tomcat 6.0.1477527Fri Jul 20 04:20:30 BST 2007org.apache.jasper.compiler

Node

public abstract class Node extends Object implements TagConstants
An internal data representation of a JSP page or a JSP docuement (XML). Also included here is a visitor class for tranversing nodes.
author
Kin-man Chung
author
Jan Luehe
author
Shawn Bayern
author
Mark Roth

Fields Summary
private static final javax.servlet.jsp.tagext.VariableInfo[]
ZERO_VARIABLE_INFO
protected Attributes
attrs
protected Attributes
taglibAttrs
protected Attributes
nonTaglibXmlnsAttrs
protected Nodes
body
protected String
text
protected Mark
startMark
protected int
beginJavaLine
protected int
endJavaLine
protected Node
parent
protected Nodes
namedAttributeNodes
protected String
qName
protected String
localName
protected String
innerClassName
private boolean
isDummy
Constructors Summary
public Node()
Zero-arg Constructor.


           
      
        this.isDummy = true;
    
public Node(Mark start, Node parent)
Constructor.

param
start The location of the jsp page
param
parent The enclosing node

        this.startMark = start;
        this.isDummy = (start == null);
        addToParent(parent);
    
public Node(String qName, String localName, Mark start, Node parent)
Constructor.

param
qName The action's qualified name
param
localName The action's local name
param
start The location of the jsp page
param
parent The enclosing node

        this.qName = qName;
        this.localName = localName;
        this.startMark = start;
        this.isDummy = (start == null);
        addToParent(parent);
    
public Node(String qName, String localName, Attributes attrs, Mark start, Node parent)
Constructor for Nodes parsed from standard syntax.

param
qName The action's qualified name
param
localName The action's local name
param
attrs The attributes for this node
param
start The location of the jsp page
param
parent The enclosing node

        this.qName = qName;
        this.localName = localName;
        this.attrs = attrs;
        this.startMark = start;
        this.isDummy = (start == null);
        addToParent(parent);
    
public Node(String qName, String localName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent)
Constructor for Nodes parsed from XML syntax.

param
qName The action's qualified name
param
localName The action's local name
param
attrs The action's attributes whose name does not start with xmlns
param
nonTaglibXmlnsAttrs The action's xmlns attributes that do not represent tag libraries
param
taglibAttrs The action's xmlns attributes that represent tag libraries
param
start The location of the jsp page
param
parent The enclosing node

        this.qName = qName;
        this.localName = localName;
        this.attrs = attrs;
        this.nonTaglibXmlnsAttrs = nonTaglibXmlnsAttrs;
        this.taglibAttrs = taglibAttrs;
        this.startMark = start;
        this.isDummy = (start == null);
        addToParent(parent);
    
public Node(String qName, String localName, String text, Mark start, Node parent)

        this.qName = qName;
        this.localName = localName;
        this.text = text;
        this.startMark = start;
        this.isDummy = (start == null);
        addToParent(parent);
    
Methods Summary
abstract voidaccept(org.apache.jasper.compiler.Node$Visitor v)
Selects and invokes a method in the visitor class based on the node type. This is abstract and should be overrode by the extending classes.

param
v The visitor class

private voidaddToParent(org.apache.jasper.compiler.Node parent)

        if (parent != null) {
            this.parent = parent;
            Nodes parentBody = parent.getBody();
            if (parentBody == null) {
                parentBody = new Nodes();
                parent.setBody(parentBody);
            }
            parentBody.add(this);
        }
    
public java.lang.StringgetAttributeValue(java.lang.String name)

        return (attrs == null) ? null : attrs.getValue(name);
    
public org.xml.sax.AttributesgetAttributes()

        return this.attrs;
    
public intgetBeginJavaLine()

        return beginJavaLine;
    
public org.apache.jasper.compiler.Node$NodesgetBody()

        return body;
    
public intgetEndJavaLine()

        return endJavaLine;
    
public java.lang.StringgetInnerClassName()

        return innerClassName;
    
public java.lang.StringgetLocalName()

        return this.localName;
    
public org.apache.jasper.compiler.Node$NamedAttributegetNamedAttributeNode(java.lang.String name)
Searches all subnodes of this node for jsp:attribute standard actions with the given name, and returns the NamedAttribute node of the matching named attribute, nor null if no such node is found.

This should always be called and only be called for nodes that accept dynamic runtime attribute expressions.

        NamedAttribute result = null;

        // Look for the attribute in NamedAttribute children
        Nodes nodes = getNamedAttributeNodes();
        int numChildNodes = nodes.size();
        for (int i = 0; i < numChildNodes; i++) {
            NamedAttribute na = (NamedAttribute) nodes.getNode(i);
            boolean found = false;
            int index = name.indexOf(':");
            if (index != -1) {
                // qualified name
                found = na.getName().equals(name);
            } else {
                found = na.getLocalName().equals(name);
            }
            if (found) {
                result = na;
                break;
            }
        }

        return result;
    
public org.apache.jasper.compiler.Node$NodesgetNamedAttributeNodes()
Searches all subnodes of this node for jsp:attribute standard actions, and returns that set of nodes as a Node.Nodes object.

return
Possibly empty Node.Nodes object containing any jsp:attribute subnodes of this Node


        if (namedAttributeNodes != null) {
            return namedAttributeNodes;
        }

        Node.Nodes result = new Node.Nodes();

        // Look for the attribute in NamedAttribute children
        Nodes nodes = getBody();
        if (nodes != null) {
            int numChildNodes = nodes.size();
            for (int i = 0; i < numChildNodes; i++) {
                Node n = nodes.getNode(i);
                if (n instanceof NamedAttribute) {
                    result.add(n);
                } else if (!(n instanceof Comment)) {
                    // Nothing can come before jsp:attribute, and only
                    // jsp:body can come after it.
                    break;
                }
            }
        }

        namedAttributeNodes = result;
        return result;
    
public org.xml.sax.AttributesgetNonTaglibXmlnsAttributes()

        return this.nonTaglibXmlnsAttrs;
    
public org.apache.jasper.compiler.NodegetParent()

        return parent;
    
public java.lang.StringgetQName()

        return this.qName;
    
public org.apache.jasper.compiler.Node$RootgetRoot()

        Node n = this;
        while (!(n instanceof Node.Root)) {
            n = n.getParent();
        }
        return (Node.Root) n;
    
public MarkgetStart()

        return startMark;
    
public org.xml.sax.AttributesgetTaglibAttributes()

        return this.taglibAttrs;
    
public java.lang.StringgetText()

        return text;
    
public java.lang.StringgetTextAttribute(java.lang.String name)
Get the attribute that is non request time expression, either from the attribute of the node, or from a jsp:attrbute


        String attr = getAttributeValue(name);
        if (attr != null) {
            return attr;
        }

        NamedAttribute namedAttribute = getNamedAttributeNode(name);
        if (namedAttribute == null) {
            return null;
        }

        return namedAttribute.getText();
    
public booleanisDummy()

        return isDummy;
    
public voidsetAttributes(org.xml.sax.Attributes attrs)

        this.attrs = attrs;
    
public voidsetBeginJavaLine(int begin)

        beginJavaLine = begin;
    
public voidsetBody(org.apache.jasper.compiler.Node$Nodes body)

        this.body = body;
    
public voidsetEndJavaLine(int end)

        endJavaLine = end;
    
public voidsetInnerClassName(java.lang.String icn)

        innerClassName = icn;