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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2004 TOPP - www.openplans.org
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; either
010:         *    version 2.1 of the License, or (at your option) any later version.
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:        package org.geotools.validation.attributes;
018:
019:        import org.geotools.feature.Feature;
020:        import org.geotools.feature.FeatureType;
021:        import org.geotools.validation.DefaultFeatureValidation;
022:        import org.geotools.validation.ValidationResults;
023:
024:        /**
025:         * RangeFeatureValidation validates that a number is within a given range.
026:         * 
027:         * <p>
028:         * RangeFeatureValidation is a quick and simple class the checks that the given
029:         * number resides within a given range.
030:         * </p>
031:         * 
032:         * <p>
033:         * Capabilities:
034:         * 
035:         * <ul>
036:         * <li>
037:         * Default max value is Integer.MAX_VALUE;
038:         * </li>
039:         * <li>
040:         * Default min value is Integer.MIN_VALUE;
041:         * </li>
042:         * <li>
043:         * If only one boundary of the range is set, only that boundary is checked.
044:         * </li>
045:         * <li>
046:         * The value of the integer is contained in the field specified by path.
047:         * </li>
048:         * </ul>
049:         * 
050:         * Example Use:
051:         * <pre><code>
052:         * RangeFeatureValidation x = new RangeFeatureValidation();
053:         * 
054:         * x.setMin(3);
055:         * x.setMax(5);
056:         * x.setName("id");
057:         * 
058:         * boolean result = x.validate(feature, featureType, results);
059:         * </code></pre>
060:         * </p>
061:         *
062:         * @author rgould, Refractions Research, Inc.
063:         * @author $Author: cholmesny $ (last modification)
064:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/attributes/RangeValidation.java $
065:         * @version $Id: RangeValidation.java 22266 2006-10-19 11:30:55Z acuster $
066:         */
067:        public class RangeValidation extends DefaultFeatureValidation {
068:            private int max = Integer.MAX_VALUE;
069:            private int min = Integer.MIN_VALUE;
070:            /** XPath expression used to specify attribute */
071:            private String attribute;
072:
073:            /**
074:             * RangeFeatureValidation constructor.
075:             * 
076:             * <p>
077:             * Description
078:             * </p>
079:             */
080:            public RangeValidation() {
081:                super ();
082:            }
083:
084:            /**
085:             * Override validate.
086:             * 
087:             * <p>
088:             * Description ...
089:             * </p>
090:             *
091:             * @param feature
092:             * @param type
093:             * @param results
094:             *
095:             *
096:             * @see org.geotools.validation.FeatureValidation#validate(org.geotools.feature.Feature,
097:             *      org.geotools.feature.FeatureType,
098:             *      org.geotools.validation.ValidationResults)
099:             */
100:            public boolean validate(Feature feature, FeatureType type,
101:                    ValidationResults results) {
102:                Object obj = feature.getAttribute(attribute);
103:
104:                if (obj == null) {
105:                    return true; // user can separately issue a nullzero test
106:                }
107:
108:                if (obj instanceof  Number) {
109:                    Number number = (Number) obj;
110:
111:                    if (number.intValue() < min) {
112:                        results.error(feature, attribute + " is less than "
113:                                + min);
114:                        return false;
115:                    }
116:
117:                    if (number.intValue() > max) {
118:                        results.error(feature, attribute + " is greater than "
119:                                + max);
120:                        return false;
121:                    }
122:                }
123:                return true;
124:            }
125:
126:            /**
127:             * Override getPriority.
128:             * 
129:             * <p>
130:             * Description ...
131:             * </p>
132:             *
133:             *
134:             * @see org.geotools.validation.Validation#getPriority()
135:             */
136:            public int getPriority() {
137:                return 0;
138:            }
139:
140:            /**
141:             * getMax purpose.
142:             * 
143:             * <p>
144:             * Description ...
145:             * </p>
146:             *
147:             */
148:            public int getMax() {
149:                return max;
150:            }
151:
152:            /**
153:             * getMin purpose.
154:             * 
155:             * <p>
156:             * Description ...
157:             * </p>
158:             *
159:             */
160:            public int getMin() {
161:                return min;
162:            }
163:
164:            /**
165:             * getPath purpose.
166:             * 
167:             * <p>
168:             * Description ...
169:             * </p>
170:             *
171:             * @task REVISIT: This wasn't compiling for me, as its parent sets
172:             * this as final.  If needed for some reason then fix it.  But it
173:             * looks like it should inherit ok... ch
174:             */
175:            //public String getName() {
176:            //    return name;
177:            //}
178:            /**
179:             * setMax purpose.
180:             * 
181:             * <p>
182:             * Description ...
183:             * </p>
184:             *
185:             * @param i
186:             */
187:            public void setMax(int i) {
188:                max = i;
189:            }
190:
191:            /**
192:             * setMin purpose.
193:             * 
194:             * <p>
195:             * Description ...
196:             * </p>
197:             *
198:             * @param i
199:             */
200:            public void setMin(int i) {
201:                min = i;
202:            }
203:
204:            /**
205:             * setPath purpose.
206:             * 
207:             * <p>
208:             * Description ...
209:             * </p>
210:             *
211:             * @param string
212:             * see note on getName - ch.
213:             */
214:            //public void setName(String string) {
215:            //    name = string;
216:            //}
217:            /**
218:             * XPATH expression used to locate attribute
219:             * @return xpath
220:             */
221:            public String getAttribute() {
222:                return attribute;
223:            }
224:
225:            /**
226:             * XPATH expression used to locate attribute
227:             * @param xpath
228:             */
229:            public void setAttribute(String xpath) {
230:                attribute = xpath;
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.