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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-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.xs.facets;
017:
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        /**
023:         * Captures the whitespace facet.
024:         * <p>
025:         * Constants and utility method for old fashion facet goodness. See BooleanXOHandler for an example.
026:         * <p>
027:         * Here is an example use:<pre><code>
028:         * &lt;simpleType name='token'&gt;
029:         *   &lt;restriction base='normalizedString'&gt;
030:         *     &lt;whiteSpace value='collapse'/&gt;
031:         *   &lt;/restriction&gt;
032:         * &lt;/simpleType&gt;
033:         * </code></pre>
034:         * @see a longing for Java 5 Enum construct
035:         * @see <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">This web page</a>
036:         * @author jgarnett
037:         * @since 1.0.0
038:         */
039:        public abstract class Whitespace implements  Comparable {
040:            /**
041:             * No normalization is done, the value is not changed
042:             * <p>
043:             * Simon the spec says: <i> No normalization is done, the value is not changed (this is the
044:             * behavior required by [XML 1.0 (Second Edition)] for element content) </i>
045:             * </p>
046:             */
047:            public static final Whitespace PRESERVE = new Whitespace(
048:                    "preserve", 0) {
049:                public String preparse(String text) {
050:                    return text;
051:                }
052:            };
053:
054:            /**
055:             * All occurrences of tab, line feed and carriage return are replaced with space.
056:             * <p>
057:             * Simon the spec says: <i> All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage
058:             * return) are replaced with #x20 (space) </i>
059:             * </p>
060:             */
061:            public static final Whitespace REPLACE = new Whitespace("replace",
062:                    1) {
063:                public String preparse(String text) {
064:                    StringBuffer replace = new StringBuffer(text);
065:
066:                    for (int i = 0; i < replace.length(); i++) {
067:                        char ch = replace.charAt(i);
068:
069:                        if (('\t' == ch) || ('\n' == ch) || ('\r' == ch)) {
070:                            replace.setCharAt(i, ' ');
071:                        }
072:                    }
073:
074:                    return replace.toString();
075:                }
076:            };
077:
078:            /**
079:             * All occurrences of tab, line feed and carriage return are replaced with space.
080:             * <p>
081:             * Simon the spec says: <i> All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage
082:             * return) are replaced with #x20 (space) </i>
083:             * </p>
084:             */
085:            public static final Whitespace COLLAPSE = new Whitespace(
086:                    "collapse", 2) {
087:                public String preparse(String text) {
088:                    text = REPLACE.preparse(text);
089:                    text = text.trim();
090:
091:                    StringBuffer collapse = new StringBuffer(text);
092:                    int i = 0;
093:
094:                    for (; i < collapse.length(); i++) {
095:                        if (' ' == collapse.charAt(i)) {
096:                            for (++i; (i < collapse.length())
097:                                    && (' ' == collapse.charAt(i));) {
098:                                collapse.deleteCharAt(i);
099:                            }
100:                        }
101:                    }
102:
103:                    return collapse.toString();
104:                }
105:            };
106:
107:            //
108:            // Fake the ENUM thing for the Java 14 crowd
109:            //
110:            private static List values = new ArrayList();
111:
112:            static {
113:                values.add(PRESERVE);
114:                values.add(REPLACE);
115:                values.add(COLLAPSE);
116:            }
117:
118:            private int ordinal;
119:            private String name;
120:
121:            private Whitespace(String name, int number) {
122:                this .ordinal = number;
123:                this .name = name;
124:            }
125:
126:            /** Handle whitespace */
127:            public abstract String preparse(String text);
128:
129:            public String name() {
130:                return name;
131:            }
132:
133:            public int ordinal() {
134:                return ordinal;
135:            }
136:
137:            public int hashCode() {
138:                return ordinal;
139:            }
140:
141:            protected Object clone() throws CloneNotSupportedException {
142:                throw new CloneNotSupportedException("Ha Ha");
143:            }
144:
145:            public boolean equals(Object other) {
146:                return (other != null) && other instanceof  Whitespace
147:                        && (((Whitespace) other).ordinal == ordinal);
148:            }
149:
150:            public int compareTo(Object other) {
151:                if ((other == null) || !(other instanceof  Whitespace)) {
152:                    return -1;
153:                }
154:
155:                int ord = ((Whitespace) other).ordinal;
156:
157:                if (ordinal == ord) {
158:                    return 0;
159:                }
160:
161:                if (ordinal < ord) {
162:                    return -1;
163:                }
164:
165:                return 1;
166:            }
167:
168:            /**
169:             * Returns the enum constant of the specified enum type with the specified name. The name must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
170:             * @param whitespace
171:             */
172:            public static Whitespace valueOf(String whitespace) {
173:                for (Iterator i = values.iterator(); i.hasNext();) {
174:                    Whitespace item = (Whitespace) i.next();
175:
176:                    if (whitespace.equals(item.name)) {
177:                        return item;
178:                    }
179:                }
180:
181:                return null;
182:            }
183:
184:            /**
185:             * Returns the Class object corresponding to this enum constant's enum type.
186:             *
187:             * @return Whitespace.class
188:             */
189:            public Class getDeclaringClass() {
190:                return Whitespace.class;
191:            }
192:
193:            public static List values() {
194:                return values;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.