Source Code Cross Referenced for AttributeInfo.java in  » GIS » openjump » de » fho » jump » pirol » utilities » 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 » openjump » de.fho.jump.pirol.utilities.attributes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 03.03.2005 for PIROL
003:         *
004:         * SVN header information:
005:         *  $Author: javamap $
006:         *  $Rev: 856 $
007:         *  $Date: 2007-06-18 21:15:27 -0700 (Mon, 18 Jun 2007) $
008:         *  $Id: AttributeInfo.java 856 2007-06-19 04:15:27Z javamap $
009:         */
010:        package de.fho.jump.pirol.utilities.attributes;
011:
012:        import com.vividsolutions.jump.feature.AttributeType;
013:        import com.vividsolutions.jump.feature.FeatureSchema;
014:
015:        /**
016:         * Class to store all information for a given attribute, so it can easily passed
017:         * to e.g. to methods of the FeatureCollectionTools 
018:         * 
019:         * @author Ole Rahn
020:         * <br>
021:         * <br>FH Osnabr&uuml;ck - University of Applied Sciences Osnabr&uuml;ck,
022:         * <br>Project: PIROL (2005),
023:         * <br>Subproject: Daten- und Wissensmanagement
024:         * 
025:         * @version $Rev: 856 $
026:         * 
027:         * @see de.fhOsnabrueck.jump.pirol.utilities.FeatureCollectionTools
028:         */
029:        public class AttributeInfo implements  Comparable {
030:
031:            protected AttributeType attributeType = null;
032:            protected String attributeName = null;
033:            protected String uniqueAttributeName = null;
034:            protected String unitIdentifier = null;
035:            protected Object nullValue = null;
036:
037:            /**
038:             * For attributes that have been loaded from the DB
039:             */
040:            protected int dataBaseId = -1;
041:
042:            /**
043:             * attribute's index in a (given?) FeatureSchema
044:             */
045:            protected int index = -1;
046:
047:            public AttributeInfo(AttributeType attributeType,
048:                    String attributeName, Object nullValue) {
049:                this (attributeType, attributeName);
050:                this .nullValue = nullValue;
051:            }
052:
053:            public AttributeInfo(AttributeType attributeType,
054:                    String attributeName) {
055:                super ();
056:                this .attributeType = attributeType;
057:                this .attributeName = attributeName;
058:            }
059:
060:            public AttributeInfo(String attributeName, Object nullValue) {
061:                super ();
062:                this .attributeName = attributeName;
063:                this .nullValue = nullValue;
064:            }
065:
066:            public String getAttributeName() {
067:                return attributeName;
068:            }
069:
070:            public AttributeType getAttributeType() {
071:                return attributeType;
072:            }
073:
074:            public int getIndex() {
075:                return index;
076:            }
077:
078:            public void setIndex(int index) {
079:                this .index = index;
080:            }
081:
082:            public Object getNullValue() {
083:                return nullValue;
084:            }
085:
086:            public String getUniqueAttributeName() {
087:                if (uniqueAttributeName == null)
088:                    return this .getAttributeName();
089:                return uniqueAttributeName;
090:            }
091:
092:            public void setUniqueAttributeName(String uniqueAttributeName) {
093:                this .uniqueAttributeName = uniqueAttributeName;
094:            }
095:
096:            public void setAttributeName(String attributeName) {
097:                this .attributeName = attributeName;
098:            }
099:
100:            public void setAttributeType(AttributeType attributeType) {
101:                this .attributeType = attributeType;
102:            }
103:
104:            public void setNullValue(Object nullValue) {
105:                if (this .attributeType != null) {
106:                    if ((this .attributeType.equals(AttributeType.DOUBLE) && !Double.class
107:                            .isInstance(nullValue))
108:                            || (this .attributeType
109:                                    .equals(AttributeType.INTEGER) && !Integer.class
110:                                    .isInstance(nullValue)))
111:                        throw new IllegalArgumentException(
112:                                "default value is of a wrong type: "
113:                                        + nullValue.getClass().getName());
114:                    else if (this .attributeType.equals(AttributeType.STRING)
115:                            && !String.class.isInstance(nullValue))
116:                        nullValue = new String(nullValue.toString());
117:                }
118:
119:                this .nullValue = nullValue;
120:            }
121:
122:            public String getUnitIdentifier() {
123:                return unitIdentifier;
124:            }
125:
126:            public void setUnitIdentifier(String unitIdentifier) {
127:                this .unitIdentifier = unitIdentifier;
128:            }
129:
130:            /**
131:             * convenient method to convert a FeatureSchema into an AttributeInfo array
132:             *@param fs the FeatureSchema
133:             *@return an array of AttributeInfos matching the FeatureSchema
134:             */
135:            public static AttributeInfo[] schema2AttributeInfoArray(
136:                    FeatureSchema fs) {
137:                AttributeInfo[] result = new AttributeInfo[fs
138:                        .getAttributeCount()];
139:
140:                for (int i = 0; i < result.length; i++) {
141:                    result[i] = new AttributeInfo(fs.getAttributeType(i), fs
142:                            .getAttributeName(i));
143:                    result[i].setIndex(i);
144:                }
145:
146:                return result;
147:            }
148:
149:            /**
150:             * convenient method to convert an AttributeInfo array into a FeatureSchema
151:             *@param attributeInfos an array of AttributeInfos matching wanted in the FeatureSchema
152:             *@return the desired FeatureSchema
153:             */
154:            public static FeatureSchema attributeInfoArray2FeatureSchema(
155:                    AttributeInfo[] attributeInfos) {
156:                FeatureSchema result = new FeatureSchema();
157:
158:                for (int i = 0; i < attributeInfos.length; i++) {
159:                    result.addAttribute(attributeInfos[i]
160:                            .getUniqueAttributeName(), attributeInfos[i]
161:                            .getAttributeType());
162:                }
163:
164:                return result;
165:            }
166:
167:            /**
168:             *@inheritDoc
169:             */
170:            public String toString() {
171:                return this .getUniqueAttributeName();
172:            }
173:
174:            /**
175:             * In order for this to work, the attribute indices of this AttributeInfo object and of the other
176:             * one has to be set, correctly!
177:             *@param theOtherObject
178:             *@return see <code>Comparable</code> for
179:             */
180:            public int compareTo(Object theOtherObject) {
181:                int iTheOtherIndex = ((AttributeInfo) theOtherObject)
182:                        .getIndex();
183:                int iThisIndex = this .getIndex();
184:
185:                if (Math.min(iThisIndex, iTheOtherIndex) > -1) {
186:                    // since both indices may be -1 --> not set...
187:                    Integer theOtherIndex = new Integer(iTheOtherIndex);
188:                    Integer this Index = new Integer(iThisIndex);
189:                    return this Index.compareTo(theOtherIndex);
190:                }
191:                // ... we may want to throw an exception...
192:                throw new IllegalStateException(
193:                        "at least one index is not set correctly: "
194:                                + iThisIndex + ", " + iTheOtherIndex);
195:            }
196:
197:            public int getDataBaseId() {
198:                return dataBaseId;
199:            }
200:
201:            public void setDataBaseId(int dataBaseId) {
202:                this.dataBaseId = dataBaseId;
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.