Pergunta

How do I access a object of some other class through my class?? I tried toString but it can display contents only of its own object not other class objects.

Basically, I am able to access Bugzilla Webservice API through java code(xmlrpc) and in return i get a object of class java.util.HashMap. But i am unable to understand how to access the object returned.

    Object createResult = rpcClient.execute("Bug.search", new Object[]{bugMap});

how do i get bugs information from : "createResult" object.ie, contents of cretaeResult object.According to Bugzilla documentation two items are returned, bugs and faults, both are array of hashes. and i want to access these.

Foi útil?

Solução 2

In Case someone else needs this. Object from Bugzilla is first typecasted to a HashMap type. Each Keyset of HashMap itself is an object that contains the array of an object where in each object is again a Hashmap. Quite Complex.

HashMap bugs = (HashMap)bugzillaObject; 
for( Object key : bugs.keySet() )
{

    Object value = bugs.get( key );
    Object[] valueArray = (Object[])value;
    for( Object v : valueArray )
    {

        HashMap L = (HashMap)v;
        for( Object key1 : L.keySet() )
        System.out.println( "Key " + "= "+key1  + ", value " + "= "+ L.get(key1) );
    }
}

Outras dicas

If it returns a HashMap, then you want to make the variable "createResult" a HashMap. ie,

HashMap createResult = rpcClient.execute("Bug.search", new Object[]{bugMap});

Then "createResult" is a HashMap, and you can use it as such, eg createResult.isEmpty() createResult.size() etc

Good luck!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top