1 /* *************************************************************************** 2 * Copyright (c) 2008 Brabenetz Harald, Austria. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 *****************************************************************************/ 17 package org.settings4j; 18 19 /** 20 * Interface to implement an cumied filter. 21 * <p> 22 * The default implementation is in {@link org.settings4j.settings.DefaultFilter}. 23 * <p> 24 * A simple "Never-Filter" whould look like: 25 * <pre> 26 * /<nospace/>*<nospace/>* 27 * * The simplest default implementation doesn't filter. 28 * *<nospace/>/ 29 * public static final Filter NO_FILTER = new Filter() { 30 * public void addExclude(final String pattern) { 31 * throw new java.lang.IllegalStateException("This instance of Filter cannot be modified."); 32 * } 33 * public void addInclude(final String pattern) { 34 * throw new java.lang.IllegalStateException("This instance of Filter cannot be modified."); 35 * } 36 * public boolean isValid(final String key) { 37 * return true; 38 * } 39 * }; 40 * </pre> 41 * @author Harald.Brabenetz 42 */ 43 public interface Filter { 44 45 /** 46 * Add an include Pattern (Which pattern-Syntax is determinate by the implementation). 47 * 48 * @param pattern the pattern. 49 */ 50 void addInclude(String pattern); 51 52 /** 53 * Add an exclude Pattern (Which pattern-Syntax is determinate by the implementation). 54 * 55 * @param pattern the pattern. 56 */ 57 void addExclude(String pattern); 58 59 /** 60 * Return true if the key is not filtered out. 61 * @param key The key to check. 62 * @return true if the key is not filtered out. 63 */ 64 boolean isValid(String key); 65 }