Search in sources :

Example 1 with Tuple

use of org.apache.jena.atlas.lib.Tuple in project jena by apache.

the class ExQuadFilter method createFilter.

/** Create a filter to exclude the graph http://example/g2 */
private static Filter<Tuple<NodeId>> createFilter(Dataset ds) {
    // Filtering operates at a very low level: 
    // Need to know the internal identifier for the graph name. 
    final NodeId target = TDBInternal.getNodeId(ds, NodeFactory.createURI(graphToHide));
    System.out.println("Hide graph: " + graphToHide + " --> " + target);
    // Filter for accept/reject as quad as being visible.
    // Return true for "accept", false for "reject"
    Filter<Tuple<NodeId>> filter = new Filter<Tuple<NodeId>>() {

        @Override
        public boolean accept(Tuple<NodeId> item) {
            //System.err.println(item) ;
            if (item.size() == 4 && item.get(0).equals(target)) {
                //System.out.println("Reject: "+item) ;
                return false;
            }
            //System.out.println("Accept: "+item) ;
            return true;
        }
    };
    return filter;
}
Also used : Filter(org.apache.jena.atlas.iterator.Filter) NodeId(org.apache.jena.tdb.store.NodeId) Tuple(org.apache.jena.atlas.lib.Tuple)

Aggregations

Filter (org.apache.jena.atlas.iterator.Filter)1 Tuple (org.apache.jena.atlas.lib.Tuple)1 NodeId (org.apache.jena.tdb.store.NodeId)1