I found a solution, but it seems to me to be a lot of complicated :

private Object getObjectInstance(String typeName){
try {
Class cl = Class.forName(typeName);
try {
java.lang.reflect.Constructor co = cl.getConstructor();
try {
return co.newInstance();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} catch (SecurityException e1) {
e1.printStackTrace();
} catch (NoSuchMethodException e1) {
e1.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
public String generate(TreeLogger logger, GeneratorContext context, String 
typeName) throws UnableToCompleteException {
 .......
 Object object = getObjectInstance(typeName); // Create a new instance of 
the object parsing
 JField[] fields = classType.getFields();
 for (int i = 0; i < fields.length; i++){
 Class c = object.getClass();
 try {
 Field fielda = c.getField("aaa");
 try {
  if 
(field.getType().getParameterizedQualifiedSourceName().equals("java.lang.String[]")){
  String[] fieldValue = (String[]) fielda.get(object);
  System.out.println(fieldValue[0]);
 }else 
if(field.getType().getParameterizedQualifiedSourceName().equals("int[]")){
  int[] fieldValue = (int[]) fielda.get(object);
  System.out.println(fieldValue[0].toString());
 }else
 .....
 .....
 .....
 } catch (IllegalArgumentException e) {
 e.printStackTrace();
 } catch (IllegalAccessException e) {
 e.printStackTrace();
 }
 } catch (SecurityException e) {
 e.printStackTrace();
 } catch (NoSuchFieldException e) {
 e.printStackTrace();
 }
 .....

Have someone other idea?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to