1 17 18 package org.apache.avalon.logging.data; 19 20 import java.io.Serializable ; 21 22 44 public class CategoryDirective implements Serializable 45 { 46 47 50 public static final String DEBUG = "DEBUG"; 51 52 55 public static final String INFO = "INFO"; 56 57 60 public static final String WARN = "WARN"; 61 62 65 public static final String ERROR = "ERROR"; 66 67 70 private String m_name; 71 72 75 private final String m_priority; 76 77 80 private final String m_target; 81 82 87 public CategoryDirective( final String name ) 88 { 89 this( name, null, null ); 90 } 91 92 98 public CategoryDirective( final String name, String priority ) 99 { 100 this( name, priority, null ); 101 } 102 103 112 public CategoryDirective( 113 final String name, final String priority, final String target ) 114 { 115 m_name = name; 116 m_target = target; 117 if( priority != null ) 118 { 119 m_priority = priority.trim().toUpperCase(); 120 } 121 else 122 { 123 m_priority = null; 124 } 125 } 126 127 132 public String getName() 133 { 134 return m_name; 135 } 136 137 142 public String getPriority() 143 { 144 return m_priority; 145 } 146 147 152 public String getTarget() 153 { 154 return m_target; 155 } 156 157 public boolean equals(Object other) 158 { 159 if( null == other ) 160 { 161 return false; 162 } 163 164 if( ! ( other instanceof CategoryDirective ) ) 165 { 166 return false; 167 } 168 169 CategoryDirective test = (CategoryDirective) other; 170 return ( equalName( test.getName() ) 171 && equalPriority( test.getPriority() ) 172 && equalTarget( test.getTarget() ) ); 173 } 174 175 private boolean equalName( String other ) 176 { 177 if( m_name == null ) 178 { 179 return other == null; 180 } 181 else 182 { 183 return m_name.equals( other ); 184 } 185 } 186 187 private boolean equalPriority( String other ) 188 { 189 if( m_priority == null ) 190 { 191 return other == null; 192 } 193 else 194 { 195 return m_priority.equals( other ); 196 } 197 } 198 199 private boolean equalTarget( String other ) 200 { 201 if( m_target == null ) 202 { 203 return other == null; 204 } 205 else 206 { 207 return m_target.equals( other ); 208 } 209 } 210 211 public int hashCode() 212 { 213 int hash = m_name.hashCode(); 214 hash >>>= 13; 215 if( m_priority != null ) 216 { 217 hash ^= m_priority.hashCode(); 218 } 219 hash >>>= 5; 220 if( m_target != null ) 221 { 222 hash ^= m_target.hashCode(); 223 } 224 return hash; 225 } 226 } 227 | Popular Tags |