/** * Visiting triple patterns in SPARQL algebra. */ @Override public void visit(final OpBGP opBGP) { if(optionalFlag) { opBGP.getPattern().getList().forEach(triple -> optionalTraversals.add(TraversalBuilder.transform(triple))); opBGP.getPattern().getList().forEach(triple -> optionalVariable.add(triple.getObject().toString())); } else opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple))); }
/** Answer a human-readable representation of this Node where literals are quoted according to <code>quoting</code> but URIs are not compressed. */ public String toString( boolean quoting ) { return toString( null, quoting ); }
/** Answer a human-readable representation of this Node. It will not compress URIs, nor quote literals (because at the moment too many places use toString() for something machine-oriented). */ @Override public String toString() { return toString( null ); }
/** Answer a human-readable representation of the Node, quoting literals and compressing URIs. */ public String toString( PrefixMapping pm ) { return toString( pm, true ); }
@Override public String toString() { return node.toString(); } }
/** Answer the "nice" representation of this node, the string returned by <code>n.toString(PrefixMapping.Extended,true)</code>. */ protected static String nice( Node n ) { return n.toString( PrefixMapping.Extended, true ); }
/** Answer a string describing <code>object</code>, quoting it if it is a literal. */ protected String objectString( RDFNode object ) { return object.asNode().toString( null, true ); }
/** Answer a string describing <code>object</code>, quoting it if it is a literal. */ protected String objectString( RDFNode object ) { return object.asNode().toString( null, true ); }
@Override public String toString() { // Use get() rather than accessing the field directly because the node // field is lazily instantiated from the Thrift term Node n = this.get(); if (n == null) return ""; return n.toString(); }
/** * Convert a node into a pattern node by converting var resources into wildcard * variables. */ public static Node nodeToPattern(Node n) { if (n.isURI() && n.toString().startsWith("var:")) { return Node_RuleVariable.WILD; // return Node.ANY; } else { return n; } }
/** * Convert a node into a pattern node by converting var resources into wildcard * variables. */ public static Node nodeToPattern(Node n) { if (n.isURI() && n.toString().startsWith("var:")) { return Node_RuleVariable.WILD; // return Node.ANY; } else { return n; } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new IndividualImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to Individual"); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new IndividualImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to Individual"); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new OntClassImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to OntClass: it does not have rdf:type owl:Class or equivalent"); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new OntResourceImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to OntResource"); } }
/** Answer a "nice" representation of <code>r</code>, suitable for appearance within an exception message. */ protected static String nice( Resource r ) { String rString = r.asNode().toString( r.getModel() ); return r.isAnon() ? rString + getLabels( r ) : rString; }
public void testLiteralToString() { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dtInt = tm.getTypeByValue( new Integer( 10 ) ); Node plain = NodeFactory.createLiteral( "rhubarb", ""); Node english = NodeFactory.createLiteral( "eccentric", "en_UK"); Node typed = NodeFactory.createLiteral( "10", dtInt ); assertEquals( "\"rhubarb\"", plain.toString() ); assertEquals( "rhubarb", plain.toString( false ) ); assertEquals( "\"eccentric\"@en_UK", english.toString() ); assertEquals( "10^^http://www.w3.org/2001/XMLSchema#int", typed.toString( false ) ); }
@Test public void collectingOneDatasetGivesThatDataset() { Graph graph = parseGraph("(graph (triple <s1> <p1> <o1> ))"); Model model = createModelForGraph(graph); Dataset dataset = DatasetFactory.create(model); Node graphName = NodeFactory.createBlankNode(); dataset.addNamedModel(graphName.toString(), model); Dataset collection = Stream.<Dataset>builder().add(dataset).build().collect(testInstance()); assertDatasetsAreIsomorphicPerGraph(dataset, collection); }
@Test public void test_param_string_copy_5() { // Test selective copying - copying without copying parameters ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setIri("x", "http://example.org/original"); ParameterizedSparqlString copy = query.copy(false); Assert.assertEquals("http://example.org/original", query.getParam("x").toString()); Assert.assertEquals(null, copy.getParam("x")); }