1 7 34 35 package com.sun.tools.example.debug.bdi; 36 37 import com.sun.jdi.*; 38 import java.util.StringTokenizer ; 39 40 class PatternReferenceTypeSpec implements ReferenceTypeSpec { 41 final boolean isWild; 42 final String classId; 43 44 PatternReferenceTypeSpec(String classId) 45 { 47 isWild = classId.startsWith("*."); 49 if (isWild) { 50 this.classId = classId.substring(1); 51 } else { 52 this.classId = classId; 53 } 54 } 55 56 59 public boolean matches(ReferenceType refType) { 60 if (isWild) { 61 return refType.name().endsWith(classId); 62 } else { 63 return refType.name().equals(classId); 64 } 65 } 66 67 public int hashCode() { 68 return classId.hashCode(); 69 } 70 71 public boolean equals(Object obj) { 72 if (obj instanceof PatternReferenceTypeSpec) { 73 PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj; 74 75 return classId.equals(spec.classId) && (isWild == spec.isWild); 76 } else { 77 return false; 78 } 79 } 80 81 private void checkClassName(String className) throws ClassNotFoundException { 82 StringTokenizer tokenizer = new StringTokenizer (className, "."); 87 boolean first = true; 88 while (tokenizer.hasMoreTokens()) { 89 String token = tokenizer.nextToken(); 90 if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) { 95 throw new ClassNotFoundException (); 96 } 97 first = false; 98 } 99 } 100 101 public String toString() { 102 return isWild? "*" + classId : classId; 103 } 104 } 105 106 107 | Popular Tags |