Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27497

Re: Unable to Overload toString for Object

Newsgroups comp.lang.java.programmer
Date 2014-02-13 00:59 -0800
References (3 earlier) <afa4179b-ea47-4bc4-b9d3-a3a4e7df06bf@googlegroups.com> <0163eae2-3f35-4b96-a292-87a2fe3d3b03@googlegroups.com> <ldgf0i$quu$1@dont-email.me> <95d8b98f-f57d-41b5-8b95-e9f0d13e7f2a@googlegroups.com> <ldhl8k$22q$1@dont-email.me>
Message-ID <21fd4c10-207a-4515-9308-99df55cebd60@googlegroups.com> (permalink)
Subject Re: Unable to Overload toString for Object
From Ojesh Dugar <ojesh.u@gmail.com>

Show all headers | View raw


On Thursday, February 13, 2014 10:59:50 AM UTC+5:30, markspace wrote:
> 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.

Yeah, This worked out for me.
That was a great help. Thanks a lot.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-10 22:59 -0800
  Re: Unable to Overload toString for Object leif.roar@invalid.com (Leif Roar Moldskred) - 2014-02-11 02:40 -0600
    Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-11 01:03 -0800
      Re: Unable to Overload toString for Object Lew <lewbloch@gmail.com> - 2014-02-11 15:49 -0800
        Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-12 00:38 -0800
          Re: Unable to Overload toString for Object markspace <markspace@nospam.nospam> - 2014-02-12 10:37 -0800
            Re: Unable to Overload toString for Object Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-02-12 13:57 -0500
              Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-12 20:24 -0800
                Re: Unable to Overload toString for Object Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-02-13 08:29 -0500
            Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-12 20:58 -0800
              Re: Unable to Overload toString for Object markspace <markspace@nospam.nospam> - 2014-02-12 21:29 -0800
                Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-13 00:59 -0800
  Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-11 01:06 -0800
    Re: Unable to Overload toString for Object Ojesh Dugar <ojesh.u@gmail.com> - 2014-02-11 01:27 -0800

csiph-web