Source Code Cross Referenced for SimpleNode.java in  » Library » Apache-commons-jexl-1.1-src » org » apache » commons » jexl » parser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons jexl 1.1 src » org.apache.commons.jexl.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.commons.jexl.parser;
018:
019:        import org.apache.commons.jexl.JexlContext;
020:
021:        /**
022:         * A Useful implementation of {@link Node}. Mostly autogenerated by javacc
023:         * 
024:         * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
025:         * @version $Id: SimpleNode.java 398328 2006-04-30 12:46:59Z dion $
026:         */
027:        public class SimpleNode implements  Node {
028:            /** parent node. */
029:            protected Node parent;
030:
031:            /** children of this node. */
032:            protected Node[] children;
033:
034:            /** id of the node. */
035:            protected int id;
036:
037:            /** parser that created the node. */
038:            protected Parser parser;
039:
040:            /**
041:             * Create the node given an id.
042:             * 
043:             * @param i node id.
044:             */
045:            public SimpleNode(int i) {
046:                id = i;
047:            }
048:
049:            /**
050:             * Create a node with the given parser and id.
051:             * 
052:             * @param p a parser.
053:             * @param i node id.
054:             */
055:            public SimpleNode(Parser p, int i) {
056:                this (i);
057:                parser = p;
058:            }
059:
060:            /**
061:             * Start of the node.
062:             */
063:            public void jjtOpen() {
064:            }
065:
066:            /**
067:             * End of the node.
068:             */
069:            public void jjtClose() {
070:            }
071:
072:            /** {@inheritDoc} */
073:            public void jjtSetParent(Node n) {
074:                parent = n;
075:            }
076:
077:            /** {@inheritDoc} */
078:            public Node jjtGetParent() {
079:                return parent;
080:            }
081:
082:            /** {@inheritDoc} */
083:            public void jjtAddChild(Node n, int i) {
084:                if (children == null) {
085:                    children = new Node[i + 1];
086:                } else if (i >= children.length) {
087:                    Node[] c = new Node[i + 1];
088:                    System.arraycopy(children, 0, c, 0, children.length);
089:                    children = c;
090:                }
091:
092:                children[i] = n;
093:            }
094:
095:            /** {@inheritDoc} */
096:            public Node jjtGetChild(int i) {
097:                return children[i];
098:            }
099:
100:            /** {@inheritDoc} */
101:            public int jjtGetNumChildren() {
102:                return (children == null) ? 0 : children.length;
103:            }
104:
105:            /**
106:             * Accept the visitor.
107:             * 
108:             * @param visitor a {@link ParserVisitor}.
109:             * @param data data to be passed along to the visitor.
110:             * @return the value from visiting.
111:             * @see ParserVisitor#visit
112:             */
113:            public Object jjtAccept(ParserVisitor visitor, Object data) {
114:                return visitor.visit(this , data);
115:            }
116:
117:            /**
118:             * Visit all children.
119:             * 
120:             * @param visitor a {@link ParserVisitor}.
121:             * @param data data to be passed along to the visitor.
122:             * @return the value from visiting.
123:             * @see ParserVisitor#visit
124:             */
125:            public Object childrenAccept(ParserVisitor visitor, Object data) {
126:                if (children != null) {
127:                    for (int i = 0; i < children.length; ++i) {
128:                        children[i].jjtAccept(visitor, data);
129:                    }
130:                }
131:                return data;
132:            }
133:
134:            /**
135:             * Gets a string representation of the node.
136:             * @return the node name.
137:             */
138:            public String toString() {
139:                return ParserTreeConstants.jjtNodeName[id];
140:            }
141:
142:            /**
143:             * Used during dumping to output the node with a prefix.
144:             * @param prefix text to prefix {@link #toString()}
145:             * @return text.
146:             */
147:            public String toString(String prefix) {
148:                return prefix + toString();
149:            }
150:
151:            /**
152:             * Dump the node and all children.
153:             * @param prefix text to prefix the node output.
154:             */
155:            public void dump(String prefix) {
156:                System.out.println(toString(prefix));
157:
158:                if (children != null) {
159:                    for (int i = 0; i < children.length; ++i) {
160:                        SimpleNode n = (SimpleNode) children[i];
161:
162:                        if (n != null) {
163:                            n.dump(prefix + " ");
164:                        }
165:                    }
166:                }
167:            }
168:
169:            /**
170:             * basic interpret - just invoke interpret on all children.
171:             * @param pc the {@link JexlContext context} to interpret against.
172:             * @return true if interpretation worked.
173:             * @throws Exception on any error.
174:             */
175:            public boolean interpret(JexlContext pc) throws Exception {
176:                for (int i = 0; i < jjtGetNumChildren(); i++) {
177:                    SimpleNode node = (SimpleNode) jjtGetChild(i);
178:                    if (!node.interpret(pc)) {
179:                        return false;
180:                    }
181:                }
182:
183:                return true;
184:            }
185:
186:            /**
187:             * Gets the value of this node.
188:             * 
189:             * @param context the context to retrieve values from.
190:             * @return the value of the node.
191:             * @throws Exception when evaluating the operands fails.
192:             */
193:            public Object value(JexlContext context) throws Exception {
194:                return null;
195:            }
196:
197:            /**
198:             * Sets the value for the node - again, only makes sense for some nodes but
199:             * lazyness tempts me to put it here. Keeps things simple.
200:             * 
201:             * @param context the context to retrieve values from.
202:             * @param value the value.
203:             * @return the result.
204:             * @throws Exception when evaluating the operands fails.
205:             */
206:            public Object setValue(JexlContext context, Object value)
207:                    throws Exception {
208:                return null;
209:            }
210:
211:            /**
212:             * Used to let a node calcuate it's value..
213:             * @param o the object to calculate with.
214:             * @param ctx the context to retrieve values from.
215:             * @throws Exception when calculating the value fails.
216:             * @return the result of the calculation.
217:             */
218:            public Object execute(Object o, JexlContext ctx) throws Exception {
219:                return null;
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.