/** * Checks all characters of the given String to determine if they syntactically match the * production of an NCName as defined by the W3C XML Namespaces recommendation. * * @param str the String to check * @return true if the given String follows the Syntax of an NCName */ public static boolean isNCName(final String str) { if (str == null || str.length() == 0) { return false; } char[] chars = str.toCharArray(); // -- make sure String starts with a letter or '_' char ch = chars[0]; if (!isLetter(ch) && ch != '_') { return false; } for (int i = 1; i < chars.length; i++) { if (!isNCNameChar(chars[i])) { return false; } } return true; } // -- isNCName
/** * Checks all characters of the given String to determine if they * syntactically match the production of an NCName as defined by the W3C XML * Namespaces recommendation. * * @param str * the String to check * @return true if the given String follows the Syntax of an NCName */ public static boolean isNCName(final String str) { if (str == null || str.length() == 0) { return false; } char[] chars = str.toCharArray(); // -- make sure String starts with a letter or '_' char ch = chars[0]; if (!isLetter(ch) && ch != '_') { return false; } for (int i = 1; i < chars.length; i++) { if (!isNCNameChar(chars[i])) { return false; } } return true; } // -- isNCName
/** * Checks all characters of the given String to determine if they syntactically match the * production of an QName as defined by the W3C XML Namespaces recommendation. * * @param str the String to check * @return true if the given String follows the Syntax of an QName */ public static boolean isQName(final String str) { if (str == null || str.length() == 0) { return false; } char[] chars = str.toCharArray(); // -- make sure String starts with a letter or '_' char ch = chars[0]; if (!isLetter(ch) && ch != '_') { return false; } for (int i = 1; i < chars.length; i++) { if (chars[i] == ':') { continue; } if (!isNCNameChar(chars[i])) { return false; } } return true; } // -- isQName
/** * Checks all characters of the given String to determine if they * syntactically match the production of an QName as defined by the W3C XML * Namespaces recommendation. * * @param str * the String to check * @return true if the given String follows the Syntax of an QName */ public static boolean isQName(final String str) { if (str == null || str.length() == 0) { return false; } char[] chars = str.toCharArray(); // -- make sure String starts with a letter or '_' char ch = chars[0]; if (!isLetter(ch) && ch != '_') { return false; } for (int i = 1; i < chars.length; i++) { if (chars[i] == ':') { continue; } if (!isNCNameChar(chars[i])) { return false; } } return true; } //-- isQName
/** * Checks all characters of the given String to determine if they syntactically match the * production of an NMToken. * * @param str the String to check * @return true if the given String follows the Syntax of an NMToken */ public static boolean isNMToken(final String str) { if (str == null) { return false; } char[] chars = str.toCharArray(); for (int i = 0; i < chars.length; i++) { char ch = chars[i]; if (isLetter(ch) || isDigit(ch) || isExtender(ch) || isCombiningChar(ch)) { continue; } switch (ch) { case '.': case '-': case '_': case ':': break; default: return false; } } return true; } // -- isNMToken
/** * Checks all characters of the given String to determine if they * syntactically match the production of an NMToken. * * @param str * the String to check * @return true if the given String follows the Syntax of an NMToken */ public static boolean isNMToken(final String str) { if (str == null) { return false; } char[] chars = str.toCharArray(); for (int i = 0; i < chars.length; i++) { char ch = chars[i]; if (isLetter(ch) || isDigit(ch) || isExtender(ch) || isCombiningChar(ch)) { continue; } switch (ch) { case '.': case '-': case '_': case ':': break; default: return false; } } return true; } // -- isNMToken
/** * Checks the the given character to determine if it is a valid NCNameChar as defined by the W3C * XML Namespaces recommendation. * * @param ch the char to check * @return true if the given char is an NCNameChar */ public static boolean isNCNameChar(final char ch) { if (isLetter(ch) || isDigit(ch)) { return true; } if (isExtender(ch) || isCombiningChar(ch)) { return true; } switch (ch) { case '.': case '-': case '_': return true; default: return false; } } // -- isNCNameChar
/** * Checks the the given character to determine if it is a valid NCNameChar * as defined by the W3C XML Namespaces recommendation. * * @param ch * the char to check * @return true if the given char is an NCNameChar */ public static boolean isNCNameChar(final char ch) { if (isLetter(ch) || isDigit(ch)) { return true; } if (isExtender(ch) || isCombiningChar(ch)) { return true; } switch (ch) { case '.': case '-': case '_': return true; default: return false; } } // -- isNCNameChar