1 56 57 package org.jdom.filter; 58 59 66 final class OrFilter extends AbstractFilter { 67 68 private static final String CVS_ID = 69 "@(#) $RCSfile: OrFilter.java,v $ $Revision: 1.4 $ $Date: 2004/02/06 09:28:31 $"; 70 71 72 private Filter left; 73 74 75 private Filter right; 76 77 84 public OrFilter(Filter left, Filter right) { 85 if ((left == null) || (right == null)) { 86 throw new IllegalArgumentException ("null filter not allowed"); 87 } 88 this.left = left; 89 this.right = right; 90 } 91 92 public boolean matches(Object obj) { 93 return left.matches(obj) || right.matches(obj); 94 } 95 96 public boolean equals(Object obj) { 97 if (this == obj) { 98 return true; 99 } 100 101 if (obj instanceof OrFilter) { 102 OrFilter filter = (OrFilter) obj; 103 if ((left.equals(filter.left) && right.equals(filter.right)) || 104 (left.equals(filter.right) && right.equals(filter.left))) { 105 return true; 106 } 107 } 108 return false; 109 } 110 111 public int hashCode() { 112 return (31 * left.hashCode()) + right.hashCode(); 113 } 114 115 public String toString() { 116 return new StringBuffer (64) 117 .append("[OrFilter: ") 118 .append(left.toString()) 119 .append(",\n") 120 .append(" ") 121 .append(right.toString()) 122 .append("]") 123 .toString(); 124 } 125 } 126 | Popular Tags |