1 21 package proguard.classfile.util; 22 23 import proguard.classfile.*; 24 25 26 37 public class InternalTypeEnumeration 38 { 39 private String descriptor; 40 private int index; 41 42 43 public InternalTypeEnumeration(String descriptor) 44 { 45 setDescriptor(descriptor); 46 } 47 48 49 public InternalTypeEnumeration() 50 { 51 } 52 53 54 void setDescriptor(String descriptor) 55 { 56 this.descriptor = descriptor; 57 58 reset(); 59 } 60 61 62 public void reset() 63 { 64 index = descriptor.indexOf(ClassConstants.INTERNAL_METHOD_ARGUMENTS_OPEN) + 1; 65 66 if (index < 1) 67 { 68 throw new IllegalArgumentException ("Missing opening parenthesis in descriptor ["+descriptor+"]"); 69 } 70 } 71 72 73 public boolean hasMoreTypes() 74 { 75 return descriptor.charAt(index) != ClassConstants.INTERNAL_METHOD_ARGUMENTS_CLOSE; 76 } 77 78 79 public String nextType() 80 { 81 int startIndex = index; 82 83 while (descriptor.charAt(index) == ClassConstants.INTERNAL_TYPE_ARRAY) 85 { 86 index++; 87 } 88 89 if (descriptor.charAt(index) == ClassConstants.INTERNAL_TYPE_CLASS_START) 91 { 92 index = descriptor.indexOf(ClassConstants.INTERNAL_TYPE_CLASS_END, 93 index + 1); 94 if (index < 0) 95 { 96 throw new IllegalArgumentException ("Missing closing class type in descriptor ["+descriptor+"]"); 97 } 98 } 99 100 return descriptor.substring(startIndex, ++index); 101 } 102 103 104 public String returnType() 105 { 106 return descriptor.substring(descriptor.indexOf(ClassConstants.INTERNAL_METHOD_ARGUMENTS_CLOSE) + 1); 107 } 108 } 109 | Popular Tags |