annotate NGSrich_0.5.5/src/org/jdom/Verifier.java @ 0:89ad0a9cca52 default tip

Uploaded
author pfrommolt
date Mon, 21 Nov 2011 08:12:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1 /*--
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
2
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
3 $Id: Verifier.java,v 1.57 2009/07/23 05:54:23 jhunter Exp $
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
4
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
5 Copyright (C) 2000-2007 Jason Hunter & Brett McLaughlin.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
6 All rights reserved.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
7
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
8 Redistribution and use in source and binary forms, with or without
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
9 modification, are permitted provided that the following conditions
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
10 are met:
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
11
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
12 1. Redistributions of source code must retain the above copyright
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
13 notice, this list of conditions, and the following disclaimer.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
14
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
15 2. Redistributions in binary form must reproduce the above copyright
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
16 notice, this list of conditions, and the disclaimer that follows
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
17 these conditions in the documentation and/or other materials
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
18 provided with the distribution.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
19
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
20 3. The name "JDOM" must not be used to endorse or promote products
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
21 derived from this software without prior written permission. For
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
22 written permission, please contact <request_AT_jdom_DOT_org>.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
23
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
24 4. Products derived from this software may not be called "JDOM", nor
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
25 may "JDOM" appear in their name, without prior written permission
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
26 from the JDOM Project Management <request_AT_jdom_DOT_org>.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
27
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
28 In addition, we request (but do not require) that you include in the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
29 end-user documentation provided with the redistribution and/or in the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
30 software itself an acknowledgement equivalent to the following:
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
31 "This product includes software developed by the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
32 JDOM Project (http://www.jdom.org/)."
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
33 Alternatively, the acknowledgment may be graphical using the logos
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
34 available at http://www.jdom.org/images/logos.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
35
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
36 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
37 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
38 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
39 DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
40 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
41 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
42 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
43 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
44 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
45 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
46 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
47 SUCH DAMAGE.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
48
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
49 This software consists of voluntary contributions made by many
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
50 individuals on behalf of the JDOM Project and was originally
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
51 created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
52 Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
53 on the JDOM Project, please see <http://www.jdom.org/>.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
54
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
55 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
56
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
57 package org.jdom;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
58
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
59 import java.util.*;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
60
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
61 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
62 * A utility class to handle well-formedness checks on names, data, and other
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
63 * verification tasks for JDOM. The class is final and may not be subclassed.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
64 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
65 * @version $Revision: 1.57 $, $Date: 2009/07/23 05:54:23 $
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
66 * @author Brett McLaughlin
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
67 * @author Elliotte Rusty Harold
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
68 * @author Jason Hunter
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
69 * @author Bradley S. Huffman
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
70 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
71 final public class Verifier {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
72
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
73 private static final String CVS_ID =
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
74 "@(#) $RCSfile: Verifier.java,v $ $Revision: 1.57 $ $Date: 2009/07/23 05:54:23 $ $Name: jdom_1_1_1 $";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
75
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
76 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
77 * Ensure instantation cannot occur.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
78 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
79 private Verifier() { }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
80
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
81 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
82 * This will check the supplied name to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
83 * a JDOM <code>{@link Element}</code> name.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
84 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
85 * @param name <code>String</code> name to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
86 * @return <code>String</code> reason name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
87 * <code>null</code> if name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
88 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
89 public static String checkElementName(String name) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
90 // Check basic XML name rules first
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
91 String reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
92 if ((reason = checkXMLName(name)) != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
93 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
94 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
95
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
96 // No colons allowed, since elements handle this internally
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
97 if (name.indexOf(":") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
98 return "Element names cannot contain colons";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
99 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
100
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
101 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
102 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
103 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
104
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
105 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
106 * This will check the supplied name to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
107 * a JDOM <code>{@link Attribute}</code> name.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
108 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
109 * @param name <code>String</code> name to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
110 * @return <code>String</code> reason name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
111 * <code>null</code> if name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
112 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
113 public static String checkAttributeName(String name) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
114 // Check basic XML name rules first
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
115 String reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
116 if ((reason = checkXMLName(name)) != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
117 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
118 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
119
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
120 // No colons are allowed, since attributes handle this internally
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
121 if (name.indexOf(":") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
122 return "Attribute names cannot contain colons";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
123 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
124
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
125 // Attribute names may not be xmlns since we do this internally too
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
126 if (name.equals("xmlns")) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
127 return "An Attribute name may not be \"xmlns\"; " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
128 "use the Namespace class to manage namespaces";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
129 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
130
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
131 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
132 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
133 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
134
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
135 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
136 * This will check the supplied string to see if it only contains
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
137 * characters allowed by the XML 1.0 specification. The C0 controls
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
138 * (e.g. null, vertical tab, formfeed, etc.) are specifically excluded
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
139 * except for carriage return, linefeed, and the horizontal tab.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
140 * Surrogates are also excluded.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
141 * <p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
142 * This method is useful for checking element content and attribute
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
143 * values. Note that characters
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
144 * like " and &lt; are allowed in attribute values and element content.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
145 * They will simply be escaped as &quot; or &lt;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
146 * when the value is serialized.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
147 * </p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
148 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
149 * @param text <code>String</code> value to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
150 * @return <code>String</code> reason name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
151 * <code>null</code> if name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
152 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
153 public static String checkCharacterData(String text) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
154 if (text == null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
155 return "A null is not a legal XML value";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
156 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
157
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
158 // Do check
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
159 for (int i = 0, len = text.length(); i<len; i++) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
160
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
161 int ch = text.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
162
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
163 // Check if high part of a surrogate pair
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
164 if (isHighSurrogate((char) ch)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
165 // Check if next char is the low-surrogate
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
166 i++;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
167 if (i < len) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
168 char low = text.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
169 if (!isLowSurrogate(low)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
170 return "Illegal Surrogate Pair";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
171 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
172 // It's a good pair, calculate the true value of
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
173 // the character to then fall thru to isXMLCharacter
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
174 ch = decodeSurrogatePair((char) ch, low);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
175 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
176 else {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
177 return "Surrogate Pair Truncated";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
178 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
179 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
180
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
181 if (!isXMLCharacter(ch)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
182 // Likely this character can't be easily displayed
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
183 // because it's a control so we use it'd hexadecimal
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
184 // representation in the reason.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
185 return ("0x" + Integer.toHexString(ch) +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
186 " is not a legal XML character");
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
187 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
188 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
189
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
190 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
191 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
192 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
193
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
194 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
195 * This will check the supplied data to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
196 * JDOM <code>{@link CDATA}</code>.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
197 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
198 * @param data <code>String</code> data to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
199 * @return <code>String</code> reason data is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
200 * <code>null</code> is name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
201 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
202 public static String checkCDATASection(String data) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
203 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
204 if ((reason = checkCharacterData(data)) != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
205 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
206 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
207
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
208 if (data.indexOf("]]>") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
209 return "CDATA cannot internally contain a CDATA ending " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
210 "delimiter (]]>)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
211 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
212
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
213 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
214 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
215 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
216
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
217 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
218 * This will check the supplied name to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
219 * a JDOM <code>{@link Namespace}</code> prefix.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
220 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
221 * @param prefix <code>String</code> prefix to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
222 * @return <code>String</code> reason name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
223 * <code>null</code> if name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
224 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
225 public static String checkNamespacePrefix(String prefix) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
226 // Manually do rules, since URIs can be null or empty
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
227 if ((prefix == null) || (prefix.equals(""))) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
228 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
229 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
230
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
231 // Cannot start with a number
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
232 char first = prefix.charAt(0);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
233 if (isXMLDigit(first)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
234 return "Namespace prefixes cannot begin with a number";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
235 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
236 // Cannot start with a $
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
237 if (first == '$') {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
238 return "Namespace prefixes cannot begin with a dollar sign ($)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
239 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
240 // Cannot start with a -
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
241 if (first == '-') {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
242 return "Namespace prefixes cannot begin with a hyphen (-)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
243 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
244 // Cannot start with a .
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
245 if (first == '.') {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
246 return "Namespace prefixes cannot begin with a period (.)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
247 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
248 // Cannot start with "xml" in any character case
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
249 if (prefix.toLowerCase().startsWith("xml")) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
250 return "Namespace prefixes cannot begin with " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
251 "\"xml\" in any combination of case";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
252 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
253
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
254 // Ensure legal content
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
255 for (int i=0, len = prefix.length(); i<len; i++) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
256 char c = prefix.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
257 if (!isXMLNameCharacter(c)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
258 return "Namespace prefixes cannot contain the character \"" +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
259 c + "\"";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
260 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
261 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
262
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
263 // No colons allowed
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
264 if (prefix.indexOf(":") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
265 return "Namespace prefixes cannot contain colons";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
266 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
267
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
268 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
269 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
270 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
271
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
272 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
273 * This will check the supplied name to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
274 * a JDOM <code>{@link Namespace}</code> URI.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
275 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
276 * @param uri <code>String</code> URI to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
277 * @return <code>String</code> reason name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
278 * <code>null</code> if name is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
279 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
280 public static String checkNamespaceURI(String uri) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
281 // Manually do rules, since URIs can be null or empty
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
282 if ((uri == null) || (uri.equals(""))) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
283 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
284 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
285
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
286 // Cannot start with a number
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
287 char first = uri.charAt(0);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
288 if (Character.isDigit(first)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
289 return "Namespace URIs cannot begin with a number";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
290 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
291 // Cannot start with a $
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
292 if (first == '$') {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
293 return "Namespace URIs cannot begin with a dollar sign ($)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
294 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
295 // Cannot start with a -
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
296 if (first == '-') {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
297 return "Namespace URIs cannot begin with a hyphen (-)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
298 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
299
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
300 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
301 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
302 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
303
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
304 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
305 * Check if two namespaces collide.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
306 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
307 * @param namespace <code>Namespace</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
308 * @param other <code>Namespace</code> to check against.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
309 * @return <code>String</code> reason for collision, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
310 * <code>null</code> if no collision.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
311 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
312 public static String checkNamespaceCollision(Namespace namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
313 Namespace other) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
314 String p1,p2,u1,u2,reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
315
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
316 reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
317 p1 = namespace.getPrefix();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
318 u1 = namespace.getURI();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
319 p2 = other.getPrefix();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
320 u2 = other.getURI();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
321 if (p1.equals(p2) && !u1.equals(u2)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
322 reason = "The namespace prefix \"" + p1 + "\" collides";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
323 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
324 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
325 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
326
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
327 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
328 * Check if <code>{@link Attribute}</code>'s namespace collides with a
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
329 * <code>{@link Element}</code>'s namespace.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
330 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
331 * @param attribute <code>Attribute</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
332 * @param element <code>Element</code> to check against.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
333 * @return <code>String</code> reason for collision, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
334 * <code>null</code> if no collision.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
335 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
336 public static String checkNamespaceCollision(Attribute attribute,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
337 Element element) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
338 Namespace namespace = attribute.getNamespace();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
339 String prefix = namespace.getPrefix();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
340 if ("".equals(prefix)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
341 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
342 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
343
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
344 return checkNamespaceCollision(namespace, element);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
345 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
346
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
347 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
348 * Check if a <code>{@link Namespace}</code> collides with a
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
349 * <code>{@link Element}</code>'s namespace.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
350 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
351 * @param namespace <code>Namespace</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
352 * @param element <code>Element</code> to check against.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
353 * @return <code>String</code> reason for collision, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
354 * <code>null</code> if no collision.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
355 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
356 public static String checkNamespaceCollision(Namespace namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
357 Element element) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
358 String reason = checkNamespaceCollision(namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
359 element.getNamespace());
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
360 if (reason != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
361 return reason + " with the element namespace prefix";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
362 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
363
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
364 reason = checkNamespaceCollision(namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
365 element.getAdditionalNamespaces());
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
366 if (reason != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
367 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
368 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
369
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
370 reason = checkNamespaceCollision(namespace, element.getAttributes());
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
371 if (reason != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
372 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
373 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
374
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
375 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
376 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
377
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
378 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
379 * Check if a <code>{@link Namespace}</code> collides with a
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
380 * <code>{@link Attribute}</code>'s namespace.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
381 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
382 * @param namespace <code>Namespace</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
383 * @param attribute <code>Attribute</code> to check against.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
384 * @return <code>String</code> reason for collision, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
385 * <code>null</code> if no collision.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
386 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
387 public static String checkNamespaceCollision(Namespace namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
388 Attribute attribute) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
389 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
390 if (!attribute.getNamespace().equals(Namespace.NO_NAMESPACE)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
391 reason = checkNamespaceCollision(namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
392 attribute.getNamespace());
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
393 if (reason != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
394 reason += " with an attribute namespace prefix on the element";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
395 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
396 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
397 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
398 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
399
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
400 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
401 * Check if a <code>{@link Namespace}</code> collides with any namespace
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
402 * from a list of objects.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
403 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
404 * @param namespace <code>Namespace</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
405 * @param list <code>List</code> to check against.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
406 * @return <code>String</code> reason for collision, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
407 * <code>null</code> if no collision.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
408 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
409 public static String checkNamespaceCollision(Namespace namespace,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
410 List list) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
411 if (list == null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
412 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
413 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
414
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
415 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
416 Iterator i = list.iterator();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
417 while ((reason == null) && i.hasNext()) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
418 Object obj = i.next();
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
419 if (obj instanceof Attribute) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
420 reason = checkNamespaceCollision(namespace, (Attribute) obj);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
421 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
422 else if (obj instanceof Element) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
423 reason = checkNamespaceCollision(namespace, (Element) obj);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
424 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
425 else if (obj instanceof Namespace) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
426 reason = checkNamespaceCollision(namespace, (Namespace) obj);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
427 if (reason != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
428 reason += " with an additional namespace declared" +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
429 " by the element";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
430 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
431 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
432 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
433 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
434 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
435
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
436 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
437 * This will check the supplied data to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
438 * a JDOM <code>{@link ProcessingInstruction}</code> target.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
439 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
440 * @param target <code>String</code> target to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
441 * @return <code>String</code> reason target is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
442 * <code>null</code> if target is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
443 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
444 public static String checkProcessingInstructionTarget(String target) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
445 // Check basic XML name rules first
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
446 String reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
447 if ((reason = checkXMLName(target)) != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
448 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
449 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
450
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
451 // No colons allowed, per Namespace Specification Section 6
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
452 if (target.indexOf(":") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
453 return "Processing instruction targets cannot contain colons";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
454 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
455
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
456 // Cannot begin with 'xml' in any case
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
457 if (target.equalsIgnoreCase("xml")) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
458 return "Processing instructions cannot have a target of " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
459 "\"xml\" in any combination of case. (Note that the " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
460 "\"<?xml ... ?>\" declaration at the beginning of a " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
461 "document is not a processing instruction and should not " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
462 "be added as one; it is written automatically during " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
463 "output, e.g. by XMLOutputter.)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
464 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
465
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
466 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
467 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
468 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
469
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
470 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
471 * This will check the supplied data to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
472 * <code>{@link ProcessingInstruction}</code> data. Besides checking that
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
473 * all the characters are allowed in XML, this also checks
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
474 * that the data does not contain the PI end-string "?&gt;".
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
475 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
476 * @param data <code>String</code> data to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
477 * @return <code>String</code> reason data is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
478 * <code>null</code> if data is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
479 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
480 public static String checkProcessingInstructionData(String data) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
481 // Check basic XML name rules first
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
482 String reason = checkCharacterData(data);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
483
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
484 if (reason == null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
485 if (data.indexOf("?>") >= 0) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
486 return "Processing instructions cannot contain " +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
487 "the string \"?>\"";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
488 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
489 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
490
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
491 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
492 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
493
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
494 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
495 * This will check the supplied data to see if it is legal for use as
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
496 * JDOM <code>{@link Comment}</code> data.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
497 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
498 * @param data <code>String</code> data to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
499 * @return <code>String</code> reason data is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
500 * <code>null</code> if data is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
501 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
502 public static String checkCommentData(String data) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
503 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
504 if ((reason = checkCharacterData(data)) != null) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
505 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
506 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
507
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
508 if (data.indexOf("--") != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
509 return "Comments cannot contain double hyphens (--)";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
510 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
511 if (data.endsWith("-")) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
512 return "Comment data cannot end with a hyphen.";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
513 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
514
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
515 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
516 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
517 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
518 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
519 * This is a utility function to decode a non-BMP
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
520 * UTF-16 surrogate pair.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
521 * @param high high 16 bits
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
522 * @param low low 16 bits
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
523 * @return decoded character
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
524 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
525 public static int decodeSurrogatePair(char high, char low) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
526 return 0x10000 + (high - 0xD800) * 0x400 + (low - 0xDC00);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
527 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
528
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
529 // [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] |
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
530 // [-'()+,./:=?;*#@$_%]
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
531 public static boolean isXMLPublicIDCharacter(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
532
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
533 if (c >= 'a' && c <= 'z') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
534 if (c >= '?' && c <= 'Z') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
535 if (c >= '\'' && c <= ';') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
536
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
537 if (c == ' ') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
538 if (c == '!') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
539 if (c == '=') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
540 if (c == '#') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
541 if (c == '$') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
542 if (c == '_') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
543 if (c == '%') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
544 if (c == '\n') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
545 if (c == '\r') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
546 if (c == '\t') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
547
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
548 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
549 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
550
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
551 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
552 * This will ensure that the data for a public identifier
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
553 * is legal.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
554 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
555 * @param publicID <code>String</code> public ID to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
556 * @return <code>String</code> reason public ID is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
557 * <code>null</code> if public ID is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
558 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
559 public static String checkPublicID(String publicID) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
560 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
561
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
562 if (publicID == null) return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
563 // This indicates there is no public ID
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
564
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
565 for (int i = 0; i < publicID.length(); i++) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
566 char c = publicID.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
567 if (!isXMLPublicIDCharacter(c)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
568 reason = c + " is not a legal character in public IDs";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
569 break;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
570 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
571 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
572
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
573 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
574 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
575
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
576
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
577 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
578 * This will ensure that the data for a system literal
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
579 * is legal.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
580 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
581 * @param systemLiteral <code>String</code> system literal to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
582 * @return <code>String</code> reason system literal is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
583 * <code>null</code> if system literal is OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
584 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
585 public static String checkSystemLiteral(String systemLiteral) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
586 String reason = null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
587
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
588 if (systemLiteral == null) return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
589 // This indicates there is no system ID
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
590
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
591 if (systemLiteral.indexOf('\'') != -1
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
592 && systemLiteral.indexOf('"') != -1) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
593 reason =
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
594 "System literals cannot simultaneously contain both single and double quotes.";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
595 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
596 else {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
597 reason = checkCharacterData(systemLiteral);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
598 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
599
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
600 return reason;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
601 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
602
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
603 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
604 * This is a utility function for sharing the base process of checking
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
605 * any XML name.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
606 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
607 * @param name <code>String</code> to check for XML name compliance.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
608 * @return <code>String</code> reason the name is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
609 * <code>null</code> if OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
610 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
611 public static String checkXMLName(String name) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
612 // Cannot be empty or null
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
613 if ((name == null) || (name.length() == 0)
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
614 || (name.trim().equals(""))) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
615 return "XML names cannot be null or empty";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
616 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
617
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
618
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
619 // Cannot start with a number
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
620 char first = name.charAt(0);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
621 if (!isXMLNameStartCharacter(first)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
622 return "XML names cannot begin with the character \"" +
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
623 first + "\"";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
624 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
625 // Ensure legal content for non-first chars
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
626 for (int i=1, len = name.length(); i<len; i++) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
627 char c = name.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
628 if (!isXMLNameCharacter(c)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
629 return "XML names cannot contain the character \"" + c + "\"";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
630 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
631 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
632
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
633 // We got here, so everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
634 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
635 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
636
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
637 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
638 * <p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
639 * Checks a string to see if it is a legal RFC 2396 URI.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
640 * Both absolute and relative URIs are supported.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
641 * </p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
642 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
643 * @param uri <code>String</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
644 * @return <code>String</code> reason the URI is illegal, or
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
645 * <code>null</code> if OK.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
646 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
647 public static String checkURI(String uri) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
648 // URIs can be null or empty
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
649 if ((uri == null) || (uri.equals(""))) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
650 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
651 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
652
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
653 for (int i = 0; i < uri.length(); i++) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
654 char test = uri.charAt(i);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
655 if (!isURICharacter(test)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
656 String msgNumber = "0x" + Integer.toHexString(test);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
657 if (test <= 0x09) msgNumber = "0x0" + Integer.toHexString(test);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
658 return "URIs cannot contain " + msgNumber;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
659 } // end if
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
660 if (test == '%') { // must be followed by two hexadecimal digits
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
661 try {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
662 char firstDigit = uri.charAt(i+1);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
663 char secondDigit = uri.charAt(i+2);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
664 if (!isHexDigit(firstDigit) ||
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
665 !isHexDigit(secondDigit)) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
666 return "Percent signs in URIs must be followed by "
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
667 + "exactly two hexadecimal digits.";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
668 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
669
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
670 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
671 catch (StringIndexOutOfBoundsException e) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
672 return "Percent signs in URIs must be followed by "
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
673 + "exactly two hexadecimal digits.";
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
674 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
675 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
676 } // end for
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
677
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
678 // If we got here, everything is OK
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
679 return null;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
680 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
681
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
682 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
683 * <p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
684 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
685 * Unicode character is a hexadecimal digit as defined in RFC 2396;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
686 * that is, one of the ASCII characters 0-9, a-f, or A-F.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
687 * </p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
688 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
689 * @param c to check for hex digit.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
690 * @return true if it's allowed, false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
691 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
692 public static boolean isHexDigit(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
693
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
694 // I suspect most characters passed to this method will be
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
695 // correct hexadecimal digits, so I test for the true cases
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
696 // first. If this proves to be a performance bottleneck
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
697 // a switch statement or lookup table
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
698 // might optimize this.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
699 if (c >= '0' && c <= '9') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
700 if (c >= 'A' && c <= 'F') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
701 if (c >= 'a' && c <= 'f') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
702
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
703 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
704 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
705
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
706 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
707 * This is a function for determining whether the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
708 * specified character is the high 16 bits in a
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
709 * UTF-16 surrogate pair.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
710 * @param ch character to check
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
711 * @return true if the character is a high surrogate, false otherwise
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
712 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
713 public static boolean isHighSurrogate(char ch) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
714 return (ch >= 0xD800 && ch <= 0xDBFF);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
715 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
716
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
717 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
718 * This is a function for determining whether the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
719 * specified character is the low 16 bits in a
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
720 * UTF-16 surrogate pair.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
721 * @param ch character to check
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
722 * @return true if the character is a low surrogate, false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
723 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
724 public static boolean isLowSurrogate(char ch) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
725 return (ch >= 0xDC00 && ch <= 0xDFFF);
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
726 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
727
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
728 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
729 * <p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
730 * This is a utility function for determining whether
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
731 * a specified Unicode character is legal in URI references
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
732 * as determined by RFC 2396.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
733 * </p>
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
734 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
735 * @param c <code>char</code> to check for URI reference compliance.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
736 * @return true if it's allowed, false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
737 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
738 public static boolean isURICharacter(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
739 if (c >= 'a' && c <= 'z') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
740 if (c >= 'A' && c <= 'Z') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
741 if (c >= '0' && c <= '9') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
742 if (c == '/') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
743 if (c == '-') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
744 if (c == '.') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
745 if (c == '?') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
746 if (c == ':') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
747 if (c == '@') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
748 if (c == '&') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
749 if (c == '=') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
750 if (c == '+') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
751 if (c == '$') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
752 if (c == ',') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
753 if (c == '%') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
754
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
755 if (c == '_') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
756 if (c == '!') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
757 if (c == '~') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
758 if (c == '*') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
759 if (c == '\'') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
760 if (c == '(') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
761 if (c == ')') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
762 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
763 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
764
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
765 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
766 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
767 * character is a character according to production 2 of the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
768 * XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
769 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
770 * @param c <code>char</code> to check for XML compliance
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
771 * @return <code>boolean</code> true if it's a character,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
772 * false otherwise
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
773 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
774 public static boolean isXMLCharacter(int c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
775
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
776 if (c == '\n') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
777 if (c == '\r') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
778 if (c == '\t') return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
779
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
780 if (c < 0x20) return false; if (c <= 0xD7FF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
781 if (c < 0xE000) return false; if (c <= 0xFFFD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
782 if (c < 0x10000) return false; if (c <= 0x10FFFF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
783
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
784 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
785 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
786
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
787
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
788 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
789 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
790 * character is a name character according to production 4 of the
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
791 * XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
792 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
793 * @param c <code>char</code> to check for XML name compliance.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
794 * @return <code>boolean</code> true if it's a name character,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
795 * false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
796 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
797 public static boolean isXMLNameCharacter(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
798
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
799 return (isXMLLetter(c) || isXMLDigit(c) || c == '.' || c == '-'
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
800 || c == '_' || c == ':' || isXMLCombiningChar(c)
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
801 || isXMLExtender(c));
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
802 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
803
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
804 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
805 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
806 * character is a legal name start character according to production 5
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
807 * of the XML 1.0 specification. This production does allow names
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
808 * to begin with colons which the Namespaces in XML Recommendation
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
809 * disallows.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
810 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
811 * @param c <code>char</code> to check for XML name start compliance.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
812 * @return <code>boolean</code> true if it's a name start character,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
813 * false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
814 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
815 public static boolean isXMLNameStartCharacter(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
816
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
817 return (isXMLLetter(c) || c == '_' || c ==':');
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
818
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
819 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
820
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
821 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
822 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
823 * character is a letter or digit according to productions 84 and 88
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
824 * of the XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
825 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
826 * @param c <code>char</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
827 * @return <code>boolean</code> true if it's letter or digit,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
828 * false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
829 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
830 public static boolean isXMLLetterOrDigit(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
831
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
832 return (isXMLLetter(c) || isXMLDigit(c));
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
833
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
834 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
835
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
836 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
837 * This is a utility function for determining whether a specified character
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
838 * is a letter according to production 84 of the XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
839 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
840 * @param c <code>char</code> to check for XML name compliance.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
841 * @return <code>String</code> true if it's a letter, false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
842 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
843 public static boolean isXMLLetter(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
844 // Note that order is very important here. The search proceeds
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
845 // from lowest to highest values, so that no searching occurs
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
846 // above the character's value. BTW, the first line is equivalent to:
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
847 // if (c >= 0x0041 && c <= 0x005A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
848
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
849 if (c < 0x0041) return false; if (c <= 0x005a) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
850 if (c < 0x0061) return false; if (c <= 0x007A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
851 if (c < 0x00C0) return false; if (c <= 0x00D6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
852 if (c < 0x00D8) return false; if (c <= 0x00F6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
853 if (c < 0x00F8) return false; if (c <= 0x00FF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
854 if (c < 0x0100) return false; if (c <= 0x0131) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
855 if (c < 0x0134) return false; if (c <= 0x013E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
856 if (c < 0x0141) return false; if (c <= 0x0148) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
857 if (c < 0x014A) return false; if (c <= 0x017E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
858 if (c < 0x0180) return false; if (c <= 0x01C3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
859 if (c < 0x01CD) return false; if (c <= 0x01F0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
860 if (c < 0x01F4) return false; if (c <= 0x01F5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
861 if (c < 0x01FA) return false; if (c <= 0x0217) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
862 if (c < 0x0250) return false; if (c <= 0x02A8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
863 if (c < 0x02BB) return false; if (c <= 0x02C1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
864 if (c == 0x0386) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
865 if (c < 0x0388) return false; if (c <= 0x038A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
866 if (c == 0x038C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
867 if (c < 0x038E) return false; if (c <= 0x03A1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
868 if (c < 0x03A3) return false; if (c <= 0x03CE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
869 if (c < 0x03D0) return false; if (c <= 0x03D6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
870 if (c == 0x03DA) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
871 if (c == 0x03DC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
872 if (c == 0x03DE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
873 if (c == 0x03E0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
874 if (c < 0x03E2) return false; if (c <= 0x03F3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
875 if (c < 0x0401) return false; if (c <= 0x040C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
876 if (c < 0x040E) return false; if (c <= 0x044F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
877 if (c < 0x0451) return false; if (c <= 0x045C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
878 if (c < 0x045E) return false; if (c <= 0x0481) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
879 if (c < 0x0490) return false; if (c <= 0x04C4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
880 if (c < 0x04C7) return false; if (c <= 0x04C8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
881 if (c < 0x04CB) return false; if (c <= 0x04CC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
882 if (c < 0x04D0) return false; if (c <= 0x04EB) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
883 if (c < 0x04EE) return false; if (c <= 0x04F5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
884 if (c < 0x04F8) return false; if (c <= 0x04F9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
885 if (c < 0x0531) return false; if (c <= 0x0556) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
886 if (c == 0x0559) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
887 if (c < 0x0561) return false; if (c <= 0x0586) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
888 if (c < 0x05D0) return false; if (c <= 0x05EA) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
889 if (c < 0x05F0) return false; if (c <= 0x05F2) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
890 if (c < 0x0621) return false; if (c <= 0x063A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
891 if (c < 0x0641) return false; if (c <= 0x064A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
892 if (c < 0x0671) return false; if (c <= 0x06B7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
893 if (c < 0x06BA) return false; if (c <= 0x06BE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
894 if (c < 0x06C0) return false; if (c <= 0x06CE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
895 if (c < 0x06D0) return false; if (c <= 0x06D3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
896 if (c == 0x06D5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
897 if (c < 0x06E5) return false; if (c <= 0x06E6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
898 if (c < 0x0905) return false; if (c <= 0x0939) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
899 if (c == 0x093D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
900 if (c < 0x0958) return false; if (c <= 0x0961) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
901 if (c < 0x0985) return false; if (c <= 0x098C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
902 if (c < 0x098F) return false; if (c <= 0x0990) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
903 if (c < 0x0993) return false; if (c <= 0x09A8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
904 if (c < 0x09AA) return false; if (c <= 0x09B0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
905 if (c == 0x09B2) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
906 if (c < 0x09B6) return false; if (c <= 0x09B9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
907 if (c < 0x09DC) return false; if (c <= 0x09DD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
908 if (c < 0x09DF) return false; if (c <= 0x09E1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
909 if (c < 0x09F0) return false; if (c <= 0x09F1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
910 if (c < 0x0A05) return false; if (c <= 0x0A0A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
911 if (c < 0x0A0F) return false; if (c <= 0x0A10) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
912 if (c < 0x0A13) return false; if (c <= 0x0A28) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
913 if (c < 0x0A2A) return false; if (c <= 0x0A30) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
914 if (c < 0x0A32) return false; if (c <= 0x0A33) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
915 if (c < 0x0A35) return false; if (c <= 0x0A36) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
916 if (c < 0x0A38) return false; if (c <= 0x0A39) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
917 if (c < 0x0A59) return false; if (c <= 0x0A5C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
918 if (c == 0x0A5E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
919 if (c < 0x0A72) return false; if (c <= 0x0A74) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
920 if (c < 0x0A85) return false; if (c <= 0x0A8B) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
921 if (c == 0x0A8D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
922 if (c < 0x0A8F) return false; if (c <= 0x0A91) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
923 if (c < 0x0A93) return false; if (c <= 0x0AA8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
924 if (c < 0x0AAA) return false; if (c <= 0x0AB0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
925 if (c < 0x0AB2) return false; if (c <= 0x0AB3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
926 if (c < 0x0AB5) return false; if (c <= 0x0AB9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
927 if (c == 0x0ABD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
928 if (c == 0x0AE0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
929 if (c < 0x0B05) return false; if (c <= 0x0B0C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
930 if (c < 0x0B0F) return false; if (c <= 0x0B10) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
931 if (c < 0x0B13) return false; if (c <= 0x0B28) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
932 if (c < 0x0B2A) return false; if (c <= 0x0B30) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
933 if (c < 0x0B32) return false; if (c <= 0x0B33) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
934 if (c < 0x0B36) return false; if (c <= 0x0B39) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
935 if (c == 0x0B3D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
936 if (c < 0x0B5C) return false; if (c <= 0x0B5D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
937 if (c < 0x0B5F) return false; if (c <= 0x0B61) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
938 if (c < 0x0B85) return false; if (c <= 0x0B8A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
939 if (c < 0x0B8E) return false; if (c <= 0x0B90) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
940 if (c < 0x0B92) return false; if (c <= 0x0B95) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
941 if (c < 0x0B99) return false; if (c <= 0x0B9A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
942 if (c == 0x0B9C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
943 if (c < 0x0B9E) return false; if (c <= 0x0B9F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
944 if (c < 0x0BA3) return false; if (c <= 0x0BA4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
945 if (c < 0x0BA8) return false; if (c <= 0x0BAA) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
946 if (c < 0x0BAE) return false; if (c <= 0x0BB5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
947 if (c < 0x0BB7) return false; if (c <= 0x0BB9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
948 if (c < 0x0C05) return false; if (c <= 0x0C0C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
949 if (c < 0x0C0E) return false; if (c <= 0x0C10) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
950 if (c < 0x0C12) return false; if (c <= 0x0C28) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
951 if (c < 0x0C2A) return false; if (c <= 0x0C33) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
952 if (c < 0x0C35) return false; if (c <= 0x0C39) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
953 if (c < 0x0C60) return false; if (c <= 0x0C61) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
954 if (c < 0x0C85) return false; if (c <= 0x0C8C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
955 if (c < 0x0C8E) return false; if (c <= 0x0C90) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
956 if (c < 0x0C92) return false; if (c <= 0x0CA8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
957 if (c < 0x0CAA) return false; if (c <= 0x0CB3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
958 if (c < 0x0CB5) return false; if (c <= 0x0CB9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
959 if (c == 0x0CDE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
960 if (c < 0x0CE0) return false; if (c <= 0x0CE1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
961 if (c < 0x0D05) return false; if (c <= 0x0D0C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
962 if (c < 0x0D0E) return false; if (c <= 0x0D10) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
963 if (c < 0x0D12) return false; if (c <= 0x0D28) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
964 if (c < 0x0D2A) return false; if (c <= 0x0D39) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
965 if (c < 0x0D60) return false; if (c <= 0x0D61) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
966 if (c < 0x0E01) return false; if (c <= 0x0E2E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
967 if (c == 0x0E30) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
968 if (c < 0x0E32) return false; if (c <= 0x0E33) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
969 if (c < 0x0E40) return false; if (c <= 0x0E45) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
970 if (c < 0x0E81) return false; if (c <= 0x0E82) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
971 if (c == 0x0E84) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
972 if (c < 0x0E87) return false; if (c <= 0x0E88) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
973 if (c == 0x0E8A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
974 if (c == 0x0E8D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
975 if (c < 0x0E94) return false; if (c <= 0x0E97) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
976 if (c < 0x0E99) return false; if (c <= 0x0E9F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
977 if (c < 0x0EA1) return false; if (c <= 0x0EA3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
978 if (c == 0x0EA5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
979 if (c == 0x0EA7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
980 if (c < 0x0EAA) return false; if (c <= 0x0EAB) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
981 if (c < 0x0EAD) return false; if (c <= 0x0EAE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
982 if (c == 0x0EB0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
983 if (c < 0x0EB2) return false; if (c <= 0x0EB3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
984 if (c == 0x0EBD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
985 if (c < 0x0EC0) return false; if (c <= 0x0EC4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
986 if (c < 0x0F40) return false; if (c <= 0x0F47) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
987 if (c < 0x0F49) return false; if (c <= 0x0F69) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
988 if (c < 0x10A0) return false; if (c <= 0x10C5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
989 if (c < 0x10D0) return false; if (c <= 0x10F6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
990 if (c == 0x1100) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
991 if (c < 0x1102) return false; if (c <= 0x1103) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
992 if (c < 0x1105) return false; if (c <= 0x1107) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
993 if (c == 0x1109) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
994 if (c < 0x110B) return false; if (c <= 0x110C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
995 if (c < 0x110E) return false; if (c <= 0x1112) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
996 if (c == 0x113C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
997 if (c == 0x113E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
998 if (c == 0x1140) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
999 if (c == 0x114C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1000 if (c == 0x114E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1001 if (c == 0x1150) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1002 if (c < 0x1154) return false; if (c <= 0x1155) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1003 if (c == 0x1159) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1004 if (c < 0x115F) return false; if (c <= 0x1161) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1005 if (c == 0x1163) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1006 if (c == 0x1165) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1007 if (c == 0x1167) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1008 if (c == 0x1169) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1009 if (c < 0x116D) return false; if (c <= 0x116E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1010 if (c < 0x1172) return false; if (c <= 0x1173) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1011 if (c == 0x1175) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1012 if (c == 0x119E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1013 if (c == 0x11A8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1014 if (c == 0x11AB) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1015 if (c < 0x11AE) return false; if (c <= 0x11AF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1016 if (c < 0x11B7) return false; if (c <= 0x11B8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1017 if (c == 0x11BA) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1018 if (c < 0x11BC) return false; if (c <= 0x11C2) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1019 if (c == 0x11EB) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1020 if (c == 0x11F0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1021 if (c == 0x11F9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1022 if (c < 0x1E00) return false; if (c <= 0x1E9B) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1023 if (c < 0x1EA0) return false; if (c <= 0x1EF9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1024 if (c < 0x1F00) return false; if (c <= 0x1F15) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1025 if (c < 0x1F18) return false; if (c <= 0x1F1D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1026 if (c < 0x1F20) return false; if (c <= 0x1F45) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1027 if (c < 0x1F48) return false; if (c <= 0x1F4D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1028 if (c < 0x1F50) return false; if (c <= 0x1F57) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1029 if (c == 0x1F59) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1030 if (c == 0x1F5B) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1031 if (c == 0x1F5D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1032 if (c < 0x1F5F) return false; if (c <= 0x1F7D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1033 if (c < 0x1F80) return false; if (c <= 0x1FB4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1034 if (c < 0x1FB6) return false; if (c <= 0x1FBC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1035 if (c == 0x1FBE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1036 if (c < 0x1FC2) return false; if (c <= 0x1FC4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1037 if (c < 0x1FC6) return false; if (c <= 0x1FCC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1038 if (c < 0x1FD0) return false; if (c <= 0x1FD3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1039 if (c < 0x1FD6) return false; if (c <= 0x1FDB) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1040 if (c < 0x1FE0) return false; if (c <= 0x1FEC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1041 if (c < 0x1FF2) return false; if (c <= 0x1FF4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1042 if (c < 0x1FF6) return false; if (c <= 0x1FFC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1043 if (c == 0x2126) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1044 if (c < 0x212A) return false; if (c <= 0x212B) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1045 if (c == 0x212E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1046 if (c < 0x2180) return false; if (c <= 0x2182) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1047 if (c == 0x3007) return true; // ideographic
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1048 if (c < 0x3021) return false; if (c <= 0x3029) return true; // ideo
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1049 if (c < 0x3041) return false; if (c <= 0x3094) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1050 if (c < 0x30A1) return false; if (c <= 0x30FA) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1051 if (c < 0x3105) return false; if (c <= 0x312C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1052 if (c < 0x4E00) return false; if (c <= 0x9FA5) return true; // ideo
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1053 if (c < 0xAC00) return false; if (c <= 0xD7A3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1054
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1055 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1056
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1057 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1058
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1059 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1060 * This is a utility function for determining whether a specified character
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1061 * is a combining character according to production 87
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1062 * of the XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1063 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1064 * @param c <code>char</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1065 * @return <code>boolean</code> true if it's a combining character,
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1066 * false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1067 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1068 public static boolean isXMLCombiningChar(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1069 // CombiningChar
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1070 if (c < 0x0300) return false; if (c <= 0x0345) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1071 if (c < 0x0360) return false; if (c <= 0x0361) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1072 if (c < 0x0483) return false; if (c <= 0x0486) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1073 if (c < 0x0591) return false; if (c <= 0x05A1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1074
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1075 if (c < 0x05A3) return false; if (c <= 0x05B9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1076 if (c < 0x05BB) return false; if (c <= 0x05BD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1077 if (c == 0x05BF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1078 if (c < 0x05C1) return false; if (c <= 0x05C2) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1079
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1080 if (c == 0x05C4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1081 if (c < 0x064B) return false; if (c <= 0x0652) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1082 if (c == 0x0670) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1083 if (c < 0x06D6) return false; if (c <= 0x06DC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1084
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1085 if (c < 0x06DD) return false; if (c <= 0x06DF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1086 if (c < 0x06E0) return false; if (c <= 0x06E4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1087 if (c < 0x06E7) return false; if (c <= 0x06E8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1088
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1089 if (c < 0x06EA) return false; if (c <= 0x06ED) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1090 if (c < 0x0901) return false; if (c <= 0x0903) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1091 if (c == 0x093C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1092 if (c < 0x093E) return false; if (c <= 0x094C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1093
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1094 if (c == 0x094D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1095 if (c < 0x0951) return false; if (c <= 0x0954) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1096 if (c < 0x0962) return false; if (c <= 0x0963) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1097 if (c < 0x0981) return false; if (c <= 0x0983) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1098
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1099 if (c == 0x09BC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1100 if (c == 0x09BE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1101 if (c == 0x09BF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1102 if (c < 0x09C0) return false; if (c <= 0x09C4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1103 if (c < 0x09C7) return false; if (c <= 0x09C8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1104
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1105 if (c < 0x09CB) return false; if (c <= 0x09CD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1106 if (c == 0x09D7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1107 if (c < 0x09E2) return false; if (c <= 0x09E3) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1108 if (c == 0x0A02) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1109 if (c == 0x0A3C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1110
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1111 if (c == 0x0A3E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1112 if (c == 0x0A3F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1113 if (c < 0x0A40) return false; if (c <= 0x0A42) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1114 if (c < 0x0A47) return false; if (c <= 0x0A48) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1115
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1116 if (c < 0x0A4B) return false; if (c <= 0x0A4D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1117 if (c < 0x0A70) return false; if (c <= 0x0A71) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1118 if (c < 0x0A81) return false; if (c <= 0x0A83) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1119 if (c == 0x0ABC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1120
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1121 if (c < 0x0ABE) return false; if (c <= 0x0AC5) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1122 if (c < 0x0AC7) return false; if (c <= 0x0AC9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1123 if (c < 0x0ACB) return false; if (c <= 0x0ACD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1124
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1125 if (c < 0x0B01) return false; if (c <= 0x0B03) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1126 if (c == 0x0B3C) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1127 if (c < 0x0B3E) return false; if (c <= 0x0B43) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1128 if (c < 0x0B47) return false; if (c <= 0x0B48) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1129
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1130 if (c < 0x0B4B) return false; if (c <= 0x0B4D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1131 if (c < 0x0B56) return false; if (c <= 0x0B57) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1132 if (c < 0x0B82) return false; if (c <= 0x0B83) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1133
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1134 if (c < 0x0BBE) return false; if (c <= 0x0BC2) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1135 if (c < 0x0BC6) return false; if (c <= 0x0BC8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1136 if (c < 0x0BCA) return false; if (c <= 0x0BCD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1137 if (c == 0x0BD7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1138
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1139 if (c < 0x0C01) return false; if (c <= 0x0C03) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1140 if (c < 0x0C3E) return false; if (c <= 0x0C44) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1141 if (c < 0x0C46) return false; if (c <= 0x0C48) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1142
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1143 if (c < 0x0C4A) return false; if (c <= 0x0C4D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1144 if (c < 0x0C55) return false; if (c <= 0x0C56) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1145 if (c < 0x0C82) return false; if (c <= 0x0C83) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1146
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1147 if (c < 0x0CBE) return false; if (c <= 0x0CC4) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1148 if (c < 0x0CC6) return false; if (c <= 0x0CC8) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1149 if (c < 0x0CCA) return false; if (c <= 0x0CCD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1150
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1151 if (c < 0x0CD5) return false; if (c <= 0x0CD6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1152 if (c < 0x0D02) return false; if (c <= 0x0D03) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1153 if (c < 0x0D3E) return false; if (c <= 0x0D43) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1154
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1155 if (c < 0x0D46) return false; if (c <= 0x0D48) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1156 if (c < 0x0D4A) return false; if (c <= 0x0D4D) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1157 if (c == 0x0D57) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1158 if (c == 0x0E31) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1159
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1160 if (c < 0x0E34) return false; if (c <= 0x0E3A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1161 if (c < 0x0E47) return false; if (c <= 0x0E4E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1162 if (c == 0x0EB1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1163 if (c < 0x0EB4) return false; if (c <= 0x0EB9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1164
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1165 if (c < 0x0EBB) return false; if (c <= 0x0EBC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1166 if (c < 0x0EC8) return false; if (c <= 0x0ECD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1167 if (c < 0x0F18) return false; if (c <= 0x0F19) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1168 if (c == 0x0F35) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1169
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1170 if (c == 0x0F37) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1171 if (c == 0x0F39) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1172 if (c == 0x0F3E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1173 if (c == 0x0F3F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1174 if (c < 0x0F71) return false; if (c <= 0x0F84) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1175
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1176 if (c < 0x0F86) return false; if (c <= 0x0F8B) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1177 if (c < 0x0F90) return false; if (c <= 0x0F95) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1178 if (c == 0x0F97) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1179 if (c < 0x0F99) return false; if (c <= 0x0FAD) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1180
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1181 if (c < 0x0FB1) return false; if (c <= 0x0FB7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1182 if (c == 0x0FB9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1183 if (c < 0x20D0) return false; if (c <= 0x20DC) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1184 if (c == 0x20E1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1185
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1186 if (c < 0x302A) return false; if (c <= 0x302F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1187 if (c == 0x3099) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1188 if (c == 0x309A) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1189
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1190 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1191
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1192 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1193
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1194 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1195 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1196 * character is an extender according to production 88 of the XML 1.0
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1197 * specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1198 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1199 * @param c <code>char</code> to check.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1200 * @return <code>String</code> true if it's an extender, false otherwise.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1201 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1202 public static boolean isXMLExtender(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1203
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1204 if (c < 0x00B6) return false; // quick short circuit
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1205
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1206 // Extenders
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1207 if (c == 0x00B7) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1208 if (c == 0x02D0) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1209 if (c == 0x02D1) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1210 if (c == 0x0387) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1211 if (c == 0x0640) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1212 if (c == 0x0E46) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1213 if (c == 0x0EC6) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1214 if (c == 0x3005) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1215
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1216 if (c < 0x3031) return false; if (c <= 0x3035) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1217 if (c < 0x309D) return false; if (c <= 0x309E) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1218 if (c < 0x30FC) return false; if (c <= 0x30FE) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1219
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1220 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1221
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1222 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1223
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1224 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1225 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1226 * Unicode character
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1227 * is a digit according to production 88 of the XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1228 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1229 * @param c <code>char</code> to check for XML digit compliance
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1230 * @return <code>boolean</code> true if it's a digit, false otherwise
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1231 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1232 public static boolean isXMLDigit(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1233
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1234 if (c < 0x0030) return false; if (c <= 0x0039) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1235 if (c < 0x0660) return false; if (c <= 0x0669) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1236 if (c < 0x06F0) return false; if (c <= 0x06F9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1237 if (c < 0x0966) return false; if (c <= 0x096F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1238
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1239 if (c < 0x09E6) return false; if (c <= 0x09EF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1240 if (c < 0x0A66) return false; if (c <= 0x0A6F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1241 if (c < 0x0AE6) return false; if (c <= 0x0AEF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1242
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1243 if (c < 0x0B66) return false; if (c <= 0x0B6F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1244 if (c < 0x0BE7) return false; if (c <= 0x0BEF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1245 if (c < 0x0C66) return false; if (c <= 0x0C6F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1246
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1247 if (c < 0x0CE6) return false; if (c <= 0x0CEF) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1248 if (c < 0x0D66) return false; if (c <= 0x0D6F) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1249 if (c < 0x0E50) return false; if (c <= 0x0E59) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1250
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1251 if (c < 0x0ED0) return false; if (c <= 0x0ED9) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1252 if (c < 0x0F20) return false; if (c <= 0x0F29) return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1253
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1254 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1255 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1256
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1257 /**
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1258 * This is a utility function for determining whether a specified
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1259 * Unicode character is a whitespace character according to production 3
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1260 * of the XML 1.0 specification.
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1261 *
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1262 * @param c <code>char</code> to check for XML whitespace compliance
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1263 * @return <code>boolean</code> true if it's a whitespace, false otherwise
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1264 */
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1265 public static boolean isXMLWhitespace(char c) {
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1266 if (c==' ' || c=='\n' || c=='\t' || c=='\r' ){
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1267 return true;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1268 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1269 return false;
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1270 }
89ad0a9cca52 Uploaded
pfrommolt
parents:
diff changeset
1271 }