in ti/phase2/jars/compiler-xdoclet/src/java/org/apache/ti/compiler/xdoclet/internal/typesystem/impl/declaration/DeclarationImpl.java [292:355]
private static Object parseValue(AnnotationTypeElementDeclaration memberDecl, String strValue, SourcePositionImpl pos) {
TypeInstance type = memberDecl.getReturnType();
if (type instanceof ClassType) {
ClassType classType = (ClassType) type;
String typeName = classType.getClassTypeDeclaration().getQualifiedName();
if (typeName.equals("java.lang.String")) {
return strValue;
} else if (typeName.equals("java.lang.Class")) {
TypeInstance retVal = XDocletCompilerUtils.resolveType(strValue, false, pos.getOuterClass());
if (retVal == null) {
XDocletCompilerUtils.addError(pos, "error.unknown-class",
new String[]{strValue, memberDecl.getSimpleName()});
}
return XDocletCompilerUtils.resolveType(strValue, true, pos.getOuterClass());
} else {
assert false : "unexpected type in annotation declaration: " + typeName;
}
} else if (type instanceof ArrayType) {
ArrayType arrayType = (ArrayType) type;
TypeInstance componentType = arrayType.getComponentType();
// We only handle an array of strings -- nothing else at this point.
assert componentType instanceof DeclaredType : componentType.getClass().getName();
assert ((DeclaredType) componentType).getDeclaration().getQualifiedName().equals(String.class.getName())
: ((DeclaredType) componentType).getDeclaration().getQualifiedName();
StringTokenizer tok = new StringTokenizer(strValue, ",");
ArrayList arrayValues = new ArrayList();
while (tok.hasMoreTokens()) {
arrayValues.add(new AnnotationValueImpl(tok.nextToken().trim(), pos, memberDecl));
}
return arrayValues;
}
assert type instanceof PrimitiveType : type.getClass().getName();
switch (((PrimitiveType) type).getKind().asInt()) {
case PrimitiveType.Kind.INT_BOOLEAN:
return Boolean.valueOf(strValue);
case PrimitiveType.Kind.INT_BYTE:
return new Byte(strValue);
case PrimitiveType.Kind.INT_SHORT:
return new Short(strValue);
case PrimitiveType.Kind.INT_INT:
return new Integer(strValue);
case PrimitiveType.Kind.INT_LONG:
return new Long(strValue);
case PrimitiveType.Kind.INT_FLOAT:
return new Float(strValue);
case PrimitiveType.Kind.INT_DOUBLE:
return new Double(strValue);
}
assert false : "unrecognized type: " + type.toString();
return null;
}