1 4 package com.openedit.util.strainer; 5 6 11 public class NotFilter implements DecoratorFilter 12 { 13 protected Filter fieldFilter = null; 14 15 18 public NotFilter() 19 { 20 } 21 22 27 public NotFilter(Filter inFilter) 28 { 29 fieldFilter = inFilter; 30 } 31 32 37 public Filter getFilter() 38 { 39 return fieldFilter; 40 } 41 42 45 public Filter[] getFilters() 46 { 47 Filter[] array = new Filter[1]; 48 array[0] = fieldFilter; 49 return array; 50 } 51 52 57 public void setFilter(Filter newFilter) 58 { 59 fieldFilter = newFilter; 60 } 61 62 76 public boolean passes(Object inObj) throws FilterException, ClassCastException 77 { 78 if ( fieldFilter == null) 79 { 80 return false; 81 } 82 return !fieldFilter.passes(inObj); 83 } 84 85 88 public void accept(FilterVisitor inFilterVisitor) throws FilterException 89 { 90 if (inFilterVisitor instanceof NotFilterVisitor) 91 { 92 ((NotFilterVisitor) inFilterVisitor).visitNotFilter(this); 93 } 94 } 95 96 99 public String toString() 100 { 101 return "not (" + getFilter().toString() + ")"; 102 } 103 } 104 | Popular Tags |