private static int repeat ( char [ ] data , int off , int out , Term term ) { switch ( term . type ) { case Term . CHAR : { char c = term . c ; int i = off ; while ( i < out ) { if ( data [ i ] != c ) break ; i ++ ; } return i - off ; } case Term . ANY_CHAR : { return out - off ; } case Term . ANY_CHAR_NE : { int i = off ; char c ; while ( i < out ) { if ( ( c = data [ i ] ) == ' ' || c == ' ' ) break ; i ++ ; } return i - off ; } case Term . BITSET : { IntBitSet arr = term . bitset ; int i = off ; char c ; if ( term . inverse ) while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) break ; else i ++ ; } else while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) i ++ ; else break ; } return i - off ; } case Term . BITSET2 : { int i = off ; IntBitSet [ ] bitset2 = term . bitset2 ; char c ; if ( term . inverse ) while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) break ; else i ++ ; } else while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) i ++ ; else break ; } return i - off ; } } throw new Error ( "this kind of term can't be quantified:" + term . type ) ; }
repeat while matches