1 21 package proguard.classfile.util; 22 23 import proguard.classfile.*; 24 25 26 37 public class ExternalTypeEnumeration 38 { 39 private String descriptor; 40 private int index; 41 42 43 public ExternalTypeEnumeration(String descriptor) 44 { 45 setDescriptor(descriptor); 46 } 47 48 49 ExternalTypeEnumeration() 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.EXTERNAL_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 index < descriptor.length() - 1; 76 } 77 78 79 public String nextType() 80 { 81 int startIndex = index; 82 83 index = descriptor.indexOf(ClassConstants.EXTERNAL_METHOD_ARGUMENTS_SEPARATOR, 85 startIndex); 86 87 if (index < 0) 89 { 90 index = descriptor.indexOf(ClassConstants.EXTERNAL_METHOD_ARGUMENTS_CLOSE, 91 startIndex); 92 if (index < 0) 93 { 94 throw new IllegalArgumentException ("Missing closing parenthesis in descriptor ["+descriptor+"]"); 95 } 96 } 97 98 return descriptor.substring(startIndex, index++).trim(); 99 } 100 101 102 public String methodName() 103 { 104 return descriptor.substring(0, descriptor.indexOf(ClassConstants.EXTERNAL_METHOD_ARGUMENTS_OPEN)).trim(); 105 } 106 } 107 | Popular Tags |