@Test public void stringForString() { assertEquals("\"a\\rbt\"", FmtUtils.stringForString("a\rbt")) ; }
@Override public void visit(OpLabel opLabel) { String x = FmtUtils.stringForString(opLabel.getObject().toString()) ; if ( opLabel.hasSubOp() ) { start(opLabel, NL) ; out.println(x) ; printOp(opLabel.getSubOp()) ; finish(opLabel) ; } else { start(opLabel, NoNL) ; out.print(x) ; finish(opLabel) ; } }
private void docEntity(Node g, Node s, List<Quad> batch) { // One document per entity String x = TextQueryFuncs.subjectToString(s) ; String gx = TextQueryFuncs.graphNodeToString(g) ; Entity entity = new Entity(x, gx) ; String graphField = defn.getGraphField() ; if ( defn.getGraphField() != null ) entity.put(graphField, gx) ; for ( Quad quad : batch ) { Node p = quad.getPredicate() ; String field = defn.getField(p) ; if ( field == null ) continue ; Node o = quad.getObject() ; String val = null ; if ( o.isURI() ) val = o.getURI() ; else if ( o.isLiteral() ) val = o.getLiteralLexicalForm() ; else { log.warn("Not a literal value for mapped field-predicate: " + field + " :: " + FmtUtils.stringForString(field)) ; continue ; } entity.put(field, val) ; } indexer.addEntity(entity) ; }
/** Create an Entity from a quad (as g/s/p/o). * Returns null if the quad is not a candidate for indexing. */ public static Entity entityFromQuad(EntityDefinition defn , Node g , Node s , Node p , Node o ) { String field = defn.getField(p) ; if ( field == null ) return null ; if ( !o.isLiteral() ) { Log.warn(TextQuery.class, "Not a literal value for mapped field-predicate: " + field + " :: " + FmtUtils.stringForString(field)) ; return null ; } String x = TextQueryFuncs.subjectToString(s) ; String graphText = TextQueryFuncs.graphNodeToString(g) ; String language = o.getLiteral().language() ; RDFDatatype datatype = o.getLiteral().getDatatype() ; Entity entity = new Entity(x, graphText, language, datatype) ; entity.put(field, o.getLiteralLexicalForm()) ; return entity ; }
private void docEntity(Node g, Node s, List<Quad> batch) { // One document per entity String x = TextQueryFuncs.subjectToString(s) ; String gx = TextQueryFuncs.graphNodeToString(g) ; Entity entity = new Entity(x, gx) ; String graphField = defn.getGraphField() ; if ( defn.getGraphField() != null ) entity.put(graphField, gx) ; for ( Quad quad : batch ) { Node p = quad.getPredicate() ; String field = defn.getField(p) ; if ( field == null ) continue ; Node o = quad.getObject() ; String val = null ; if ( o.isURI() ) val = o.getURI() ; else if ( o.isLiteral() ) val = o.getLiteralLexicalForm() ; else { log.warn("Not a literal value for mapped field-predicate: " + field + " :: " + FmtUtils.stringForString(field)) ; continue ; } entity.put(field, val) ; } indexer.addEntity(entity) ; }
/** Create an Entity from a quad (as g/s/p/o). * Returns null if the quad is not a candidate for indexing. */ public static Entity entityFromQuad(EntityDefinition defn , Node g , Node s , Node p , Node o ) { String field = defn.getField(p) ; if ( field == null ) return null ; if ( !o.isLiteral() ) { Log.warn(TextQuery.class, "Not a literal value for mapped field-predicate: " + field + " :: " + FmtUtils.stringForString(field)) ; return null ; } String x = TextQueryFuncs.subjectToString(s) ; String graphText = TextQueryFuncs.graphNodeToString(g) ; String language = o.getLiteral().language() ; RDFDatatype datatype = o.getLiteral().getDatatype() ; Entity entity = new Entity(x, graphText, language, datatype) ; entity.put(field, o.getLiteralLexicalForm()) ; return entity ; }