Author: andy Date: Fri Nov 8 16:59:26 2013 New Revision: 1540117 URL: http://svn.apache.org/r1540117 Log: JENA-584 - ensure final char of a possible local name is not a DOT.
Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterTTL.java Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterTTL.java URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterTTL.java?rev=1540117&r1=1540116&r2=1540117&view=diff ============================================================================== --- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterTTL.java (original) +++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterTTL.java Fri Nov 8 16:59:26 2013 @@ -112,9 +112,9 @@ public class NodeFormatterTTL extends No int idx = 0 ; idx = skip1_PN_CHARS_BASE(str, idx) ; if ( idx == -1 ) return false ; - idx = skipAny_PN_CHARS_or_DOT(str, idx) ; + idx = skipAny_PN_CHARS_or_DOT(str, idx, N-1) ; if ( idx == -1 ) return false ; - if ( idx == N ) return true ; + // Final char idx = skip1_PN_CHARS(str, idx) ; if ( idx == -1 ) return false ; return ( idx == N ) ; @@ -144,12 +144,12 @@ public class NodeFormatterTTL extends No int N = str.length() ; if ( N == 0 ) return true ; int idx = 0 ; - idx = skip1_PN_CHARS_U_or_029(str, idx) ; + idx = skip1_PN_CHARS_U_or_digit(str, idx) ; if ( idx == -1 ) return false ; - idx = skipAny_PN_CHARS_or_DOT(str, idx) ; + idx = skipAny_PN_CHARS_or_DOT(str, idx, N-1) ; if ( idx == -1 ) return false ; - if ( idx == N ) return true ; idx = skip1_PN_CHARS(str, idx) ; + // Final char return ( idx == N ) ; } @@ -162,7 +162,7 @@ public class NodeFormatterTTL extends No return ch == '\u00B7' || RiotChars.range(ch, '\u0300', '\u036F') || RiotChars.range(ch, '\u203F', '\u2040') ; } - private static int skip1_PN_CHARS_U_or_029(String str, int idx) + private static int skip1_PN_CHARS_U_or_digit(String str, int idx) { char ch = str.charAt(idx) ; if ( is_PN_CHARS_U(ch) ) return idx+1 ; @@ -177,15 +177,14 @@ public class NodeFormatterTTL extends No return -1 ; } - private static int skipAny_PN_CHARS_or_DOT(String str, int idx) + private static int skipAny_PN_CHARS_or_DOT(String str, int idx, int max) { - int N = str.length() ; - for ( int i = idx ; i < N ; i++ ) + for ( int i = idx ; i < max ; i++ ) { char ch = str.charAt(i) ; if ( ! is_PN_CHARS(ch) && ch != '.' ) return i ; } - return N ; + return max ; } private static int skip1_PN_CHARS(String str, int idx)