001: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
002: /*
003: * GeoTools - OpenSource mapping toolkit
004: * http://geotools.org
005: * (C) 2006, GeoTools Project Managment Committee (PMC)
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017:
018: package org.geotools.filter.text.cql2;
019:
020: class SimpleNode implements Node {
021: protected Node parent;
022: protected Node[] children;
023: protected int id;
024: protected CQLParser parser;
025: protected String value;
026: Token token;
027:
028: public SimpleNode(int i) {
029: id = i;
030: }
031:
032: public SimpleNode(CQLParser p, int i) {
033: this (i);
034: parser = p;
035: }
036:
037: public void jjtOpen() {
038: }
039:
040: public void jjtClose() {
041: }
042:
043: public void jjtSetParent(Node n) {
044: parent = n;
045: }
046:
047: public Node jjtGetParent() {
048: return parent;
049: }
050:
051: public void jjtAddChild(Node n, int i) {
052: if (children == null) {
053: children = new Node[i + 1];
054: } else if (i >= children.length) {
055: Node c[] = new Node[i + 1];
056: System.arraycopy(children, 0, c, 0, children.length);
057: children = c;
058: }
059: children[i] = n;
060: }
061:
062: public Node jjtGetChild(int i) {
063: return children[i];
064: }
065:
066: public int jjtGetNumChildren() {
067: return (children == null) ? 0 : children.length;
068: }
069:
070: /** Accept the visitor. **/
071: public Object jjtAccept(CQLParserVisitor visitor, Object obj) {
072: return visitor.visit(this , obj);
073: }
074:
075: /* You can override these two methods in subclasses of SimpleNode to
076: customize the way the node appears when the tree is dumped. If
077: your output uses more than one line you should override
078: toString(String), otherwise overriding toString() is probably all
079: you need to do. */
080:
081: public String toString() {
082: return CQLParserTreeConstants.jjtNodeName[id];
083: }
084:
085: public String toString(String prefix) {
086: return prefix + toString();
087: }
088:
089: /* Override this method if you want to customize how the node dumps
090: out its children. */
091:
092: public void dump(String prefix) {
093: System.out.println(toString(prefix));
094: if (children != null) {
095: for (int i = 0; i < children.length; ++i) {
096: SimpleNode n = (SimpleNode) children[i];
097: if (n != null) {
098: n.dump(prefix + " ");
099: }
100: }
101: }
102: }
103:
104: public int getType() {
105: return id;
106: }
107:
108: public void dispose() {
109: parent = null;
110: children = null;
111: parser = null;
112: }
113:
114: public Token getToken() {
115: return token;
116: }
117:
118: }
|