node.java

来自「精通tomcat书籍原代码,希望大家共同学习」· Java 代码 · 共 2,370 行 · 第 1/5 页

JAVA
2,370
字号
	public String getJspConfigPageEncoding() {
	    return jspConfigPageEnc;
	}

	public void setPageEncoding(String enc) {
	    pageEnc = enc;
	}

	public String getPageEncoding() {
	    return pageEnc;
	}

	public void setIsDefaultPageEncoding(boolean isDefault) {
	    isDefaultPageEncoding = isDefault;
	}

	public boolean isDefaultPageEncoding() {
	    return isDefaultPageEncoding;
	}
	
	public void setIsEncodingSpecifiedInProlog(boolean isSpecified) {
	    isEncodingSpecifiedInProlog = isSpecified;
	}

	public boolean isEncodingSpecifiedInProlog() {
	    return isEncodingSpecifiedInProlog;
	}

	/**
	 * @return The enclosing root to this Root. Usually represents the
	 * page that includes this one.
	 */
	public Root getParentRoot() {
	    return parentRoot;
	}
    }
    
    /**
     * Represents the root of a Jsp document (XML syntax)
     */
    public static class JspRoot extends Node {

	public JspRoot(String qName, Attributes attrs,
		       Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
		       Mark start, Node parent) {
	    super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
		  start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a page directive
     */
    public static class PageDirective extends Node {

	private Vector imports;

	public PageDirective(Attributes attrs, Mark start, Node parent) {
	    this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent);
	}

	public PageDirective(String qName, Attributes attrs,
			     Attributes nonTaglibXmlnsAttrs,
			     Attributes taglibAttrs, Mark start, Node parent) {
	    super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	    imports = new Vector();
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}

	/**
	 * Parses the comma-separated list of class or package names in the
	 * given attribute value and adds each component to this
	 * PageDirective's vector of imported classes and packages.
	 * @param value A comma-separated string of imports.
	 */
	public void addImport(String value) {
	    int start = 0;
	    int index;
	    while ((index = value.indexOf(',', start)) != -1) {
		imports.add(value.substring(start, index).trim());
		start = index + 1;
	    }
	    if (start == 0) {
		// No comma found
		imports.add(value.trim());
	    } else {
		imports.add(value.substring(start).trim());
	    }
	}

	public List getImports() {
	    return imports;
	}
    }

    /**
     * Represents an include directive
     */
    public static class IncludeDirective extends Node {

	public IncludeDirective(Attributes attrs, Mark start, Node parent) {
	    this(JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null, start,
		 parent);
	}

	public IncludeDirective(String qName, Attributes attrs,
				Attributes nonTaglibXmlnsAttrs,
				Attributes taglibAttrs, Mark start,
				Node parent) {
	    super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a custom taglib directive
     */
    public static class TaglibDirective extends Node {

	public TaglibDirective(Attributes attrs, Mark start, Node parent) {
	    super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs,
		  start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a tag directive
     */
    public static class TagDirective extends Node {
        private Vector imports;

	public TagDirective(Attributes attrs, Mark start, Node parent) {
	    this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent);
	}

	public TagDirective(String qName, Attributes attrs,
			    Attributes nonTaglibXmlnsAttrs,
			    Attributes taglibAttrs, Mark start, Node parent) {
	    super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
            imports = new Vector();
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
        }
 
        /**
         * Parses the comma-separated list of class or package names in the
         * given attribute value and adds each component to this
         * PageDirective's vector of imported classes and packages.
         * @param value A comma-separated string of imports.
         */
        public void addImport(String value) {
            int start = 0;
            int index;
            while ((index = value.indexOf(',', start)) != -1) {
                imports.add(value.substring(start, index).trim());
                start = index + 1;
            }
            if (start == 0) {
                // No comma found
                imports.add(value.trim());
            } else {
                imports.add(value.substring(start).trim());
            }
        }
 
        public List getImports() {
            return imports;
	}
    }

    /**
     * Represents an attribute directive
     */
    public static class AttributeDirective extends Node {

	public AttributeDirective(Attributes attrs, Mark start, Node parent) {
	    this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start,
		 parent);
	}

	public AttributeDirective(String qName, Attributes attrs,
				  Attributes nonTaglibXmlnsAttrs,
				  Attributes taglibAttrs, Mark start,
				  Node parent) {
	    super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs,
		  nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a variable directive
     */
    public static class VariableDirective extends Node {

	public VariableDirective(Attributes attrs, Mark start, Node parent) {
	    this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start,
		 parent);
	}

	public VariableDirective(String qName, Attributes attrs,
				 Attributes nonTaglibXmlnsAttrs,
				 Attributes taglibAttrs,
				 Mark start, Node parent) {
	    super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a <jsp:invoke> tag file action
     */
    public static class InvokeAction extends Node {

	public InvokeAction(Attributes attrs, Mark start, Node parent) {
	    this(JSP_INVOKE_ACTION, attrs, null, null, start, parent);
	}

	public InvokeAction(String qName, Attributes attrs,
			    Attributes nonTaglibXmlnsAttrs,
			    Attributes taglibAttrs, Mark start, Node parent) {
	    super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a <jsp:doBody> tag file action
     */
    public static class DoBodyAction extends Node {

	public DoBodyAction(Attributes attrs, Mark start, Node parent) {
	    this(JSP_DOBODY_ACTION, attrs, null, null, start, parent);
	}

	public DoBodyAction(String qName, Attributes attrs,
			    Attributes nonTaglibXmlnsAttrs,
			    Attributes taglibAttrs, Mark start, Node parent) {
	    super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a Jsp comment
     * Comments are kept for completeness.
     */
    public static class Comment extends Node {

	public Comment(String text, Mark start, Node parent) {
	    super(null, null, text, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents an expression, declaration, or scriptlet
     */
    public static abstract class ScriptingElement extends Node {

	public ScriptingElement(String qName, String localName, String text,
				Mark start, Node parent) {
	    super(qName, localName, text, start, parent);
	}

	public ScriptingElement(String qName, String localName,
				Attributes nonTaglibXmlnsAttrs,
				Attributes taglibAttrs, Mark start,
				Node parent) {
	    super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs,
		  start, parent);
	}

	/**
	 * When this node was created from a JSP page in JSP syntax, its text
	 * was stored as a String in the "text" field, whereas when this node
	 * was created from a JSP document, its text was stored as one or more
	 * TemplateText nodes in its body. This method handles either case.
	 * @return The text string
	 */
	public String getText() {
	    String ret = text;
	    if ((ret == null) && (body != null)) {
		StringBuffer buf = new StringBuffer();
		for (int i=0; i<body.size(); i++) {
		    buf.append(body.getNode(i).getText());
		}
		ret = buf.toString();
	    }
	    return ret;
	}

        /**
         * For the same reason as above, the source line information in the
         * contained TemplateText node should be used.
         */
        public Mark getStart() {
            if (text == null && body != null && body.size() > 0) {
                return body.getNode(0).getStart();
            } else {
                return super.getStart();
            }
        }
    }

    /**
     * Represents a declaration
     */
    public static class Declaration extends ScriptingElement {

	public Declaration(String text, Mark start, Node parent) {
	    super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start,
		  parent);
	}

	public Declaration(String qName, Attributes nonTaglibXmlnsAttrs,
			   Attributes taglibAttrs, Mark start,
			   Node parent) {
	    super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents an expression.  Expressions in attributes are embedded
     * in the attribute string and not here.
     */
    public static class Expression extends ScriptingElement {

	public Expression(String text, Mark start, Node parent) {
	    super(JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text, start,
		  parent);
	}

	public Expression(String qName, Attributes nonTaglibXmlnsAttrs,
			  Attributes taglibAttrs, Mark start,
			  Node parent) {
	    super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs,
		  start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents a scriptlet
     */
    public static class Scriptlet extends ScriptingElement {

	public Scriptlet(String text, Mark start, Node parent) {
	    super(JSP_SCRIPTLET_ACTION, SCRIPTLET_ACTION, text, start, parent);
	}

	public Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs,
			 Attributes taglibAttrs, Mark start,
			 Node parent) {
	    super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs,
		  start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}
    }

    /**
     * Represents an EL expression.  Expressions in attributes are embedded
     * in the attribute string and not here.
     */
    public static class ELExpression extends Node {

	private ELNode.Nodes el;

        public ELExpression(String text, Mark start, Node parent) {
            super(null, null, text, start, parent);
        }

        public void accept(Visitor v) throws JasperException {
            v.visit(this);
        }

	public void setEL(ELNode.Nodes el) {
	    this.el = el;
	}

	public ELNode.Nodes getEL() {
	    return el;
	}
    }

    /**
     * Represents a param action
     */
    public static class ParamAction extends Node {

	JspAttribute value;

	public ParamAction(Attributes attrs, Mark start, Node parent) {
	    this(JSP_PARAM_ACTION, attrs, null, null, start, parent);
	}

	public ParamAction(String qName, Attributes attrs,
			   Attributes nonTaglibXmlnsAttrs,
			   Attributes taglibAttrs, Mark start, Node parent) {
	    super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs,
		  taglibAttrs, start, parent);
	}

	public void accept(Visitor v) throws JasperException {
	    v.visit(this);
	}

	public void setValue(JspAttribute value) {
	    this.value = value;
	}

	public JspAttribute getValue() {
	    return value;
	}
    }

    /**
     * Represents a params action
     */
    public static class ParamsAction extends Node {

	public ParamsAction(Mark start, Node parent) {
	    this(JSP_PARAMS_ACTION, null, null, start, parent);
	}

	public ParamsAction(String qName,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?