001    package org.shiftone.jrat.core.criteria;
002    
003    import org.shiftone.jrat.util.log.Logger;
004    
005    
006    /**
007     * Used by ant task.
008     * (p1 or p2 or p3 or p4) and not(n1 or n2 or n3).
009     *
010     * @author jeff@shiftone.org (Jeff Drost)
011     */
012    public class IncludeExcludeMethodCriteria implements MethodCriteria {
013    
014        private static final Logger LOG = Logger.getLogger(IncludeExcludeMethodCriteria.class);
015        private final AndMethodCriteria root;
016        private final OrMethodCriteria positive;
017        private final OrMethodCriteria negative;
018    
019        public IncludeExcludeMethodCriteria() {
020    
021            root = new AndMethodCriteria();
022            positive = new OrMethodCriteria();
023            negative = new OrMethodCriteria();
024    
025            root.addCriteria(positive);
026            root.addCriteria(new NotMethodCriteria(negative));
027        }
028    
029    
030        public void addPositive(MethodCriteria criteria) {
031            positive.addCriteria(criteria);
032        }
033    
034    
035        public void addNegative(MethodCriteria criteria) {
036            negative.addCriteria(criteria);
037        }
038    
039    
040        public boolean isMatch(String className, long modifier) {
041            return root.isMatch(className, modifier);
042        }
043    
044    
045        public boolean isMatch(String className, String methodName, String signature, long modifier) {
046            return root.isMatch(className, methodName, signature, modifier);
047        }
048    }