/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* THIS IS A COPY OF THE XERCES-2J CLASS com.sun.org.apache.xerces.internal.utls.XMLChar
*
* This class defines the basic properties of characters in XML 1.1. The data
* in this class can be used to verify that a character is a valid
* XML 1.1 character or if the character is a space, name start, or name
* character.
* <p>
* A series of convenience methods are supplied to ease the burden
* of the developer. Using the character as an index into the <code>XML11CHARS</code>
* array and applying the appropriate mask flag (e.g.
* <code>MASK_VALID</code>), yields the same results as calling the
* convenience methods. There is one exception: check the comments
* for the <code>isValid</code> method for details.
*
*/
public class XML11Char {
//
// Constants
//
/** Character flags for XML 1.1. */
/** XML 1.1 Valid character mask. */
/** XML 1.1 Space character mask. */
/** XML 1.1 Name start character mask. */
/** XML 1.1 Name character mask. */
/** XML 1.1 control character mask */
/** XML 1.1 content for external entities (valid - "special" chars - control chars) */
/** XML namespaces 1.1 NCNameStart */
/** XML namespaces 1.1 NCName */
/** XML 1.1 content for internal entities (valid - "special" chars) */
//
// Static initialization
//
static {
// Initializing the Character Flag Array
// Code generated by: XML11CharGenerator.
} // <clinit>()
//
// Public static methods
//
/**
* Returns true if the specified character is a space character
* as amdended in the XML 1.1 specification.
*
* @param c The character to check.
*/
public static boolean isXML11Space(int c) {
} // isXML11Space(int):boolean
/**
* Returns true if the specified character is valid. This method
* also checks the surrogate character range from 0x10000 to 0x10FFFF.
* <p>
* If the program chooses to apply the mask directly to the
* <code>XML11CHARS</code> array, then they are responsible for checking
* the surrogate character range.
*
* @param c The character to check.
*/
public static boolean isXML11Valid(int c) {
|| (0x10000 <= c && c <= 0x10FFFF);
} // isXML11Valid(int):boolean
/**
* Returns true if the specified character is invalid.
*
* @param c The character to check.
*/
public static boolean isXML11Invalid(int c) {
return !isXML11Valid(c);
} // isXML11Invalid(int):boolean
/**
* Returns true if the specified character is valid and permitted outside
* of a character reference.
* That is, this method will return false for the same set as
* isXML11Valid, except it also reports false for "control characters".
*
* @param c The character to check.
*/
public static boolean isXML11ValidLiteral(int c) {
return ((c < 0x10000 && ((XML11CHARS[c] & MASK_XML11_VALID) != 0 && (XML11CHARS[c] & MASK_XML11_CONTROL) == 0))
|| (0x10000 <= c && c <= 0x10FFFF));
} // isXML11ValidLiteral(int):boolean
/**
* Returns true if the specified character can be considered
* content in an external parsed entity.
*
* @param c The character to check.
*/
public static boolean isXML11Content(int c) {
(0x10000 <= c && c <= 0x10FFFF);
} // isXML11Content(int):boolean
/**
* Returns true if the specified character can be considered
* content in an internal parsed entity.
*
* @param c The character to check.
*/
public static boolean isXML11InternalEntityContent(int c) {
(0x10000 <= c && c <= 0x10FFFF);
} // isXML11InternalEntityContent(int):boolean
/**
* Returns true if the specified character is a valid name start
* character as defined by production [4] in the XML 1.1
* specification.
*
* @param c The character to check.
*/
public static boolean isXML11NameStart(int c) {
|| (0x10000 <= c && c < 0xF0000);
} // isXML11NameStart(int):boolean
/**
* Returns true if the specified character is a valid name
* character as defined by production [4a] in the XML 1.1
* specification.
*
* @param c The character to check.
*/
public static boolean isXML11Name(int c) {
|| (c >= 0x10000 && c < 0xF0000);
} // isXML11Name(int):boolean
/**
* Returns true if the specified character is a valid NCName start
* character as defined by production [4] in Namespaces in XML
* 1.1 recommendation.
*
* @param c The character to check.
*/
public static boolean isXML11NCNameStart(int c) {
|| (0x10000 <= c && c < 0xF0000);
} // isXML11NCNameStart(int):boolean
/**
* Returns true if the specified character is a valid NCName
* character as defined by production [5] in Namespaces in XML
* 1.1 recommendation.
*
* @param c The character to check.
*/
public static boolean isXML11NCName(int c) {
|| (0x10000 <= c && c < 0xF0000);
} // isXML11NCName(int):boolean
/**
* Returns whether the given character is a valid
* high surrogate for a name character. This includes
* all high surrogates for characters [0x10000-0xEFFFF].
* In other words everything excluding planes 15 and 16.
*
* @param c The character to check.
*/
public static boolean isXML11NameHighSurrogate(int c) {
return (0xD800 <= c && c <= 0xDB7F);
}
/*
* [5] Name ::= NameStartChar NameChar*
*/
/**
* Check to see if a string is a valid Name according to [5]
* in the XML 1.1 Recommendation
*
* @param name string to check
* @return true if name is a valid Name
*/
if (length == 0)
return false;
int i = 1;
if( !isXML11NameStart(ch) ) {
return false;
}
i = 2;
}
else {
return false;
}
}
while (i < length) {
if ( !isXML11Name(ch) ) {
return false;
}
}
else {
return false;
}
}
++i;
}
return true;
} // isXML11ValidName(String):boolean
/*
* from the namespace 1.1 rec
* [4] NCName ::= NCNameStartChar NCNameChar*
*/
/**
* Check to see if a string is a valid NCName according to [4]
* from the XML Namespaces 1.1 Recommendation
*
* @param ncName string to check
* @return true if name is a valid NCName
*/
if (length == 0)
return false;
int i = 1;
if( !isXML11NCNameStart(ch) ) {
return false;
}
i = 2;
}
else {
return false;
}
}
while (i < length) {
if ( !isXML11NCName(ch) ) {
return false;
}
}
else {
return false;
}
}
++i;
}
return true;
} // isXML11ValidNCName(String):boolean
/*
* [7] Nmtoken ::= (NameChar)+
*/
/**
* Check to see if a string is a valid Nmtoken according to [7]
* in the XML 1.1 Recommendation
*
* @param nmtoken string to check
* @return true if nmtoken is a valid Nmtoken
*/
if (length == 0)
return false;
for (int i = 0; i < length; ++i ) {
if( !isXML11Name(ch) ) {
return false;
}
}
else {
return false;
}
}
}
return true;
} // isXML11ValidName(String):boolean
/**
* Simple check to determine if qname is legal. If it returns false
* then <param>str</param> is illegal; if it returns true then
* <param>str</param> is legal.
*/
return false;
}
if (colon > 0) {
}
else {
return isXML11ValidNCName(str);
}
}
} // class XML11Char