public static NodeSequence filter ( final NodeSequence sequence , final RowFilter filter ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( filter == null || sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { @ Override public long getRowCount ( ) { // we don't know how the filter affects the row count ... return - 1 ; } @ Override public int width ( ) { return sequence . width ( ) ; } @ Override public boolean isEmpty ( ) { // not known to be empty, so always return false ... return false ; } @ Override public Batch nextBatch ( ) { Batch next = sequence . nextBatch ( ) ; return batchFilteredWith ( next , filter ) ; } @ Override public void close ( ) { sequence . close ( ) ; } @ Override public String toString ( ) { return "(filtered width=" + width ( ) + " " + filter + " " + sequence + ")" ; } } ; }
Create a sequence of nodes that all satisfy the supplied filter .