public void addFilter ( Filter filter ) { filter . setInitialContext ( initialContext ) ; int minIndex = Integer . MAX_VALUE ; String [ ] before = filter . before ( ) ; for ( int i = 0 ; i < before . length ; i ++ ) { String s = before [ i ] ; int index = index ( activeFilters , s ) ; if ( index < minIndex ) { minIndex = index ; } } if ( minIndex == Integer . MAX_VALUE ) { // -1 is more usable for not-found than MAX_VALUE minIndex = - 1 ; } if ( contains ( filter . before ( ) , FIRST_IN_PIPE ) ) { activeFilters . add ( 0 , filter ) ; } else if ( minIndex != - 1 ) { activeFilters . add ( minIndex , filter ) ; } else { activeFilters . add ( filter ) ; } }
Add a filter to the active pipe