public static NodeSequence limit ( NodeSequence sequence , Limit limitAndOffset ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( limitAndOffset != null && ! limitAndOffset . isUnlimited ( ) ) { final int limit = limitAndOffset . getRowLimit ( ) ; // Perform the skip first ... if ( limitAndOffset . isOffset ( ) ) { sequence = skip ( sequence , limitAndOffset . getOffset ( ) ) ; } // And then the offset ... if ( limit != Integer . MAX_VALUE ) { sequence = limit ( sequence , limit ) ; } } return sequence ; }
Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of nodes returned .