/** * Returns <code>true</code> if the given value was rejected by this filter, <code>false</code> if it was accepted. * * <p>The {@link #isInverted() inverted} mode has no effect on the values returned by this method.</p> * * @param value the value to be tested * @return true if the given value was rejected by this filter */ public boolean reject(C value) { return !accept(value); }
/** * Convenience method that returns <code>true</code> if all the values in the specified array were accepted by * {@link #accept(Object)}, <code>false</code> if one of the values wasn't. * * @param values the values to be tested * @return true if all the values in the specified array were accepted */ public boolean accept(C values[]) { int nbFiles = values.length; for(int i=0; i<nbFiles; i++) if(!accept(values[i])) return false; return true; }
public boolean accept(AbstractFile file) { return accept(generator.getCriterionValue(file)); } }
/** * Convenience method that filters out files that do not {@link #match(AbstractFile) match} this filter and * returns a file array of matched <code>AbstractFile</code> instances. * * @param values values to be tested * @return an array of accepted AbstractFile instances */ public C[] filter(C values[]) { Vector<C> filteredValuesV = new Vector<C>(); int nbvalues = values.length; C value; for(int i=0; i<nbvalues; i++) { value = values[i]; if(accept(value)) filteredValuesV.add(value); } C filteredValues[] = (C[]) new Object[filteredValuesV.size()]; filteredValuesV.toArray(filteredValues); return filteredValues; }
/** * Returns <code>true</code> if this filter matched the given value, according to the current {@link #isInverted()} * mode: * <ul> * <li>if this filter currently operates in normal (non-inverted) mode, this method will return the value of * {@link #accept(Object)}</li> * <li>if this filter currently operates in inverted mode, this method will return the value of * {@link #reject(Object)}</li> * </ul> * * @param value the value to test * @return true if this filter matched the given value, according to the current inverted mode */ public boolean match(C value) { if(inverted) return reject(value); return accept(value); }