/** * Bind the ith variable in the current envionment to the given value. * Checks that the new binding is compatible with any current binding. * @return false if the binding fails */ public boolean bind(int i, Node value) { Node node = environment[i]; if (node == null) { environment[i] = value; return true; } else { return node.sameValueAs(value); } }
@Override public Predicate<Triple> filterOn( final Node n ) { return n.isConcrete() ? x -> n.sameValueAs( x.obj ) : anyTriple; } };
@Override public Predicate<Triple> filterOn( final Node n ) { return n.isConcrete() ? x -> n.sameValueAs( x.obj ) : anyTriple; } };
/** * Test that two literals are semantically equivalent. * In some cases this may be the same as equals, in others * equals is stricter. For example, two xsd:int literals with * the same value but different language tag are semantically * equivalent but distinguished by the java equality function * in order to support round tripping. */ @Override public boolean sameValueAs(Literal other) { return asNode().sameValueAs(other.asNode()); }
/** * Test that two literals are semantically equivalent. * In some cases this may be the same as equals, in others * equals is stricter. For example, two xsd:int literals with * the same value but different language tag are semantically * equivalent but distinguished by the java equality function * in order to support round tripping. */ @Override public boolean sameValueAs(Literal other) { return asNode().sameValueAs(other.asNode()); }
private static QueryIterator evalGroundedPath(Binding binding, Graph graph, Node subject, Path path, Node object, ExecutionContext execCxt) { Iterator<Node> iter = PathEval.eval(graph, subject, path, execCxt.getContext()) ; // Now count the number of matches. int count = 0 ; for ( ; iter.hasNext() ; ) { Node n = iter.next() ; if ( n.sameValueAs(object) ) count++ ; } return new QueryIterYieldN(count, binding, execCxt) ; }
/** Test that XSD anyURI is not sameValueAs XSD string (Xerces returns a string as the value for both) */ public void testXSDanyURI() { Node node1 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDanyURI) ; Node node2 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDstring) ; assertFalse(node1.sameValueAs(node2)) ; }
/** Test that XSD anyURI is not sameValueAs XSD string (Xerces returns a string as the value for both) */ public void testXSDanyURI() { Node node1 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDanyURI) ; Node node2 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDstring) ; assertFalse(node1.sameValueAs(node2)) ; }
public void testFloatVsDouble() { Node A = NodeCreateUtils.create( "'1'xsd:float" ); Node B = NodeCreateUtils.create( "'1'xsd:double" ); assertFalse( A.equals( B ) ); assertFalse( A.sameValueAs( B ) ); assertFalse( B.sameValueAs( A ) ); assertFalse( A.matches( B ) ); assertFalse( B.matches( A ) ); }
public void testDataMatches() { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dt1 = tm.getTypeByValue( new Integer( 10 ) ); RDFDatatype dt2 = tm.getTypeByValue( new Short( (short) 10 ) ); Node a = NodeFactory.createLiteral( "10", dt1 ); Node b = NodeFactory.createLiteral( "10", dt2 ); assertDiffer( "types must make a difference", a, b ); assertTrue( "A and B must express the same value", a.sameValueAs( b ) ); assertTrue( "matching literals must respect sameValueAs", a.matches( b ) ); }
public void testDataMatches() { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dt1 = tm.getTypeByValue( new Integer( 10 ) ); RDFDatatype dt2 = tm.getTypeByValue( new Short( (short) 10 ) ); Node a = NodeFactory.createLiteral( "10", dt1 ); Node b = NodeFactory.createLiteral( "10", dt2 ); assertDiffer( "types must make a difference", a, b ); assertTrue( "A and B must express the same value", a.sameValueAs( b ) ); assertTrue( "matching literals must respect sameValueAs", a.matches( b ) ); }
public void testCreateLanguagedLiteralEN2() { Node n1 = NodeCreateUtils.create( "'chat'en-UK" ); Node n2 = NodeCreateUtils.create( "'chat'EN-UK" ); assertTrue( n1.sameValueAs(n2) ) ; assertFalse( n1.equals(n2) ) ; }
public void testCreateLanguagedLiteralEN2() { Node n1 = NodeCreateUtils.create( "'chat'en-UK" ); Node n2 = NodeCreateUtils.create( "'chat'EN-UK" ); assertTrue( n1.sameValueAs(n2) ) ; assertFalse( n1.equals(n2) ) ; }
public void testFloatVsDouble() { Node A = NodeCreateUtils.create( "'1'xsd:float" ); Node B = NodeCreateUtils.create( "'1'xsd:double" ); assertFalse( A.equals( B ) ); assertFalse( A.sameValueAs( B ) ); assertFalse( B.sameValueAs( A ) ); assertFalse( A.matches( B ) ); assertFalse( B.matches( A ) ); }
public void testNoMatchAgainstUnlanguagesLiteral() { Graph m = graphWith( "a p 'chat'en; a p 'chat'" ); if (m.getCapabilities().handlesLiteralTyping()) { Node chaten = node( "'chat'en" ), chatEN = node( "'chat'EN" ); assertDiffer( chaten, chatEN ); assertTrue( chaten.sameValueAs( chatEN ) ); assertEquals( chaten.getIndexingValue(), chatEN.getIndexingValue() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chaten ).toList().size() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chatEN ).toList().size() ); } }
public void testMatchLanguagedLiteralCaseInsensitive() { Graph m = graphWith( "a p 'chat'en" ); if (m.getCapabilities().handlesLiteralTyping()) { Node chaten = node( "'chat'en" ), chatEN = node( "'chat'EN" ); assertDiffer( chaten, chatEN ); assertTrue( chaten.sameValueAs( chatEN ) ); assertEquals( chaten.getIndexingValue(), chatEN.getIndexingValue() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chaten ).toList().size() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chatEN ).toList().size() ); } }
public void testMatchLanguagedLiteralCaseInsensitive() { Graph m = graphWith( "a p 'chat'en" ); if (m.getCapabilities().handlesLiteralTyping()) { Node chaten = node( "'chat'en" ), chatEN = node( "'chat'EN" ); assertDiffer( chaten, chatEN ); assertTrue( chaten.sameValueAs( chatEN ) ); assertEquals( chaten.getIndexingValue(), chatEN.getIndexingValue() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chaten ).toList().size() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chatEN ).toList().size() ); } }
public void testMatchBothLanguagedLiteralsCaseInsensitive() { Graph m = graphWith( "a p 'chat'en; a p 'chat'EN" ); if (m.getCapabilities().handlesLiteralTyping()) { Node chaten = node( "'chat'en" ), chatEN = node( "'chat'EN" ); assertDiffer( chaten, chatEN ); assertTrue( chaten.sameValueAs( chatEN ) ); assertEquals( chaten.getIndexingValue(), chatEN.getIndexingValue() ); assertEquals( 2, m.find( Node.ANY, Node.ANY, chaten ).toList().size() ); assertEquals( 2, m.find( Node.ANY, Node.ANY, chatEN ).toList().size() ); } }
public void testNoMatchAgainstUnlanguagesLiteral() { Graph m = graphWith( "a p 'chat'en; a p 'chat'" ); if (m.getCapabilities().handlesLiteralTyping()) { Node chaten = node( "'chat'en" ), chatEN = node( "'chat'EN" ); assertDiffer( chaten, chatEN ); assertTrue( chaten.sameValueAs( chatEN ) ); assertEquals( chaten.getIndexingValue(), chatEN.getIndexingValue() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chaten ).toList().size() ); assertEquals( 1, m.find( Node.ANY, Node.ANY, chatEN ).toList().size() ); } }
@Test public void testSqrt1() { NodeValue four = NodeValue.makeInteger(4) ; NodeValue two = NodeValue.makeDouble(2) ; NodeValue result = XSDFuncOp.sqrt( four ) ; assertTrue(result.isDouble()) ; assertFalse(result.isDecimal()) ; assertTrue( NodeValue.sameAs( two, result)) ; assertTrue( two.asNode().sameValueAs(result.asNode()) ) ; }