views:

43

answers:

1

Hi, I'm using QDox to parse a .java file. The file contains a method like this:

public int getSomething (Vector<Integer> numbers);

the problem is I don't know how to get the Integer class using the reflection which QDox provides. Any idea of how can I get it?

A: 

If it's the type of a method's parameter your interested in, you can obtain if from the Method:

    Method method = myclass.getMethod("getSomething", Vector.class);
    Type atypes[] = method.getGenericParameterTypes();
    if (atypes[0] instanceof ParameterizedType) {
        ParameterizedType ptype = (ParameterizedType)atypes[0];
        Type aatypes[] = ptype.getActualTypeArguments();
        System.out.println(aatypes[0]);
    }
Maurice Perry
but what class is myclass ?
Federico
The class that has the method `public int getSomething (Vector<Integer> numbers)`
gpeche
I believe this answer is for normal reflection (i.e. java.lang.reflect), not for QDox.
Kirk Woll
I don't undertand. From where is getMethod ?
Federico
from java.lang.Class
Maurice Perry
My class is com.thoughtworks.qdox.model.Type and it doesn't have that
Federico