1 19 20 package jode.bytecode; 21 import jode.util.UnifyHash; 22 import java.util.Iterator ; 23 24 27 public class Reference { 28 31 private final String clazz, name, type; 32 33 private static final UnifyHash unifier = new UnifyHash(); 34 35 public static Reference getReference(String className, 36 String name, String type) { 37 int hash = className.hashCode() ^ name.hashCode() ^ type.hashCode(); 38 Iterator iter = unifier.iterateHashCode(hash); 39 while (iter.hasNext()) { 40 Reference ref = (Reference) iter.next(); 41 if (ref.clazz.equals(className) 42 && ref.name.equals(name) 43 && ref.type.equals(type)) 44 return ref; 45 } 46 Reference ref = new Reference(className, name, type); 47 unifier.put(hash, ref); 48 return ref; 49 } 50 51 private Reference(String clazz, String name, String type) { 52 this.clazz = clazz; 53 this.name = name; 54 this.type = type; 55 } 56 57 public String getClazz() { 58 return clazz; 59 } 60 61 public String getName() { 62 return name; 63 } 64 65 public String getType() { 66 return type; 67 } 68 69 public String toString() { 70 return clazz + " " + name + " " + type; 71 } 72 } 73 | Popular Tags |