1 11 package org.eclipse.jdt.internal.compiler.env; 12 13 import org.eclipse.jdt.core.compiler.CharOperation; 14 import org.eclipse.jdt.core.compiler.IProblem; 15 16 public class AccessRule { 17 18 public static final int IgnoreIfBetter = 0x02000000; 20 public char[] pattern; 21 public int problemId; 22 23 public AccessRule(char[] pattern, int problemId) { 24 this(pattern, problemId, false); 25 } 26 27 public AccessRule(char[] pattern, int problemId, boolean keepLooking) { 28 this.pattern = pattern; 29 this.problemId = keepLooking ? problemId | IgnoreIfBetter : problemId; 30 } 31 32 public int hashCode() { 33 return this.problemId * 17 + CharOperation.hashCode(this.pattern); 34 } 35 36 public boolean equals(Object obj) { 37 if (!(obj instanceof AccessRule)) return false; 38 AccessRule other = (AccessRule) obj; 39 if (this.problemId != other.problemId) return false; 40 return CharOperation.equals(this.pattern, other.pattern); 41 } 42 43 public int getProblemId() { 44 return this.problemId & ~IgnoreIfBetter; 45 } 46 47 public boolean ignoreIfBetter() { 48 return (this.problemId & IgnoreIfBetter) != 0; 49 } 50 51 public String toString() { 52 StringBuffer buffer = new StringBuffer (); 53 buffer.append("pattern="); buffer.append(this.pattern); 55 switch (getProblemId()) { 56 case IProblem.ForbiddenReference: 57 buffer.append(" (NON ACCESSIBLE"); break; 59 case IProblem.DiscouragedReference: 60 buffer.append(" (DISCOURAGED"); break; 62 default: 63 buffer.append(" (ACCESSIBLE"); break; 65 } 66 if (ignoreIfBetter()) 67 buffer.append(" | IGNORE IF BETTER"); buffer.append(')'); 69 return buffer.toString(); 70 } 71 } 72 | Popular Tags |