commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <ggreg...@seagullsw.com>
Subject RE: [lang] ToStringBuilder.reflectionToString() and statics.
Date Thu, 23 Oct 2003 22:34:44 GMT
Hello,

I've CVS'd support for static field output in ReflectionToStringBuilder. 

A code review would be greatly appreciated, especially in how the feature is
surfaced at the API level.

The main points are: 

(1) 
Deprecate in ReflectionToStringBuilder:

public static String toString(Object object, ToStringStyle style, boolean
outputTransients, boolean outputStatics)

In favor of:

public static String toString(Object object, ToStringStyle style, boolean
outputTransients, boolean outputStatics, Class reflectUpToClass)

(2) New convenience methods ReflectionToStringBuilder.toStringWithStatics.


The main problem I need to solve is based on this example:

ReflectionToStringBuilder.toStringWithStatics(new MQEnvironment(),
MQEnvironment.class);

This gives me a toString value without the java.lang.Object statics, which
is exactly what I need.

Ideally I would have liked not to instantiate the target object, but it
seems that Java's lack of a proper metadata model rears its ugly head here
again. Unless I've missed something, which is quite possible of course.

Doing this:

ReflectionToStringBuilder.toStringWithStatics(MQEnvironment.class
MQEnvironment.class);

Will dump out the contents of the java.lang.Class object and so does not do
the same as the first example. It seems that you cannot get to the static
side info from a java.lang.Class but only from an instance. Not very OO, oh
well.

Thanks for reading this far!
Gary


> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Wednesday, October 22, 2003 16:51
> To: Jakarta Commons Developers List
> Subject: Re: [lang] ToStringBuilder.reflectionToString() and statics.
> 
> OK, lets hope we don't get too many boolean flags...
> Stephen
> 
> ----- Original Message -----
> From: "Gary Gregory" <ggregory@seagullsw.com>
> To: "'Jakarta Commons Developers List'" <commons-dev@jakarta.apache.org>
> Sent: Thursday, October 23, 2003 12:35 AM
> Subject: RE: [lang] ToStringBuilder.reflectionToString() and statics.
> 
> 
> > +1 ReflectionToStringBuilder but I am not fond of a
> toStringWithStatics()
> > since we already have options like transient output in a boolean
> parameter
> > and not method names. I should be able to ask ReflectionToStringBuilder
> for
> > transients AND statics.
> >
> > Gary
> >
> > > -----Original Message-----
> > > From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> > > Sent: Wednesday, October 22, 2003 16:35
> > > To: Jakarta Commons Developers List
> > > Subject: Re: [lang] ToStringBuilder.reflectionToString() and statics.
> > >
> > > Perhaps just on the ReflectionToStringBuilder?
> > >
> > > Or maybe have a diferent method name - toStringWithStatics()
> > >
> > > Stephen
> > >
> > > ----- Original Message -----
> > > From: "Gary Gregory" <ggregory@seagullsw.com>
> > > > Hello,
> > > >
> > > > I have a case where I am working with an IBM class which holds
> values
> on
> > > the
> > > > static side only. So I would like to be able to see these statics
> like
> > > so:
> > > >
> > > > ToStringBuilder.reflectionToString(MQEnvironment.class)
> > > >
> > > > or
> > > >
> > > > ReflectionToStringBuilder.toString(MQEnvironment.class)
> > > >
> > > > My question is:
> > > >
> > > > Does anyone object to having a boolean parameter to show statics
> > > (default
> > > > false) like we have now for transients?
> > > >
> > > > Thanks,
> > > > Gary
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message