1 26 package com.yworks.yguard.obf; 27 28 import java.io.*; 29 import java.lang.reflect.*; 30 import java.util.*; 31 import com.yworks.yguard.obf.classfile.*; 32 33 38 abstract public class MdFd extends TreeItem 39 { 40 42 43 private String descriptor = null; 45 46 47 49 50 52 public MdFd(TreeItem parent, boolean isSynthetic, String name, String descriptor, int access) 53 { 54 super(parent, name); 55 this.descriptor = descriptor; 56 this.access = access; 57 this.isSynthetic = isSynthetic; 58 if (name.equals("") || descriptor.equals("") || !(parent instanceof Cl)) 59 { 60 System.err.println("Internal error: method/field must have name and descriptor, and have Class or Interface as parent"); 61 } 62 63 if (isSynthetic || Modifier.isNative(access)) 65 { 66 setOutName(getInName()); 67 } 68 } 69 70 71 public String getDescriptor() {return descriptor;} 72 73 74 public String toString() 75 { 76 StringBuffer sb = new StringBuffer (); 77 int modifiers = getModifiers(); 78 if (Modifier.isAbstract(modifiers)) 79 { 80 sb.append("abstract "); 81 } 82 if (Modifier.isSynchronized(modifiers)) 83 { 84 sb.append("synchronized "); 85 } 86 if (Modifier.isTransient(modifiers)) 87 { 88 sb.append("transient "); 89 } 90 if (Modifier.isVolatile(modifiers)) 91 { 92 sb.append("volatile "); 93 } 94 if (Modifier.isNative(modifiers)) 95 { 96 sb.append("native "); 97 } 98 if (Modifier.isPublic(modifiers)) 99 { 100 sb.append("public "); 101 } 102 if (Modifier.isProtected(modifiers)) 103 { 104 sb.append("protected "); 105 } 106 if (Modifier.isPrivate(modifiers)) 107 { 108 sb.append("private "); 109 } 110 if (Modifier.isStatic(modifiers)) 111 { 112 sb.append("static "); 113 } 114 if (Modifier.isFinal(modifiers)) 115 { 116 sb.append("final "); 117 } 118 sb.append(getReturnTypeName()); 119 sb.append(getInName()); 120 sb.append(getDescriptorName()); 121 return sb.toString(); 122 } 123 124 125 protected String getReturnTypeName() 126 { 127 String [] types = parseTypes(); 128 return (types.length > 0 ? types[types.length - 1] : "") + " "; 129 } 130 131 132 abstract protected String getDescriptorName(); 133 134 135 private String [] parsedTypes = null; 136 protected String [] parseTypes() 137 { 138 if (parsedTypes == null) 139 { 140 try 141 { 142 parsedTypes = ClassFile.parseDescriptor(getDescriptor(), true); 143 } 144 catch (Exception e) 145 { 146 parsedTypes = null; 147 } 148 } 149 return parsedTypes; 150 } 151 } 152 | Popular Tags |