1 19 20 package jode.obfuscator; 21 import java.lang.reflect.Modifier ; 22 import jode.bytecode.*; 23 import java.util.Collection ; 24 import java.util.Collections ; 25 import java.util.Iterator ; 26 import java.util.HashSet ; 27 import java.util.Map ; 28 29 30 public class FieldIdentifier extends Identifier{ 31 FieldInfo info; 32 ClassIdentifier clazz; 33 String name; 34 String type; 35 40 private boolean notConstant; 41 private Object constant; 42 43 47 private Collection fieldListeners; 48 49 public FieldIdentifier(ClassIdentifier clazz, FieldInfo info) { 50 super(info.getName()); 51 this.name = info.getName(); 52 this.type = info.getType(); 53 this.info = info; 54 this.clazz = clazz; 55 this.constant = info.getConstant(); 56 } 57 58 public void setSingleReachable() { 59 super.setSingleReachable(); 60 Main.getClassBundle().analyzeIdentifier(this); 61 } 62 63 public void setSinglePreserved() { 64 super.setSinglePreserved(); 65 setNotConstant(); 66 } 67 68 public void analyze() { 69 String type = getType(); 70 int index = type.indexOf('L'); 71 if (index != -1) { 72 int end = type.indexOf(';', index); 73 Main.getClassBundle().reachableClass 74 (type.substring(index+1, end).replace('/', '.')); 75 } 76 } 77 78 public Identifier getParent() { 79 return clazz; 80 } 81 82 public String getFullName() { 83 return clazz.getFullName() + "." + getName() + "." + getType(); 84 } 85 86 public String getFullAlias() { 87 return clazz.getFullAlias() + "." + getAlias() + "." 88 + Main.getClassBundle().getTypeAlias(getType()); 89 } 90 91 public String getName() { 92 return name; 93 } 94 95 public String getType() { 96 return type; 97 } 98 99 public int getModifiers() { 100 return info.getModifiers(); 101 } 102 103 public Iterator getChilds() { 104 return Collections.EMPTY_LIST.iterator(); 105 } 106 107 public boolean isNotConstant() { 108 return notConstant; 109 } 110 111 public Object getConstant() { 112 return constant; 113 } 114 115 public void addFieldListener(Identifier ident) { 116 if (ident == null) 117 throw new NullPointerException (); 118 if (fieldListeners == null) 119 fieldListeners = new HashSet (); 120 if (!fieldListeners.contains(ident)) 121 fieldListeners.add(ident); 122 } 123 124 public void setNotConstant() { 125 if (notConstant) 126 return; 127 128 notConstant = true; 129 if (fieldListeners == null) 130 return; 131 132 for (Iterator i = fieldListeners.iterator(); i.hasNext(); ) 133 Main.getClassBundle().analyzeIdentifier((Identifier) i.next()); 134 fieldListeners = null; 135 } 136 137 public String toString() { 138 return "FieldIdentifier "+getFullName(); 139 } 140 141 public boolean conflicting(String newAlias) { 142 return clazz.fieldConflicts(this, newAlias); 143 } 144 145 public void doTransformations() { 146 info.setName(getAlias()); 147 info.setType(Main.getClassBundle().getTypeAlias(type)); 148 } 149 } 150 | Popular Tags |