164 if (typePath == null || typePath.length() == 0) { 165 return null; 166 } 167 int n = typePath.length(); 168 ByteVector out = new ByteVector(n); 169 out.putByte(0); 170 for (int i = 0; i < n;) { 171 char c = typePath.charAt(i++); 172 if (c == '[') { 173 out.put11(ARRAY_ELEMENT, 0); 174 } else if (c == '.') { 175 out.put11(INNER_TYPE, 0); 176 } else if (c == '*') { 177 out.put11(WILDCARD_BOUND, 0); 178 } else if (c >= '0' && c <= '9') { 179 int typeArg = c - '0'; 180 while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') { 181 typeArg = typeArg * 10 + c - '0'; 182 i += 1; 183 } 184 out.put11(TYPE_ARGUMENT, typeArg); 185 } 186 } 187 out.data[0] = (byte) (out.length / 2); 188 return new TypePath(out.data, 0); 189 } 190 191 /** 192 * Returns a string representation of this type path. {@link #ARRAY_ELEMENT 193 * ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE 194 * INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps 195 * with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type 196 * argument index in decimal form. 197 */ 198 @Override 199 public String toString() { 200 int length = getLength(); 201 StringBuilder result = new StringBuilder(length * 2); 202 for (int i = 0; i < length; ++i) { 203 switch (getStep(i)) { 204 case ARRAY_ELEMENT: 205 result.append('['); 206 break; 207 case INNER_TYPE: 208 result.append('.'); 209 break; 210 case WILDCARD_BOUND: 211 result.append('*'); 212 break; 213 case TYPE_ARGUMENT: 214 result.append(getStepArgument(i)); 215 break; 216 default: 217 result.append('_'); 218 } 219 } 220 return result.toString(); 221 } 222 } | 164 if (typePath == null || typePath.length() == 0) { 165 return null; 166 } 167 int n = typePath.length(); 168 ByteVector out = new ByteVector(n); 169 out.putByte(0); 170 for (int i = 0; i < n;) { 171 char c = typePath.charAt(i++); 172 if (c == '[') { 173 out.put11(ARRAY_ELEMENT, 0); 174 } else if (c == '.') { 175 out.put11(INNER_TYPE, 0); 176 } else if (c == '*') { 177 out.put11(WILDCARD_BOUND, 0); 178 } else if (c >= '0' && c <= '9') { 179 int typeArg = c - '0'; 180 while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') { 181 typeArg = typeArg * 10 + c - '0'; 182 i += 1; 183 } 184 if (i < n && typePath.charAt(i) == ';') { 185 i += 1; 186 } 187 out.put11(TYPE_ARGUMENT, typeArg); 188 } 189 } 190 out.data[0] = (byte) (out.length / 2); 191 return new TypePath(out.data, 0); 192 } 193 194 /** 195 * Returns a string representation of this type path. {@link #ARRAY_ELEMENT 196 * ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE 197 * INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps 198 * with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type 199 * argument index in decimal form followed by ';'. 200 */ 201 @Override 202 public String toString() { 203 int length = getLength(); 204 StringBuilder result = new StringBuilder(length * 2); 205 for (int i = 0; i < length; ++i) { 206 switch (getStep(i)) { 207 case ARRAY_ELEMENT: 208 result.append('['); 209 break; 210 case INNER_TYPE: 211 result.append('.'); 212 break; 213 case WILDCARD_BOUND: 214 result.append('*'); 215 break; 216 case TYPE_ARGUMENT: 217 result.append(getStepArgument(i)).append(';'); 218 break; 219 default: 220 result.append('_'); 221 } 222 } 223 return result.toString(); 224 } 225 } |