private void setFormatter() { fmt = new NodeFormatterTTL(baseURI, pMap, nodeToLabel) ; }
static boolean safePrefixName(String prefix, String localname) { return safeForPrefix(prefix) && safeForPrefixLocalname(localname) ; }
protected void outputNode(Node n) { fmt.format(out, n) ; }
private static boolean validInteger(String lex) { int N = lex.length() ; if ( N == 0 ) return false ; int idx = 0 ; idx = skipSign(lex, idx) ; idx = skipDigits(lex, idx) ; return (idx == N) ; }
/*private-testing*/ static boolean safeForPrefixLocalname(String str) { int N = str.length() ; if ( N == 0 ) return true ; int idx = 0 ; idx = skip1_PN_CHARS_U_or_digit(str, idx) ; if ( idx == -1 ) return false ; idx = skipAny_PN_CHARS_or_DOT(str, idx, N-1) ; if ( idx == -1 ) return false ; idx = skip1_PN_CHARS(str, idx) ; // Final char return ( idx == N ) ; }
if ( safeForPrefix(pref) && safeForPrefixLocalname(ln) ) String x = abbrevByBase(uriStr, baseIRI) ; if ( x != null )
static boolean safeForPrefix(String str) { int N = str.length() ; if ( N == 0 ) return true ; int idx = 0 ; idx = skip1_PN_CHARS_BASE(str, idx) ; if ( idx == -1 ) return false ; idx = skipAny_PN_CHARS_or_DOT(str, idx, N-1) ; if ( idx == -1 ) return false ; // Final char idx = skip1_PN_CHARS(str, idx) ; if ( idx == -1 ) return false ; return ( idx == N ) ; }
NodeFormatterTTL formatter = new NodeFormatterTTL(null, null); formatter.format(w, n);
@Override public void formatURI(AWriter w, String uriStr) { Pair<String, String> pName = prefixMap.abbrev(uriStr) ; // Check if legal if ( pName != null ) { // Check legal - need to check its legal, not for illegal. // The splitter in "abbrev" only has a weak rule. String prefix = pName.getLeft() ; String localname = pName.getRight() ; if ( safePrefixName(prefix, localname) ) { w.print(prefix) ; w.print(':') ; w.print(localname) ; return ; } } // Attempt base abbreviation. if ( iriResolver != null ) { String x = abbrevByBase(uriStr) ; if ( x != null ) { w.print('<') ; w.print(x) ; w.print('>') ; return ; } } // else super.formatURI(w, uriStr) ; }
private static boolean validInteger(String lex) { int N = lex.length() ; if ( N == 0 ) return false ; int idx = 0 ; idx = skipSign(lex, idx) ; idx = skipDigits(lex, idx) ; return ( idx == N ) ; }
static boolean safeForPrefix(String str) { // PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? int N = str.length() ; if ( N == 0 ) return true ; int idx = 0 ; idx = skip1_PN_CHARS_BASE(str, idx) ; if ( idx == -1 ) return false ; idx = skipAny_PN_CHARS_or_DOT(str, idx, N - 1) ; if ( idx == -1 ) return false ; idx = skip1_PN_CHARS(str, idx) ; if ( idx == -1 ) return false ; return (idx == N) ; }
protected NodeFormatter createNodeFormatter() { // Use a Turtle formatter to format terms return new NodeFormatterTTL(null, null); }
private static boolean validDecimal(String lex) { // case : In N3, "." illegal, as is "+." and -." but legal in Turtle. int N = lex.length() ; if ( N <= 1 ) return false ; int idx = 0 ; idx = skipSign(lex, idx) ; idx = skipDigits(lex, idx) ; // Maybe none. // DOT required. if ( idx >= N ) return false ; char ch = lex.charAt(idx) ; if ( ch != '.' ) return false ; idx++ ; // Digit required. if ( idx >= N ) return false ; idx = skipDigits(lex, idx) ; return (idx == N) ; }
private void testPrefix(String prefix, String local) { assertTrue(NodeFormatterTTL.safeForPrefix(prefix)) ; assertTrue(NodeFormatterTTL.safeForPrefixLocalname(local)) ; }
protected void outputNode(Node n) { fmt.format(out, n) ; }
private void setFormatter() { fmt = new NodeFormatterTTL(baseURI, pMap, nodeToLabel) ; }
private static boolean validDecimal(String lex) { // case : In N3, "." illegal, as is "+." and -." but legal in Turtle. int N = lex.length() ; if ( N <= 1 ) return false ; int idx = 0 ; idx = skipSign(lex, idx) ; idx = skipDigits(lex, idx) ; // Maybe none. // DOT required. if ( idx >= N ) return false ; char ch = lex.charAt(idx) ; if ( ch != '.' ) return false ; idx++ ; // Digit required. if ( idx >= N ) return false ; idx = skipDigits(lex, idx) ; return ( idx == N ) ; }
private BindingOutputStream(Writer out, List<Var> variables, PrefixMap prefixMapping) { bw = IO.wrap(out) ; vars = variables ; pmap = prefixMapping ; nodeFormatter = new NodeFormatterTTL(null, pmap) ; needOutputVars = (vars != null ) && vars.size() > 0 ; }
idx = skipSign(lex, idx) ; int idx2 = skipDigits(lex, idx) ; boolean initialDigits = ( idx != idx2) ; idx = idx2 ; idx2 = skipDigits(lex, idx) ; boolean trailingDigits = ( idx != idx2 ) ; idx = idx2 ; idx++ ; if ( idx >= N ) return false ; idx = skipSign(lex, idx) ; if ( idx >= N ) return false ; // At least one digit. idx = skipDigits(lex, idx) ; return ( idx == N ) ;
private BindingOutputStream(Writer out, List<Var> variables, PrefixMap prefixMapping) { bw = IO.wrap(out) ; vars = variables ; pmap = prefixMapping ; nodeFormatter = new NodeFormatterTTL(null, pmap) ; needOutputVars = (vars != null ) && vars.size() > 0 ; }