private static String quoteName(String string) { // Safest to quote anyway. return quote(string) ; // Assumes only called with safe names //return string ; // Better would be: // starts a-z, constains a-z,0-9, not a keyword(true, false, null) // if ( string.contains(something not in a-z0-9) // and // //return "\""+string+"\"" ; // return JSONObject.quote(string) ; }
private void printUnbound() { out.print(quoteName(dfType)+ ": "+quote(dfUnbound)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(dfValue)+": null") ; if ( multiLineValues ) out.println() ; }
private void printLiteral(Literal literal) { String datatype = literal.getDatatypeURI() ; String lang = literal.getLanguage() ; if ( datatype != null ) { out.print(quoteName(kDatatype)+": "+quote(datatype)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(kType)+": "+quote(kTypedLiteral)+" , ") ; if ( multiLineValues ) out.println() ; } else { out.print(quoteName(kType)+": "+quote(kLiteral)+" , ") ; if ( multiLineValues ) out.println() ; if ( lang != null && !lang.equals("") ) { out.print(quoteName(kXmlLang)+": "+quote(lang)+" , ") ; if ( multiLineValues ) out.println() ; } } out.print(quoteName(kValue)+": "+quote(literal.getLexicalForm())) ; if ( multiLineValues ) out.println() ; }
private static String quoteName(String string) { // Safest to quote anyway. return quote(string) ; // Assumes only called with safe names //return string ; // Better would be: // starts a-z, constains a-z,0-9, not a keyword(true, false, null) // if ( string.contains(something not in a-z0-9) // and // //return "\""+string+"\"" ; // return JSONObject.quote(string) ; }
private void printLiteral(Literal literal) { String datatype = literal.getDatatypeURI() ; String lang = literal.getLanguage() ; if ( datatype != null ) { out.print(quoteName(dfDatatype)+": "+quote(datatype)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(dfType)+": "+quote(dfTypedLiteral)+" , ") ; if ( multiLineValues ) out.println() ; } else { out.print(quoteName(dfType)+": "+quote(dfLiteral)+" , ") ; if ( multiLineValues ) out.println() ; if ( lang != null && !lang.equals("") ) { out.print(quoteName(dfLang)+": "+quote(lang)+" , ") ; if ( multiLineValues ) out.println() ; } } out.print(quoteName(dfValue)+": "+quote(literal.getLexicalForm())) ; if ( multiLineValues ) out.println() ; }
public void binding(String varName, RDFNode value) { if ( value == null ) return ; if ( !firstBindingInSolution ) out.println(" ,") ; firstBindingInSolution = false ; // Do not use quoteName - varName may not be JSON-safe as a bare name. out.print(quote(varName)+": { ") ; if ( multiLineValues ) out.println() ; out.incIndent() ; // Old, explicit unbound // if ( value == null ) // printUnbound() ; // else if ( value.isLiteral() ) printLiteral((Literal)value) ; else if ( value.isResource() ) printResource((Resource)value) ; else Log.warn(this, "Unknown RDFNode type in result set: "+value.getClass()) ; out.decIndent() ; if ( !multiLineValues ) out.print(" ") ; out.print("}") ; // NB No newline }
out.print(quoteName(kType)+": "+quote(kBnode)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(kValue)+": "+quote(label)) ; out.print(quoteName(kType)+": "+quote(kUri)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(kValue)+": "+quote(resource.getURI())) ; if ( multiLineValues ) out.println() ; return ;
out.print(quote(varName)+": { ") ; if ( multiLineValues ) out.println() ;
out.print(quoteName(dfType)+": "+quote(dfBNode)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(dfValue)+": "+quote(label)) ; out.print(quoteName(dfType)+": "+quote(dfURI)+" , ") ; if ( multiLineValues ) out.println() ; out.print(quoteName(dfValue)+": "+quote(resource.getURI())) ; if ( multiLineValues ) out.println() ; return ;