On 4/19/07, ben short <[EMAIL PROTECTED]> wrote:

Hi Gary,

I was using version 2.2 but have tried it again with version 2.3. Same
result.
I also tried the following code.

ToStringBuilder.reflectionToString(request)

But that produces the same output.

Interestingly if i do the same but with one of my domain object,
instead of the HttpServletRequest I see an expected result.

Looking at the javadoc it states..

[SNIP]
Alternatively, there is a method that uses reflection to determine the
fields to test. Because these fields are usually private, the method,
reflectionToString, uses AccessibleObject.setAccessible to change the
visibility of the fields. This will fail under a security manager,
unless the appropriate permissions are set up correctly. It is also
slower than testing explicitly.
[SNIP]

I wonder if this has anything todo with it?

Regards

Ben

On 4/19/07, Gary Gregory <[EMAIL PROTECTED]> wrote:
> Hello Ben:
>
> It should be possible indeed. This is the kind of thing with which this
builder was designed and tested. Make sure you are using the current version
of lang (2.3). Does it happen if you use the single arg method?
>
> If you take a peek at the unit tests you'll see that the class is tested
to output fields from nested objects to any depth. So I really wonder what
is going on.
>
> You could also write a test case with no external dependencies if you
need to file a JIRA ticket.
>
> Thank you,
> Gary
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of ben
> > short
> > Sent: Wednesday, April 18, 2007 8:11 AM
> > To: commons-user@jakarta.apache.org
> > Subject: [Lang] ToStringBuilder Question
> >
> > Hi,
> >
> > Im trying to use the ToStringBuilder as follows,
> >
> > ToStringBuilder.reflectionToString(request,
ToStringStyle.MULTI_LINE_STYLE)
> >
> > the output I get is....
> >
> > [EMAIL PROTECTED]
> >   [EMAIL PROTECTED]
> > ]
> >
> >
> > I was hoping that the output would be more verbose and output all of
> > the request properties.
> >
> > Is this possible?
> >
> > Regards
> >
> > Ben
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


I *think* this is expected behavior.  ToStringBuilder.reflectionToString(
Object ) is not recursive; it uses reflection on the supplied Object only.
Primitives values are printed as-is, while Object values are determined by
calling Object.toString().

So, org.apache.catalina.connector.RequestFacade class does not implement
toString() so reflection is used to determine it has a single member
variable named "request" (which appears in your output).  That member
variable is an Object, so toString() is called to determine it's value;
unfortunately, org.apache.catalina.connector.Request does not implement
toString() either.  Meaning, I think the output you are seeing is correct.

--
Jamie Bisotti

Reply via email to