1 6 7 package com.hp.hpl.jena.graph.query; 8 9 17 18 public class ConstraintStage extends Stage 19 { 20 23 protected ValuatorSet prepared; 24 25 30 public ConstraintStage( Mapping map, ExpressionSet constraint ) 31 { this.prepared = constraint.prepare( map ); } 32 33 38 private boolean evalConstraint( Domain d, ValuatorSet e ) 39 { try 40 { return e.evalBool( d ); } 41 catch (Exception ex) 42 { ex.printStackTrace( System.err ); return false; } } 43 44 48 public Pipe deliver( final Pipe L ) 49 { 50 final Pipe mine = previous.deliver( new BufferPipe() ); 51 new Thread ( "a ConstraintStage" ) 52 { 53 public void run() 54 { 55 while (mine.hasNext()) 56 { Domain d = mine.get(); 57 if (evalConstraint( d, prepared )) L.put( d ); } 58 L.close(); 59 } 60 } .start(); 61 return L; 62 } 63 } 64 65 94 | Popular Tags |