protected IRI(String s) { this(XMLUtils.getNCNamePrefix(s), XMLUtils.getNCNameSuffix(s)); }
@Override public void characters(char[] data, int start, int length) { XMLUtils.escapeXML(data, start, length, m_content); } }
/** * Determines if a character sequence has a suffix that is an NCName. * * @param s The character sequence. * @return {@code true} if the character sequence {@code s} has a suffix that is an NCName. */ public static boolean hasNCNameSuffix(CharSequence s) { return getNCNameSuffixIndex(s) != -1; }
/** * This function exist because the one in IRI is deprecated and will be remove : We want the memory of calling it 'fragment' preserved. * * @return the NCNameSuffix * @since 2.5.1 */ default public String getFragment(final IRI iri) { return XMLUtils.getNCNameSuffix(iri); }
/** * Determines if a character sequence is an NCName (Non-Colonised Name). An NCName is a string which starts with an * NCName start character and is followed by zero or more NCName characters. * @param s The character sequence to be tested. * @return <code>true</code> if <code>s</code> is an NCName, otherwise <code>false</code>. */ public static boolean isNCName(CharSequence s) { if (isNullOrEmpty(s)) { return false; } int firstCodePoint = Character.codePointAt(s, 0); if(!isNCNameStartChar(firstCodePoint)) { return false; } for(int i = Character.charCount(firstCodePoint); i < s.length(); ) { int codePoint = Character.codePointAt(s, i); if(!isNCNameChar(codePoint)) { return false; } i += Character.charCount(codePoint); } return true; }
if (isNullOrEmpty(s)) { return false; if(!isXMLNameStartCharacter(codePoint)) { return false; if(!isXMLNameChar(codePoint)) { return false;
/** * Gets the index of the longest NCName that is the suffix of a character sequence. * @param s The character sequence. * @return The index of the longest suffix of the specified character sequence <code>s</code> that is an NCName, or * -1 if the character sequence <code>s</code> does not have a suffix that is an NCName. */ public static int getNCNameSuffixIndex(CharSequence s) { // identify bnode labels and do not try to split them if (s.length() > 1 && s.charAt(0) == '_' && s.charAt(1) == ':') { return -1; } int index = -1; for(int i = s.length() - 1; i > -1; i--) { if (!Character.isLowSurrogate(s.charAt(i))) { int codePoint = Character.codePointAt(s, i); if(isNCNameStartChar(codePoint)) { index = i; } if(!isNCNameChar(codePoint)) { break; } } } return index; }
String ns = XMLUtils.getNCNamePrefix(s); if (ns.equals("")) { iri = IRI.create(base + s);
/** * Deterimines if a character is an NCName (Non-Colonised Name) start character. * * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 * characters the code point corresponds to the value of the char that represents the * character. * @return {@code true} if {@code codePoint} is a NCName start character, otherwise {@code * false}. */ public static boolean isNCNameStartChar(int codePoint) { return codePoint != ':' && isXMLNameStartCharacter(codePoint); }
/** * Deterimines if a character is an NCName (Non-Colonised Name) character. * * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 * characters the code point corresponds to the value of the char that represents the * character. * @return {@code true} if {@code codePoint} is a NCName character, otherwise {@code false}. */ public static boolean isNCNameChar(int codePoint) { return codePoint != ':' && isXMLNameChar(codePoint); }
protected String computePrefix(String namespace, int startIndex) { if (startIndex != -1) { int endIndex = startIndex + 1; for (int i = startIndex; endIndex < namespace.length() && i < namespace.length(); i++) { char curChar = namespace.charAt(endIndex); // We include any NCNameChar except a full stop (.) so // that if the URI looks like a file with an extension the // extension is removed. if (XMLUtils.isNCNameChar(curChar) && curChar != '.') { endIndex = i + 1; } else { break; } } return namespace.substring(startIndex, endIndex); } return "p"; }
/** * This function exist because the one in IRI is deprecated and will be remove : We want the memory of calling it 'fragment' preserved. * * @return the NCNameSuffix * @since 2.5.1 */ default public String getFragment(final IRI iri) { return XMLUtils.getNCNameSuffix(iri); }
/** * Determines if a character sequence is an NCName (Non-Colonised Name). An * NCName is a string which starts with an NCName start character and is * followed by zero or more NCName characters. * * @param s * The character sequence to be tested. * @return {@code true} if {@code s} is an NCName, otherwise {@code false}. */ public static boolean isNCName(CharSequence s) { if (isNullOrEmpty(s)) { return false; } int firstCodePoint = Character.codePointAt(s, 0); if (!isNCNameStartChar(firstCodePoint)) { return false; } for (int i = Character.charCount(firstCodePoint); i < s.length();) { int codePoint = Character.codePointAt(s, i); if (!isNCNameChar(codePoint)) { return false; } i += Character.charCount(codePoint); } return true; }
if (isNullOrEmpty(s)) { return false; } else { if (!inNCName) { if (!isXMLNameStartCharacter(codePoint)) { return false; if (!isXMLNameChar(codePoint)) { return false;
/** * Gets the index of the longest NCName that is the suffix of a character sequence. * * @param s The character sequence. * @return The index of the longest suffix of the specified character sequence {@code s} that is * an NCName, or -1 if the character sequence {@code s} does not have a suffix that is * an NCName. */ public static int getNCNameSuffixIndex(CharSequence s) { // identify bnode labels and do not try to split them if (s.length() > 1 && s.charAt(0) == '_' && s.charAt(1) == ':') { return -1; } int index = -1; for (int i = s.length() - 1; i > -1; i--) { if (!Character.isLowSurrogate(s.charAt(i))) { int codePoint = Character.codePointAt(s, i); if (isNCNameStartChar(codePoint)) { index = i; } if (!isNCNameChar(codePoint)) { break; } } } return index; }
String ns = XMLUtils.getNCNamePrefix(s); if (ns.equals("")) { iri = IRI.create(base + s);
/** * Deterimines if a character is an NCName (Non-Colonised Name) start character. * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 characters the code point * corresponds to the value of the char that represents the character. * @return <code>true</code> if <code>codePoint</code> is a NCName start character, otherwise <code>false</code>. */ public static boolean isNCNameStartChar(int codePoint) { return codePoint != ':' && isXMLNameStartCharacter(codePoint); }
/** * Deterimines if a character is an NCName (Non-Colonised Name) character. * * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 * characters the code point corresponds to the value of the char that represents the * character. * @return {@code true} if {@code codePoint} is a NCName character, otherwise {@code false}. */ public static boolean isNCNameChar(int codePoint) { return codePoint != ':' && isXMLNameChar(codePoint); }
protected String computePrefix(String namespace, int startIndex) { if (startIndex != -1) { int endIndex = startIndex + 1; for (int i = startIndex; endIndex < namespace.length() && i < namespace.length(); i++) { char curChar = namespace.charAt(endIndex); // We include any NCNameChar except a full stop (.) so // that if the URI looks like a file with an extension the // extension is removed. if (XMLUtils.isNCNameChar(curChar) && curChar != '.') { endIndex = i + 1; } else { break; } } return namespace.substring(startIndex, endIndex); } return "p"; }
protected IRI(String s) { this(XMLUtils.getNCNamePrefix(s), XMLUtils.getNCNameSuffix(s)); }