Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Unable to Overload toString for Object Date: Wed, 12 Feb 2014 21:29:50 -0800 Organization: A noiseless patient Spider Lines: 41 Message-ID: References: <705891c8-b170-44c0-866f-48eec7b38c4d@googlegroups.com> <1138f80c-bc7c-4edd-a91b-fb5f8e2137d6@googlegroups.com> <0163eae2-3f35-4b96-a292-87a2fe3d3b03@googlegroups.com> <95d8b98f-f57d-41b5-8b95-e9f0d13e7f2a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 13 Feb 2014 05:29:56 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="9358cda03e1e0dfd3c4b757daa608707"; logging-data="2138"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hYd3/YYazsVXHLmoioUZq2OtKJYUVEQo=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <95d8b98f-f57d-41b5-8b95-e9f0d13e7f2a@googlegroups.com> Cancel-Lock: sha1:AHxY9Cwcv0Hh4SLZ/Js40Y2BNnM= Xref: csiph.com comp.lang.java.programmer:27496 On 2/12/2014 8:58 PM, Ojesh Dugar wrote: > According to documentation, bugs- is an array of hashes that contains > information about the bugs with the valid ids. Each hash contains the > following items It sounds to me like the first property, with a key "bugs" is an array, probably of HashMap (or possibly just Map), which contains a the actual bug information. The chance that I'm going to mess something up here is increasing because I'm not compiling this, but try this. // create bug Object createResult = rpcClient.execute("Bug.search", new Object[]{bugMap}); //createResult.toString(); HashMap bugs = (HashMap)createResult; for( Object key : bugs.keySet() ) { System.out.println( "Key "+key.getClass().getName() + "= "+key + ", value "+ bugs.get( key ).getClass().getName() + "= "+ bugs.get( key ) ); Object value = bugs.get( key ); if( value instanceof Object[] ) { Object[] valueArray = (Object[])value; for( Object v : valueArray ) { System.out.println( "-- "+v.getClass().getName() ); } } else System.out.println( "not an array!" ); } You should be able to run this and determine what to replace the v.getClass().getName() part with; probably a cast to a Map. I don't recall if collections normally override their to string -- they might, though the result normally isn't very pretty.