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


001:        package org.geotools.feature.iso;
002:
003:        import java.util.List;
004:
005:        import org.geotools.feature.IllegalAttributeException;
006:        import org.geotools.resources.Utilities;
007:        import org.opengis.feature.Attribute;
008:        import org.opengis.feature.type.AttributeDescriptor;
009:        import org.opengis.feature.type.AttributeType;
010:        import org.opengis.feature.type.Name;
011:        import org.opengis.feature.type.PropertyDescriptor;
012:
013:        /**
014:         * Simple, mutable class to store attributes.
015:         * 
016:         * @author Rob Hranac, VFNY
017:         * @author Chris Holmes, TOPP
018:         * @author Ian Schneider
019:         * @author Jody Garnett
020:         * @author Gabriel Roldan
021:         * @version $Id: AttributeImpl.java 28577 2008-01-03 15:44:29Z groldan $
022:         */
023:        public class AttributeImpl implements  Attribute {
024:
025:            protected Object content;
026:
027:            protected AttributeDescriptor DESCRIPTOR;
028:
029:            protected final AttributeType TYPE;
030:
031:            protected final String ID;
032:
033:            public AttributeImpl(Object content,
034:                    AttributeDescriptor descriptor, String id) {
035:                this (content, (AttributeType) descriptor.type(), id);
036:
037:                DESCRIPTOR = descriptor;
038:            }
039:
040:            public AttributeImpl(Object content, AttributeType type, String id) {
041:                // if (type.isAbstract()) {
042:                // throw new UnsupportedOperationException(type.getName()
043:                // + " is abstract");
044:                // }
045:                TYPE = type;
046:                ID = id;
047:                setValue(content);
048:            }
049:
050:            public String getID() {
051:                return ID;
052:            }
053:
054:            public Object getValue() {
055:                return content;
056:            }
057:
058:            public AttributeDescriptor getDescriptor() {
059:                return DESCRIPTOR;
060:            }
061:
062:            public PropertyDescriptor descriptor() {
063:                return getDescriptor();
064:            }
065:
066:            public AttributeType getType() {
067:                return TYPE;
068:            }
069:
070:            public Name name() {
071:                return DESCRIPTOR != null ? DESCRIPTOR.getName() : null;
072:            }
073:
074:            public boolean nillable() {
075:                if (getDescriptor() != null) {
076:                    return getDescriptor().isNillable();
077:                }
078:
079:                return true;
080:            }
081:
082:            /**
083:             * 
084:             * @throws IllegalArgumentException
085:             * @throws IllegalStateException
086:             *             if the value has been parsed and validated, yet this
087:             *             Attribute does not passes the restrictions imposed by its
088:             *             AttributeType
089:             */
090:            public void setValue(Object newValue)
091:                    throws IllegalArgumentException, IllegalStateException {
092:
093:                newValue = parse(newValue);
094:
095:                try {
096:                    Types.validate(getType(), this , newValue);
097:                } catch (IllegalAttributeException e) {
098:                    throw (IllegalArgumentException) new IllegalArgumentException()
099:                            .initCause(e);
100:                }
101:
102:                content = newValue;
103:            }
104:
105:            /**
106:             * Override of hashCode.
107:             * 
108:             * @return hashCode for this object.
109:             */
110:            public int hashCode() {
111:                return 37 * (DESCRIPTOR == null ? 0 : DESCRIPTOR.hashCode())
112:                        + (37 * (TYPE == null ? 0 : TYPE.hashCode()))
113:                        + (37 * (ID == null ? 0 : ID.hashCode()))
114:                        + (37 * (content == null ? 0 : content.hashCode()));
115:            }
116:
117:            /**
118:             * Override of equals.
119:             * 
120:             * @param other
121:             *            the object to be tested for equality.
122:             * 
123:             * @return whether other is equal to this attribute Type.
124:             */
125:            public boolean equals(Object other) {
126:                if (!(other instanceof  AttributeImpl)) {
127:                    return false;
128:                }
129:
130:                AttributeImpl att = (AttributeImpl) other;
131:
132:                if (!Utilities.equals(DESCRIPTOR, att.DESCRIPTOR))
133:                    return false;
134:
135:                if (!Utilities.equals(TYPE, att.TYPE))
136:                    return false;
137:
138:                if (!Utilities.equals(ID, att.ID))
139:                    return false;
140:
141:                if (!Utilities.equals(content, att.content))
142:                    return false;
143:
144:                return true;
145:            }
146:
147:            /**
148:             * Allows this Attribute to convert an argument to its prefered storage
149:             * type. If no parsing is possible, returns the original value. If a parse
150:             * is attempted, yet fails (i.e. a poor decimal format) throw the Exception.
151:             * This is mostly for use internally in Features, but implementors should
152:             * simply follow the rules to be safe.
153:             * 
154:             * @param value
155:             *            the object to attempt parsing of.
156:             * 
157:             * @return <code>value</code> converted to the preferred storage of this
158:             *         <code>AttributeType</code>. If no parsing was possible then
159:             *         the same object is returned.
160:             * 
161:             * @throws IllegalArgumentException
162:             *             if parsing is attempted and is unsuccessful.
163:             */
164:            protected Object parse(Object value)
165:                    throws IllegalArgumentException {
166:                return value;
167:            }
168:
169:            public Object operation(Name arg0, List arg1) {
170:                throw new UnsupportedOperationException(
171:                        "operation not supported yet");
172:            }
173:
174:            public String toString() {
175:                StringBuffer sb = new StringBuffer("Attribute[");
176:                sb.append(DESCRIPTOR == null ? "" : DESCRIPTOR.getName()
177:                        .getLocalPart());
178:                sb.append(":");
179:                sb.append(TYPE.getName().getLocalPart());
180:                sb.append(":@");
181:                sb.append(ID == null ? "" : ID);
182:                sb.append(":");
183:                sb.append(content);
184:                sb.append("]");
185:                //        LOGGER.fine("converting value for unbound Attribute (possibly null value) " + sb.toString() );
186:                return (content == null ? "" : content.toString());
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.