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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-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;
009:         *    version 2.1 of the License.
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:        package org.geotools.feature.visitor;
017:
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:        import java.util.Collection;
021:        import java.util.HashSet;
022:        import java.util.List;
023:        import java.util.Map;
024:        import java.util.Set;
025:
026:        import com.vividsolutions.jts.geom.Envelope;
027:        import com.vividsolutions.jts.geom.Geometry;
028:        import com.vividsolutions.jts.geom.Point;
029:
030:        /**
031:         * An abstract implementation for CalcResults. Each subclass should implement
032:         * its own getValue(), merge(), and constructor methods.
033:         * 
034:         * @author Cory Horner, Refractions
035:         * 
036:         * @since 2.2.M2
037:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/feature/visitor/AbstractCalcResult.java $
038:         */
039:        public class AbstractCalcResult implements  CalcResult {
040:            public boolean isCompatible(CalcResult targetResults) {
041:                return false;
042:            }
043:
044:            public CalcResult merge(CalcResult resultsToAdd) {
045:                return null;
046:            }
047:
048:            public Object getValue() {
049:                return null;
050:            }
051:
052:            public int toInt() {
053:                Object value = getValue();
054:                if (value instanceof  Number) {
055:                    Number number = (Number) value;
056:                    return number.intValue();
057:                } else {
058:                    return (int) 0;
059:                }
060:            }
061:
062:            public double toDouble() {
063:                Object value = getValue();
064:                if (value instanceof  Number) {
065:                    Number number = (Number) value;
066:                    return number.doubleValue();
067:                } else {
068:                    return (double) 0;
069:                }
070:            }
071:
072:            public long toLong() {
073:                Object value = getValue();
074:                if (value instanceof  Number) {
075:                    Number number = (Number) value;
076:                    return number.longValue();
077:                } else {
078:                    return (long) 0;
079:                }
080:            }
081:
082:            public float toFloat() {
083:                Object value = getValue();
084:                if (value instanceof  Number) {
085:                    Number number = (Number) value;
086:                    return number.floatValue();
087:                } else {
088:                    return (float) 0;
089:                }
090:            }
091:
092:            public Geometry toGeometry() {
093:                Object value = getValue();
094:                if (value instanceof  Geometry)
095:                    return (Geometry) getValue();
096:                else
097:                    return null;
098:            }
099:
100:            public Envelope toEnvelope() {
101:                Object value = getValue();
102:                if (value instanceof  Envelope)
103:                    return (Envelope) value;
104:                else
105:                    return null;
106:            }
107:
108:            public Point toPoint() {
109:                Geometry geometry = toGeometry();
110:                return geometry.getCentroid();
111:            }
112:
113:            public Set toSet() {
114:                Object value = getValue();
115:
116:                if (value == null) {
117:                    return null;
118:                }
119:
120:                if (value instanceof  Set) {
121:                    Set set = (Set) value;
122:
123:                    return set;
124:                }
125:
126:                if (value.getClass().isArray()) {
127:                    Set set = new HashSet(Arrays.asList((Object[]) value));
128:
129:                    return set;
130:                }
131:
132:                if (value instanceof  Collection) {
133:                    Set set = new HashSet((Collection) value);
134:
135:                    return set;
136:                }
137:
138:                return null;
139:            }
140:
141:            public List toList() {
142:                Object value = getValue();
143:
144:                if (value == null) {
145:                    return null;
146:                }
147:
148:                if (value instanceof  List) {
149:                    List list = (List) value;
150:
151:                    return list;
152:                }
153:
154:                if (value.getClass().isArray()) {
155:                    return Arrays.asList((Object[]) value);
156:                }
157:
158:                if (value instanceof  HashSet) {
159:                    Set set = (HashSet) value;
160:                    // Object[] values = set.toArray();
161:                    return Arrays.asList(set.toArray());
162:                    // List list = new ArrayList();
163:                    // for (int i = 0; i < values.length; i++)
164:                    // list.add(values[i]);
165:                    // return list;
166:                }
167:
168:                if (value instanceof  Collection) {
169:                    return new ArrayList((Collection) value);
170:                }
171:
172:                return null;
173:            }
174:
175:            public Object[] toArray() {
176:                List list = toList();
177:
178:                if (list == null) {
179:                    return null;
180:                }
181:
182:                return list.toArray();
183:            }
184:
185:            public String[] toStringArray() {
186:                List list = toList();
187:
188:                if (list == null) {
189:                    return null;
190:                }
191:
192:                String[] strings = new String[list.size()];
193:
194:                return (String[]) list.toArray(strings);
195:            }
196:
197:            public Map toMap() {
198:                return (Map) getValue();
199:            }
200:
201:            public String toString() {
202:                return getValue().toString();
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.