Source Code Cross Referenced for TestFunctions.java in  » Library » Apache-commons-jxpath-1.2-src » org » apache » commons » jxpath » ri » compiler » 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 jxpath 1.2 src » org.apache.commons.jxpath.ri.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 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:        package org.apache.commons.jxpath.ri.compiler;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:
023:        import org.apache.commons.jxpath.BasicNodeSet;
024:        import org.apache.commons.jxpath.ExpressionContext;
025:        import org.apache.commons.jxpath.JXPathContext;
026:        import org.apache.commons.jxpath.NestedTestBean;
027:        import org.apache.commons.jxpath.Pointer;
028:        import org.apache.commons.jxpath.NodeSet;
029:
030:        /**
031:         * @author Dmitri Plotnikov
032:         * @version $Revision: 1.10 $ $Date: 2004/03/25 05:42:01 $
033:         */
034:        public class TestFunctions {
035:
036:            private int foo;
037:            private String bar;
038:
039:            public TestFunctions() {
040:            }
041:
042:            public TestFunctions(int foo, String bar) {
043:                this .foo = foo;
044:                this .bar = bar;
045:            }
046:
047:            public TestFunctions(ExpressionContext context, String bar) {
048:                this .foo = ((Number) context.getContextNodePointer().getValue())
049:                        .intValue();
050:                this .bar = bar;
051:            }
052:
053:            public TestFunctions(int foo, Object object, boolean another) {
054:                this .foo = foo;
055:                bar = String.valueOf(object);
056:            }
057:
058:            public int getFoo() {
059:                return foo;
060:            }
061:
062:            public String getBar() {
063:                return bar;
064:            }
065:
066:            public void doit() {
067:            }
068:
069:            public TestFunctions setFooAndBar(int foo, String bar) {
070:                this .foo = foo;
071:                this .bar = bar;
072:                return this ;
073:            }
074:
075:            public static TestFunctions build(int foo, String bar) {
076:                return new TestFunctions(foo, bar);
077:            }
078:
079:            public String toString() {
080:                return "foo=" + foo + "; bar=" + bar;
081:            }
082:
083:            public static String path(ExpressionContext context) {
084:                return context.getContextNodePointer().asPath();
085:            }
086:
087:            public String instancePath(ExpressionContext context) {
088:                return context.getContextNodePointer().asPath();
089:            }
090:
091:            public String pathWithSuffix(ExpressionContext context,
092:                    String suffix) {
093:                return context.getContextNodePointer().asPath() + suffix;
094:            }
095:
096:            public String className(ExpressionContext context,
097:                    ExpressionContext child) {
098:                return context.getContextNodePointer().asPath();
099:            }
100:
101:            /**
102:             * Returns true if the current node in the current context is a map
103:             */
104:            public static boolean isMap(ExpressionContext context) {
105:                Pointer ptr = context.getContextNodePointer();
106:                return ptr == null ? false : (ptr.getValue() instanceof  Map);
107:            }
108:
109:            /**
110:             * Returns the number of nodes in the context that is passed as
111:             * the first argument.
112:             */
113:            public static int count(ExpressionContext context, Collection col) {
114:                for (Iterator iter = col.iterator(); iter.hasNext();) {
115:                    Object element = iter.next();
116:                    if (!(element instanceof  String)) {
117:                        throw new RuntimeException("Invalid argument");
118:                    }
119:                }
120:                ;
121:                return col.size();
122:            }
123:
124:            public static int countPointers(NodeSet nodeSet) {
125:                return nodeSet.getPointers().size();
126:            }
127:
128:            public static String string(String string) {
129:                return string;
130:            }
131:
132:            public static Collection collection() {
133:                ArrayList list = new ArrayList();
134:                list.add(new NestedTestBean("foo"));
135:                list.add(new NestedTestBean("bar"));
136:                return list;
137:            }
138:
139:            public static NodeSet nodeSet(ExpressionContext context) {
140:                JXPathContext jxpathCtx = context.getJXPathContext();
141:                BasicNodeSet set = new BasicNodeSet();
142:                set.add(jxpathCtx.getPointer("/beans[1]"));
143:                set.add(jxpathCtx.getPointer("/beans[2]"));
144:
145:                return set;
146:            }
147:
148:            public static Collection items(Collection arg) {
149:                return arg;
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.