Source Code Cross Referenced for FilterVisitorTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » filter » 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 » GIS » GeoTools 2.4.1 » org.geotools.filter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         *    Created on July 18, 2003, 7:13 PM
017:         */
018:
019:        package org.geotools.filter;
020:
021:        import org.geotools.filter.expression.AddImpl;
022:
023:        import junit.framework.Test;
024:        import junit.framework.TestCase;
025:        import junit.framework.TestSuite;
026:
027:        /**
028:         *
029:         * @author  jamesm
030:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/test/java/org/geotools/filter/FilterVisitorTest.java $
031:         */
032:        public class FilterVisitorTest extends TestCase implements 
033:                FilterVisitor {
034:            int checkcode;
035:
036:            public FilterVisitorTest(String testName) {
037:                super (testName);
038:            }
039:
040:            /** 
041:             * Main for test runner.
042:             */
043:            public static void main(String[] args) {
044:                org.geotools.util.logging.Logging.GEOTOOLS
045:                        .forceMonolineConsoleOutput();
046:                junit.textui.TestRunner.run(suite());
047:            }
048:
049:            /** 
050:             * Required suite builder.
051:             * @return A test suite for this unit test.
052:             */
053:            public static Test suite() {
054:
055:                TestSuite suite = new TestSuite(FilterVisitorTest.class);
056:                return suite;
057:            }
058:
059:            /**
060:             * This should never be called. This can only happen if a subclass of
061:             * AbstractFilter failes to implement its own version of
062:             * accept(FilterVisitor);
063:             *
064:             * @param filter The filter to visit
065:             */
066:            public void visit(Filter filter) {
067:                fail("should never end up here, overloaded method should have been called instead");
068:            }
069:
070:            public void visit(BetweenFilter filter) {
071:                DefaultExpression left = (DefaultExpression) filter
072:                        .getLeftValue();
073:                DefaultExpression right = (DefaultExpression) filter
074:                        .getRightValue();
075:                DefaultExpression mid = (DefaultExpression) filter
076:                        .getMiddleValue();
077:            }
078:
079:            public void visit(LikeFilter filter) {
080:
081:            }
082:
083:            /**
084:             * Writes the SQL for the Logic Filter.
085:             *
086:             * @param filter the logic statement to be turned into SQL.
087:             */
088:            public void visit(LogicFilter filter) {
089:
090:                java.util.Iterator list = filter.getFilterIterator();
091:
092:                if (filter.getFilterType() == AbstractFilter.LOGIC_NOT) {
093:
094:                    Filters.accept((org.opengis.filter.Filter) list.next(),
095:                            this );
096:
097:                } else { //AND or OR
098:
099:                    while (list.hasNext()) {
100:                        Filters.accept((org.opengis.filter.Filter) list.next(),
101:                                this );
102:                    }
103:
104:                }
105:
106:            }
107:
108:            public void visit(CompareFilter filter) {
109:
110:                DefaultExpression left = (DefaultExpression) filter
111:                        .getLeftValue();
112:                DefaultExpression right = (DefaultExpression) filter
113:                        .getRightValue();
114:
115:                left.accept(this );
116:
117:                right.accept(this );
118:
119:            }
120:
121:            public void visit(GeometryFilter filter) {
122:
123:            }
124:
125:            public void visit(NullFilter filter) {
126:
127:                DefaultExpression expr = (DefaultExpression) filter
128:                        .getNullCheckValue();
129:
130:                expr.accept(this );
131:
132:            }
133:
134:            public void visit(FidFilter filter) {
135:                checkcode = 9;
136:            }
137:
138:            public void visit(AttributeExpression expression) {
139:
140:            }
141:
142:            /**
143:             * Writes the SQL for the attribute Expression.
144:             *
145:             * @param expression the attribute to turn to SQL.
146:             */
147:            public void visit(Expression expression) {
148:
149:            }
150:
151:            public void visit(LiteralExpression expression) {
152:                checkcode += 1;
153:            }
154:
155:            public void visit(MathExpression expression) {
156:                checkcode += 3;
157:                ((DefaultExpression) expression.getLeftValue()).accept(this );
158:                ((DefaultExpression) expression.getRightValue()).accept(this );
159:            }
160:
161:            public void visit(FunctionExpression expression) {
162:                checkcode += 6;
163:            }
164:
165:            public void testVisitLiteral() {
166:                checkcode = 0;
167:                LiteralExpression exp = new LiteralExpressionImpl(4);
168:                exp.accept(this );
169:                assertEquals(checkcode, 1);
170:
171:            }
172:
173:            public void testVisitMathExpression() throws IllegalFilterException {
174:                checkcode = 0;
175:
176:                Expression testAttribute1 = new LiteralExpressionImpl(
177:                        new Integer(4));
178:                Expression testAttribute2 = new LiteralExpressionImpl(
179:                        new Integer(2));
180:
181:                // Test addition
182:                MathExpressionImpl mathTest = new AddImpl(null, null);
183:                mathTest.addLeftValue(testAttribute1);
184:                mathTest.addRightValue(testAttribute2);
185:
186:                mathTest.accept(this );
187:
188:                assertEquals(5, checkcode);
189:            }
190:
191:            public void testVisitFidFilter() throws IllegalFilterException {
192:                checkcode = 0;
193:                FidFilter ff = new FidFilterImpl();
194:                ff.accept(this );
195:                assertEquals(9, checkcode);
196:            }
197:
198:            public void testFunctionExpression() {
199:                checkcode = 0;
200:
201:                FunctionExpression min = FilterFactoryFinder
202:                        .createFilterFactory().createFunctionExpression("min");
203:                min.accept(this );
204:                assertEquals(6, checkcode);
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.