325N/A * reserved comment block 325N/A * DO NOT REMOVE OR ALTER! 325N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 325N/A * This code is free software; you can redistribute it and/or modify it 325N/A * under the terms of the GNU General Public License version 2 only, as 325N/A * published by the Free Software Foundation. Oracle designates this 325N/A * particular file as subject to the "Classpath" exception as provided 325N/A * by Oracle in the LICENSE file that accompanied this code. 325N/A * This code is distributed in the hope that it will be useful, but WITHOUT 325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 325N/A * version 2 for more details (a copy is included in the LICENSE file that 325N/A * accompanied this code). 325N/A * You should have received a copy of the GNU General Public License version 325N/A * 2 along with this work; if not, write to the Free Software Foundation, 325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 325N/A * or visit www.oracle.com if you need additional information or have any 325N/A * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. 325N/A * The Apache Software License, Version 1.1 325N/A * Copyright (c) 1999-2004 The Apache Software Foundation. All rights 325N/A * Redistribution and use in source and binary forms, with or without 325N/A * modification, are permitted provided that the following conditions 325N/A * 1. Redistributions of source code must retain the above copyright 325N/A * notice, this list of conditions and the following disclaimer. 325N/A * 2. Redistributions in binary form must reproduce the above copyright 325N/A * notice, this list of conditions and the following disclaimer in 325N/A * the documentation and/or other materials provided with the 325N/A * 3. The end-user documentation included with the redistribution, 325N/A * if any, must include the following acknowledgment: 325N/A * "This product includes software developed by the 325N/A * Alternately, this acknowledgment may appear in the software itself, 325N/A * if and wherever such third-party acknowledgments normally appear. 325N/A * 4. The names "Xerces" and "Apache Software Foundation" must 325N/A * not be used to endorse or promote products derived from this 325N/A * software without prior written permission. For written 325N/A * permission, please contact apache@apache.org. 325N/A * 5. Products derived from this software may not be called "Apache", 325N/A * nor may "Apache" appear in their name, without prior written 325N/A * permission of the Apache Software Foundation. 325N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 325N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 325N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 325N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 325N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 325N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 325N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 325N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 325N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 325N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 325N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 325N/A * ==================================================================== 325N/A * This software consists of voluntary contributions made by many 325N/A * individuals on behalf of the Apache Software Foundation and was 325N/A * originally based on software copyright (c) 1999, International 325N/A * information on the Apache Software Foundation, please see 325N/A * This class defines the basic XML character properties. The data 325N/A * in this class can be used to verify that a character is a valid 325N/A * XML character or if the character is a space, name start, or name 325N/A * A series of convenience methods are supplied to ease the burden 325N/A * of the developer. Because inlining the checks can improve per 325N/A * character performance, the tables of character properties are 325N/A * public. Using the character as an index into the <code>CHARS</code> 325N/A * array and applying the appropriate mask flag (e.g. 325N/A * <code>MASK_VALID</code>), yields the same results as calling the 325N/A * convenience methods. There is one exception: check the comments 325N/A * for the <code>isValid</code> method for details. 325N/A * @author Glenn Marcy, IBM 325N/A * @author Andy Clark, IBM 325N/A * @author Arnaud Le Hors, IBM 325N/A * @author Michael Glavassevich, IBM 325N/A * @author Rahul Srivastava, Sun Microsystems Inc. 325N/A /** Character flags. */ 325N/A private static final byte[]
CHARS =
new byte[
1 <<
16];
325N/A /** Valid character mask. */ 325N/A /** Space character mask. */ 325N/A /** Name start character mask. */ 325N/A /** Name character mask. */ 325N/A /** Pubid character mask. */ 325N/A * Content character mask. Special characters are those that can 325N/A * be considered the start of markup, such as '<' and '&'. 325N/A * The various newline characters are considered special as well. 325N/A * All other valid XML characters can be considered content. 325N/A * This is an optimization for the inner loop of character scanning. 325N/A /** NCName start character mask. */ 325N/A /** NCName character mask. */ 325N/A // Static initialization 325N/A // Initializing the Character Flag Array 325N/A // Code generated by: XMLCharGenerator. 325N/A // Public static methods 325N/A * Returns true if the specified character is a supplemental character. 325N/A * @param c The character to check. 325N/A return (c >=
0x10000 && c <=
0x10FFFF);
325N/A * Returns true the supplemental character corresponding to the given 325N/A * @param h The high surrogate. 325N/A * @param l The low surrogate. 325N/A return (h -
0xD800) *
0x400 + (l -
0xDC00) +
0x10000;
325N/A * Returns the high surrogate of a supplemental character 325N/A * @param c The supplemental character to "split". 325N/A return (
char) (((c -
0x00010000) >>
10) +
0xD800);
325N/A * Returns the low surrogate of a supplemental character 325N/A * @param c The supplemental character to "split". 325N/A return (
char) (((c -
0x00010000) &
0x3FF) +
0xDC00);
325N/A * Returns whether the given character is a high surrogate 325N/A * @param c The character to check. 325N/A return (
0xD800 <= c && c <=
0xDBFF);
325N/A * Returns whether the given character is a low surrogate 325N/A * @param c The character to check. 325N/A return (
0xDC00 <= c && c <=
0xDFFF);
325N/A * Returns true if the specified character is valid. This method 325N/A * also checks the surrogate character range from 0x10000 to 0x10FFFF. 325N/A * If the program chooses to apply the mask directly to the 325N/A * <code>CHARS</code> array, then they are responsible for checking 325N/A * the surrogate character range. 325N/A * @param c The character to check. 325N/A (
0x10000 <= c && c <=
0x10FFFF);
325N/A }
// isValid(int):boolean 325N/A * Returns true if the specified character is invalid. 325N/A * @param c The character to check. 325N/A }
// isInvalid(int):boolean 325N/A * Returns true if the specified character can be considered content. 325N/A * @param c The character to check. 325N/A (
0x10000 <= c && c <=
0x10FFFF);
325N/A }
// isContent(int):boolean 325N/A * Returns true if the specified character can be considered markup. 325N/A * Markup characters include '<', '&', and '%'. 325N/A * @param c The character to check. 325N/A return c ==
'<' || c ==
'&' || c ==
'%';
325N/A }
// isMarkup(int):boolean 325N/A * Returns true if the specified character is a space character 325N/A * as defined by production [3] in the XML 1.0 specification. 325N/A * @param c The character to check. 325N/A }
// isSpace(int):boolean 325N/A * Returns true if the specified character is a valid name start 325N/A * character as defined by production [5] in the XML 1.0 325N/A * @param c The character to check. 325N/A }
// isNameStart(int):boolean 325N/A * Returns true if the specified character is a valid name 325N/A * character as defined by production [4] in the XML 1.0 325N/A * @param c The character to check. 325N/A }
// isName(int):boolean 325N/A * Returns true if the specified character is a valid NCName start 325N/A * character as defined by production [4] in Namespaces in XML 325N/A * @param c The character to check. 325N/A }
// isNCNameStart(int):boolean 325N/A * Returns true if the specified character is a valid NCName 325N/A * character as defined by production [5] in Namespaces in XML 325N/A * @param c The character to check. 325N/A }
// isNCName(int):boolean 325N/A * Returns true if the specified character is a valid Pubid 325N/A * character as defined by production [13] in the XML 1.0 325N/A * @param c The character to check. 325N/A }
// isPubid(int):boolean 325N/A * [5] Name ::= (Letter | '_' | ':') (NameChar)* 325N/A * Check to see if a string is a valid Name according to [5] 325N/A * in the XML 1.0 Recommendation 325N/A * @param name string to check 325N/A * @return true if name is a valid Name 325N/A }
// isValidName(String):boolean 325N/A * from the namespace rec 325N/A * [4] NCName ::= (Letter | '_') (NCNameChar)* 325N/A * Check to see if a string is a valid NCName according to [4] 325N/A * from the XML Namespaces 1.0 Recommendation 325N/A * @param ncName string to check 325N/A * @return true if name is a valid NCName 325N/A }
// isValidNCName(String):boolean 325N/A * [7] Nmtoken ::= (NameChar)+ 325N/A * Check to see if a string is a valid Nmtoken according to [7] 325N/A * in the XML 1.0 Recommendation 325N/A * @param nmtoken string to check 325N/A * @return true if nmtoken is a valid Nmtoken 325N/A }
// isValidName(String):boolean 325N/A * Returns true if the encoding name is a valid IANA encoding. 325N/A * This method does not verify that there is a decoder available 325N/A * for this encoding, only that the characters are valid for an 325N/A * @param ianaEncoding The IANA encoding name. 325N/A if ((c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z')) {
325N/A if ((c <
'A' || c >
'Z') && (c <
'a' || c >
'z') &&
325N/A (c <
'0' || c >
'9') && c !=
'.' && c !=
'_' &&
325N/A }
// isValidIANAEncoding(String):boolean 325N/A * Returns true if the encoding name is a valid Java encoding. 325N/A * This method does not verify that there is a decoder available 325N/A * for this encoding, only that the characters are valid for an 325N/A * @param javaEncoding The Java encoding name. 325N/A if ((c <
'A' || c >
'Z') && (c <
'a' || c >
'z') &&
325N/A (c <
'0' || c >
'9') && c !=
'.' && c !=
'_' &&
325N/A }
// isValidIANAEncoding(String):boolean