/** * Sets the name of the element that this Element definition defines. * * @param name the name of the defined element **/ public void setName(String name) { if ((name == null) || (ValidationUtils.isNCName(name))) { _name = name; } else { String err = "error: '" + name + "' is not a valid NCName."; throw new IllegalArgumentException(err); } } // -- setName
/** * Sets the name which this element declaration refers to * * @param referenceName the name of the element definition that this definition references **/ public void setReferenceName(String referenceName) { if ((referenceName == null) || (ValidationUtils.isQName(referenceName))) { _elementRefName = referenceName; } else { String err = "error: '" + referenceName + "' is not a valid QName."; throw new IllegalArgumentException(err); } } // -- setReference
/** * 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
if (!ValidationUtils.isCDATA(value)) { String err = "Name '" + value + "' is not a valid CDATA."; throw new ValidationException(err); if (!ValidationUtils.isNMToken(value)) { String err = "Name '" + value + "' is not a valid NMToken."; throw new ValidationException(err); if (!ValidationUtils.isQName(value)) { String err = "Name '" + value + "' is not a valid QName."; throw new ValidationException(err); if (!ValidationUtils.isNCName(value)) { String err = "Name '" + value + "' is not a valid NCName."; throw new ValidationException(err);
/** * 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
if (!ValidationUtils.isCDATA(value)) { String err = "Name '" + value + "' is not a valid CDATA."; throw new ValidationException(err); if (!ValidationUtils.isNMToken(value)) { String err = "Name '" + value + "' is not a valid NMToken."; throw new ValidationException(err); if (!ValidationUtils.isQName(value)) { String err = "Name '" + value + "' is not a valid QName."; throw new ValidationException(err); if (!ValidationUtils.isNCName(value)) { String err = "Name '" + value + "' is not a valid NCName."; throw new ValidationException(err);
/** * 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 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
/** * Sets the name of the element that this Element definition defines. * * @param name the name of the defined element **/ public void setName(String name) { if ((name == null) || (ValidationUtils.isNCName(name))) { _name = name; } else { String err = "error: '" + name + "' is not a valid NCName."; throw new IllegalArgumentException(err); } } //-- setName
/** * 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
/** * Sets the name which this element declaration refers to * @param referenceName the name of the element definition that this * definition references **/ public void setReferenceName(String referenceName) { if ((referenceName == null) || (ValidationUtils.isQName(referenceName))) { _elementRefName = referenceName; } else { String err = "error: '" + referenceName + "' is not a valid QName."; throw new IllegalArgumentException(err); } } //-- setReference
/** * 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 validity of this Schema defintion. * * @exception ValidationException when this Schema definition is invalid. **/ public void validate() throws ValidationException { String err = null; // -- name must be a NCName if (!ValidationUtils.isNCName(_name)) { err = "The name of an IdentityConstraint must be an NCName."; } // -- selector must exist else if (_selector == null) { err = "Selector for IdentityConstraint cannot be null."; } // -- at least 1 (one) field must exist else if (_fields.size() < 1) { err = "There must be at least one 'field' in an " + "identity constraint."; } if (err != null) throw new ValidationException(err); } // -- validate
/** * 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 the validity of this Schema defintion. * @exception ValidationException when this Schema definition * is invalid. **/ public void validate() throws ValidationException { String err = null; //-- name must be a NCName if (!ValidationUtils.isNCName(_name)) { err = "The name of an IdentityConstraint must be an NCName."; } //-- selector must exist else if (_selector == null) { err = "Selector for IdentityConstraint cannot be null."; } //-- at least 1 (one) field must exist else if (_fields.size() < 1) { err = "There must be at least one 'field' in an " + "identity constraint."; } if (err != null) throw new ValidationException(err); } //-- validate