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 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 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"; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
if (!XMLUtils.isNCNameChar(b.charAt(i))) { b.deleteCharAt(i);
if (!XMLUtils.isNCNameChar(b.charAt(i))) { b.deleteCharAt(i);
if (!XMLUtils.isNCNameChar(b.charAt(i))) { b.deleteCharAt(i);
/** * 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(@Nullable CharSequence s) { if (isNullOrEmpty(s)) { return false; } assert s != null; 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; }
/** * 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; }
/** * 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(@Nullable CharSequence s) { if (isNullOrEmpty(s)) { return false; } assert s != null; 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; }
/** * 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(@Nullable CharSequence s) { if (isNullOrEmpty(s)) { return false; } assert s != null; 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; }
/** @deprecated Use {@link org.semanticweb.owlapi.io.XMLUtils#getNCNamePrefix(CharSequence)} */ @Deprecated public String [] split(String s) { // We need to deal with escape sequences. %20 is a space // and can be contained within a qname. String temp = s; temp = temp.replaceAll("\\%[0-9a-fA-F][0-9a-fA-F]", "---"); int startIndex = s.length() - 1; for (int index = s.length() - 1; index > -1; index--) { char curChar = temp.charAt(index); if (XMLUtils.isNCNameStartChar(curChar)) { startIndex = index; } else if (!XMLUtils.isNCNameChar(curChar)) { break; } } String [] split = new String [2]; if(!XMLUtils.isNCNameStartChar(s.charAt(startIndex))) { // Could not find split! split[0] = ""; split[1] = ""; } else { split[0] = s.substring(0, startIndex); split[1] = s.substring(startIndex, s.length()); } return split; }
/** * 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; }
startIndex = i; } else if (!XMLUtils.isNCNameChar(curChar)) { break;
startIndex = i; } else if (!XMLUtils.isNCNameChar(curChar)) { break;
startIndex = i; } else if (!XMLUtils.isNCNameChar(curChar)) { break;