private static boolean nodeMatches(Node thisNode, Node otherNode) { // otherNode may be Node.ANY, and this works out. return otherNode.matches(thisNode) ; }
public boolean predicateMatches( Node p ) { return pred.matches( p ); }
public boolean subjectMatches( Node s ) { return subj.matches( s ); }
public boolean objectMatches( Node o ) { return obj.matches( o ); }
public boolean subjectMatches( Node s ) { return subj.matches( s ); }
public boolean objectMatches( Node o ) { return obj.matches( o ); }
public boolean predicateMatches( Node p ) { return pred.matches( p ); }
public boolean hasAnchor(Node node) { Objects.requireNonNull(node); return node.matches(anchorVar); } // private TreeMultimap<Node, RDFResourceTree> edge2Children = TreeMultimap.create(
/** * Find nodes matching the data in the given tree. */ private List<RDFResourceTree> getMatchingTreeNodes(RDFResourceTree tree, Node node) { List<RDFResourceTree> treeNodes = new ArrayList<>(); TreeTraversal<RDFResourceTree> treeTraversal = new PreOrderTreeTraversal<>(tree); treeTraversal.forEachRemaining(treeNode -> { if(treeNode.getData().matches(node)) { treeNodes.add(treeNode); } }); return treeNodes; }
public void testSimpleMatches() { assertTrue( NodeCreateUtils.create( "S").matches( NodeCreateUtils.create( "S" ) ) ); assertFalse( "", NodeCreateUtils.create( "S").matches( NodeCreateUtils.create( "T" ) ) ); assertFalse( "", NodeCreateUtils.create( "S" ).matches( null ) ); assertTrue( NodeCreateUtils.create( "_X").matches( NodeCreateUtils.create( "_X" ) ) ); assertFalse( "", NodeCreateUtils.create( "_X").matches( NodeCreateUtils.create( "_Y" ) ) ); assertFalse( "", NodeCreateUtils.create( "_X").matches( null ) ); assertTrue( NodeCreateUtils.create( "10" ).matches( NodeCreateUtils.create( "10" ) ) ); assertFalse( "", NodeCreateUtils.create( "10" ).matches( NodeCreateUtils.create( "11" ) ) ); assertFalse( "", NodeCreateUtils.create( "10" ).matches( null ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "S" ) ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "_X" ) ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "10" ) ) ); assertFalse( "", Node.ANY.matches( null ) ); }
public void testSimpleMatches() { assertTrue( NodeCreateUtils.create( "S").matches( NodeCreateUtils.create( "S" ) ) ); assertFalse( "", NodeCreateUtils.create( "S").matches( NodeCreateUtils.create( "T" ) ) ); assertFalse( "", NodeCreateUtils.create( "S" ).matches( null ) ); assertTrue( NodeCreateUtils.create( "_X").matches( NodeCreateUtils.create( "_X" ) ) ); assertFalse( "", NodeCreateUtils.create( "_X").matches( NodeCreateUtils.create( "_Y" ) ) ); assertFalse( "", NodeCreateUtils.create( "_X").matches( null ) ); assertTrue( NodeCreateUtils.create( "10" ).matches( NodeCreateUtils.create( "10" ) ) ); assertFalse( "", NodeCreateUtils.create( "10" ).matches( NodeCreateUtils.create( "11" ) ) ); assertFalse( "", NodeCreateUtils.create( "10" ).matches( null ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "S" ) ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "_X" ) ) ); assertTrue( Node.ANY.matches( NodeCreateUtils.create( "10" ) ) ); assertFalse( "", Node.ANY.matches( null ) ); }
protected RDFResourceTree processLiteralNodes(RDFResourceTree tree1, RDFResourceTree tree2) { RDFDatatype d1 = tree1.getData().getLiteralDatatype(); RDFDatatype d2 = tree2.getData().getLiteralDatatype(); RDFResourceTree newTree; if(d1 != null && d1.equals(d2)){ newTree = new RDFResourceTree(d1); // TODO collect literal values } else { newTree = RDFResourceTree.newLiteralNode(); } if(tree1.getAnchorVar() != null && tree1.getAnchorVar().matches(tree2.getAnchorVar())) { newTree.setAnchorVar(tree1.getAnchorVar()); } return newTree; }
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 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 ) ); }