Source Code Cross Referenced for TestProvider.java in  » Template-Engine » Velocity » org » apache » velocity » test » provider » 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 » Template Engine » Velocity » org.apache.velocity.test.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.velocity.test.provider;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.    
020:         */
021:
022:        import java.util.ArrayList;
023:        import java.util.Hashtable;
024:        import java.util.List;
025:        import java.util.Stack;
026:        import java.util.Vector;
027:
028:        /**
029:         * This class is used by the testbed. Instances of the class
030:         * are fed into the context that is set before the AST
031:         * is traversed and dynamic content generated.
032:         *
033:         * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
034:         * @version $Id: TestProvider.java 463298 2006-10-12 16:10:32Z henning $
035:         */
036:        public class TestProvider {
037:            String title = "lunatic";
038:            boolean state;
039:            Object ob = null;
040:
041:            public static String PUB_STAT_STRING = "Public Static String";
042:
043:            int stateint = 0;
044:
045:            public String getName() {
046:                return "jason";
047:            }
048:
049:            public Stack getStack() {
050:                Stack stack = new Stack();
051:                stack.push("stack element 1");
052:                stack.push("stack element 2");
053:                stack.push("stack element 3");
054:                return stack;
055:            }
056:
057:            public List getEmptyList() {
058:                List list = new ArrayList();
059:                return list;
060:            }
061:
062:            public List getList() {
063:                List list = new ArrayList();
064:                list.add("list element 1");
065:                list.add("list element 2");
066:                list.add("list element 3");
067:
068:                return list;
069:            }
070:
071:            public Hashtable getSearch() {
072:                Hashtable h = new Hashtable();
073:                h.put("Text", "this is some text");
074:                h.put("EscText", "this is escaped text");
075:                h.put("Title", "this is the title");
076:                h.put("Index", "this is the index");
077:                h.put("URL", "http://periapt.com");
078:
079:                ArrayList al = new ArrayList();
080:                al.add(h);
081:
082:                h.put("RelatedLinks", al);
083:
084:                return h;
085:            }
086:
087:            public Hashtable getHashtable() {
088:                Hashtable h = new Hashtable();
089:                h.put("key0", "value0");
090:                h.put("key1", "value1");
091:                h.put("key2", "value2");
092:
093:                return h;
094:            }
095:
096:            public ArrayList getRelSearches() {
097:                ArrayList al = new ArrayList();
098:                al.add(getSearch());
099:
100:                return al;
101:            }
102:
103:            public String getTitle() {
104:                return title;
105:            }
106:
107:            public void setTitle(String title) {
108:                this .title = title;
109:            }
110:
111:            public Object[] getMenu() {
112:                //ArrayList al = new ArrayList();
113:                Object[] menu = new Object[3];
114:                for (int i = 0; i < 3; i++) {
115:                    Hashtable item = new Hashtable();
116:                    item.put("id", "item" + Integer.toString(i + 1));
117:                    item.put("name", "name" + Integer.toString(i + 1));
118:                    item.put("label", "label" + Integer.toString(i + 1));
119:                    //al.add(item);
120:                    menu[i] = item;
121:                }
122:
123:                //return al;
124:                return menu;
125:            }
126:
127:            public ArrayList getCustomers() {
128:                ArrayList list = new ArrayList();
129:
130:                list.add("ArrayList element 1");
131:                list.add("ArrayList element 2");
132:                list.add("ArrayList element 3");
133:                list.add("ArrayList element 4");
134:
135:                return list;
136:            }
137:
138:            public ArrayList getCustomers2() {
139:                ArrayList list = new ArrayList();
140:
141:                list.add(new TestProvider());
142:                list.add(new TestProvider());
143:                list.add(new TestProvider());
144:                list.add(new TestProvider());
145:
146:                return list;
147:            }
148:
149:            public Object me() {
150:                return this ;
151:            }
152:
153:            public String toString() {
154:                return ("test provider");
155:            }
156:
157:            public Vector getVector() {
158:                Vector list = new Vector();
159:
160:                list.addElement("vector element 1");
161:                list.addElement("vector element 2");
162:
163:                return list;
164:            }
165:
166:            public String[] getArray() {
167:                String[] strings = new String[2];
168:                strings[0] = "first element";
169:                strings[1] = "second element";
170:                return strings;
171:            }
172:
173:            public boolean theAPLRules() {
174:                return true;
175:            }
176:
177:            public boolean getStateTrue() {
178:                return true;
179:            }
180:
181:            public boolean getStateFalse() {
182:                return false;
183:            }
184:
185:            public String objectArrayMethod(Object[] o) {
186:                return "result of objectArrayMethod";
187:            }
188:
189:            public String concat(Object[] strings) {
190:                StringBuffer result = new StringBuffer();
191:
192:                for (int i = 0; i < strings.length; i++) {
193:                    result.append((String) strings[i]).append(' ');
194:                }
195:
196:                return result.toString();
197:            }
198:
199:            public String concat(List strings) {
200:                StringBuffer result = new StringBuffer();
201:
202:                for (int i = 0; i < strings.size(); i++) {
203:                    result.append((String) strings.get(i)).append(' ');
204:                }
205:
206:                return result.toString();
207:            }
208:
209:            public String objConcat(List objects) {
210:                StringBuffer result = new StringBuffer();
211:
212:                for (int i = 0; i < objects.size(); i++) {
213:                    result.append(objects.get(i)).append(' ');
214:                }
215:
216:                return result.toString();
217:            }
218:
219:            public String parse(String a, Object o, String c, String d) {
220:                return a + o.toString() + c + d;
221:            }
222:
223:            public String concat(String a, String b) {
224:                return a + b;
225:            }
226:
227:            // These two are for testing subclasses.
228:
229:            public Person getPerson() {
230:                return new Person();
231:            }
232:
233:            public Child getChild() {
234:                return new Child();
235:            }
236:
237:            public String showPerson(Person person) {
238:                return person.getName();
239:            }
240:
241:            /**
242:             * Chop i characters off the end of a string.
243:             *
244:             * @param string String to chop.
245:             * @param i Number of characters to chop.
246:             * @return String with processed answer.
247:             */
248:            public String chop(String string, int i) {
249:                return (string.substring(0, string.length() - i));
250:            }
251:
252:            public boolean allEmpty(Object[] list) {
253:                int size = list.length;
254:
255:                for (int i = 0; i < size; i++)
256:                    if (list[i].toString().length() > 0)
257:                        return false;
258:
259:                return true;
260:            }
261:
262:            /*
263:             * This can't have the signature
264:             *
265:             *    public void setState(boolean state)
266:             *
267:             *    or dynamically invoking the method
268:             *    doesn't work ... you would have to
269:             *    put a wrapper around a method for a
270:             *    real boolean property that takes a
271:             *    Boolean object if you wanted this to
272:             *    work. Not really sure how useful it
273:             *    is anyway. Who cares about boolean
274:             *    values you can just set a variable.
275:             *
276:             */
277:
278:            public void setState(Boolean state) {
279:            }
280:
281:            public void setBangStart(Integer i) {
282:                System.out.println("SetBangStart() : called with val = " + i);
283:                stateint = i.intValue();
284:            }
285:
286:            public Integer bang() {
287:                System.out.println("Bang! : " + stateint);
288:                Integer ret = new Integer(stateint);
289:                stateint++;
290:                return ret;
291:            }
292:
293:            /**
294:             * Test the ability of vel to use a get(key)
295:             * method for any object type, not just one
296:             * that implements the Map interface.
297:             */
298:            public String get(String key) {
299:                return key;
300:            }
301:
302:            /**
303:             * Test the ability of vel to use a put(key)
304:             * method for any object type, not just one
305:             * that implements the Map interface.
306:             */
307:            public String put(String key, Object o) {
308:                ob = o;
309:                return key;
310:            }
311:
312:            public String getFoo() throws Exception {
313:                throw new Exception("From getFoo()");
314:            }
315:
316:            public String getThrow() throws Exception {
317:                throw new Exception("From getThrow()");
318:            }
319:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.