Source Code Cross Referenced for ColumnDescription.java in  » GIS » openjump » com » vividsolutions » jump » io » 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 » com.vividsolutions.jump.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         * 
012:         * This program 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
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         * 
021:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:
033:        package com.vividsolutions.jump.io;
034:
035:        import org.xml.sax.Attributes;
036:
037:        import com.vividsolutions.jump.feature.AttributeType;
038:
039:        /**
040:         * This is a helper class to store information about a JCS Column for the GML Parser ({@link GMLReader}). <br>
041:         *
042:         * Also has a function for checking if an XML tag matches this column specification.
043:         */
044:        public class ColumnDescription {
045:            public static final int VALUE_IS_BODY = 1;
046:            public static final int VALUE_IS_ATT = 2;
047:            String columnName; //jcs column name
048:            String tagName; //XML tag this is a part of
049:            boolean tagNeedsAttribute = false; //true if the tag containing the value has a certain attribute in it
050:            String attributeName; //name of this attribute
051:            boolean tagAttributeNeedsValue = false; // true if the tag/attribute needs a value
052:            String attributeValue; //     actual value of that attribute
053:            int valueType = VALUE_IS_BODY; //either VALUE_IS_BODY or VALUE_IS_ATT
054:            String valueAttribute; //which attribute the value is in (only for VALUE_IS_ATT)
055:            AttributeType type;
056:
057:            //**constructor**/
058:            public ColumnDescription() {
059:            }
060:
061:            /**
062:             * Sets the [JCS] type of this column
063:             *
064:             * @param t JCS type that this column will contain (null means 'STRING')
065:             **/
066:            public void setType(AttributeType t) {
067:                //<<TODO:DESIGN>> Shouldn't we use the Assert class to stipulate that
068:                //t must not be null? [Jon Aquino]
069:                if (t == null) {
070:                    type = AttributeType.STRING;
071:                } else {
072:                    type = t;
073:                }
074:            }
075:
076:            /**
077:             * Returns the [JCS] type of this column
078:             * cf. setType()
079:             **/
080:            public AttributeType getType() {
081:                return type;
082:            }
083:
084:            /**
085:             * Set the name of this column.
086:             * @param colname name of the column
087:             **/
088:            public void setColumnName(String colname) {
089:                columnName = colname;
090:            }
091:
092:            /**
093:             * Sets the name of the XML tag that this column will be extracted from.
094:             * @param tagname name of the XML tag
095:             **/
096:            public void setTagName(String tagname) {
097:                tagName = tagname;
098:            }
099:
100:            /**
101:             * Sets the name of the attribute (and its value) that the xml tag that this column will be extracted from.
102:             *<pre>
103:             *  For example, the XML '&lt;value type=name&gt; DAVE &lt;/value&gt;' would described by:
104:             *  setTagName('value');
105:             *  setTagAttribute('type','name');
106:             *</pre>
107:             *
108:             * @param attName name of the XML attribute name
109:             *@param attValue its value
110:             **/
111:            public void setTagAttribute(String attName, String attValue) {
112:                attributeName = attName;
113:                attributeValue = attValue;
114:                tagNeedsAttribute = true;
115:                tagAttributeNeedsValue = true;
116:            }
117:
118:            /**
119:             * Sets the name of the attribute (with no value) that the xml tag that this column will be extracted from.
120:             *<PRE>
121:             *  For example, the XML '&lt;value name=david&gt;&lt;/value&gt;' would described by:
122:             *  setTagName('value');
123:             *  setTagAttribute('name');
124:             *</PRE>
125:             *
126:             * @param attName name of the XML attribute name
127:             **/
128:            public void setTagAttribute(String attName) {
129:                attributeName = attName;
130:                tagNeedsAttribute = true;
131:            }
132:
133:            /**
134:             * Sets the name of the attribute that the actual column's value will be found.
135:             *<PRE>
136:             *  For example, the XML '&lt;value name=david&gt;&lt;/value&gt;' would described by:
137:             *  setTagName('value');
138:             *  setTagAttribute('name');
139:             *  setValueAttribute('name');
140:             *</PRE>
141:             *
142:             *  NOTE: not calling this function will mean to get the column's value from the BODY
143:             *        of the tag.
144:             *
145:             *@param attName name of the attribute that the column's value will be extracted from
146:             */
147:            public void setValueAttribute(String attName) {
148:                valueAttribute = attName;
149:                valueType = VALUE_IS_ATT;
150:            }
151:
152:            /**
153:             * Given a set of XML attributes associated with an XML tag, find the index of
154:             * a given attribute in a case insensitive way.
155:             *
156:             * This is the case insensitive version of the standard function.  Returns -1 if
157:             * the attribute cannot be found
158:             *
159:             * @param atts XML attributes for a tag
160:             * @param att_name name of the attribute
161:             **/
162:            int lookupAttribute(Attributes atts, String att_name) {
163:                int t;
164:
165:                for (t = 0; t < atts.getLength(); t++) {
166:                    if (atts.getQName(t).equalsIgnoreCase(att_name)) {
167:                        return t;
168:                    }
169:                }
170:
171:                return -1;
172:            }
173:
174:            /**
175:             * Given an xml tag (its name and attributes), see if it matches this column description<br>
176:             *  If it doesnt, return 0 <br>
177:             *  If it does, return either VALUE_IS_BODY or VALUE_IS_ATTRIBUTE<br>
178:             * @param XMLtagName name of the xml tag
179:             * @param xmlAtts list of the xml attributes for the tag (cf. xerces or SAX)
180:             */
181:            public int match(String XMLtagName, Attributes xmlAtts) {
182:                int attindex;
183:
184:                if (XMLtagName.compareToIgnoreCase(tagName) == 0) {
185:                    //tags match
186:                    if (tagNeedsAttribute) {
187:                        //attindex = xmlAtts.getIndex(attributeName);
188:                        attindex = lookupAttribute(xmlAtts, attributeName);
189:
190:                        if (attindex == -1) {
191:                            return 0; //doesnt have the required attribute
192:                        }
193:
194:                        if (tagAttributeNeedsValue) {
195:                            if (xmlAtts.getValue(attindex).compareToIgnoreCase(
196:                                    attributeValue) != 0) {
197:                                return 0; // attribute doesnt have the correct value
198:                            }
199:                        }
200:                    }
201:
202:                    return valueType;
203:                }
204:
205:                return 0; // not the right tag
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.