Re: Where and when do struts call the method named toString()?

2002-03-18 Thread dderry

Thanks for that info. I was aware that the hashcode SHOULD be unique for
each object (depends on how one overrides the method tho'). I wasn't aware
that the default implementation returned the memory address (should have
researched a little deeper!). Good to know. I guess my original assumption
was correct after all.

But I guess that still leaves your original question about how to get the
address unresolved.

Dave D


- Original Message -
From: "keithBacon" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, March 16, 2002 5:58 AM
Subject: Re: Where and when do struts call the method named toString()?


> Thanks Dave.
> The default hashCode() implementation returns the objects memory address.
> As soon as your object or one of it's parents has overridden it you've
lost it,
> but if you override hashCode (done when using hashmaps) it should still
return
> a unique value so it's fine for determining if 2 objects are the same or
not.
>
>
> --- dderry <[EMAIL PROTECTED]> wrote:
> > Just so happens that I was curious about this myself the other day. I
found
> > this in the javadocs for Object.toString():
> >
> > this method returns a string equal to the value of:
> > getClass().getName() + '@' + Integer.toHexString(hashCode())
> >
> > So it appears that you don't really get an object pointer after all (as
I
> > also thought, must be that C++ background coming through ;-}  ). Just
call
> > hashCode() when you want to get that 'object pointer'.
> >
> > Dave D
> >
> >
> > ----- Original Message -----
> > From: "keithBacon" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Thursday, March 14, 2002 1:15 PM
> > Subject: RE: Where and when do struts call the method named toString()?
> >
> >
> > > Does anyone know how to get the object pointer from inside toString so
I
> > can
> > > make my toString print:-
> > > theclass@x data: 
> > >
> >



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




Re: Where and when do struts call the method named toString()?

2002-03-16 Thread keithBacon

Thanks Dave.
The default hashCode() implementation returns the objects memory address.
As soon as your object or one of it's parents has overridden it you've lost it,
but if you override hashCode (done when using hashmaps) it should still return
a unique value so it's fine for determining if 2 objects are the same or not.
 

--- dderry <[EMAIL PROTECTED]> wrote:
> Just so happens that I was curious about this myself the other day. I found
> this in the javadocs for Object.toString():
> 
> this method returns a string equal to the value of:
> getClass().getName() + '@' + Integer.toHexString(hashCode())
> 
> So it appears that you don't really get an object pointer after all (as I
> also thought, must be that C++ background coming through ;-}  ). Just call
> hashCode() when you want to get that 'object pointer'.
> 
> Dave D
> 
> 
> - Original Message -
> From: "keithBacon" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Thursday, March 14, 2002 1:15 PM
> Subject: RE: Where and when do struts call the method named toString()?
> 
> 
> > Does anyone know how to get the object pointer from inside toString so I
> can
> > make my toString print:-
> > theclass@x data: 
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




Re: Where and when do struts call the method named toString()?

2002-03-14 Thread dderry

Just so happens that I was curious about this myself the other day. I found
this in the javadocs for Object.toString():

this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())

So it appears that you don't really get an object pointer after all (as I
also thought, must be that C++ background coming through ;-}  ). Just call
hashCode() when you want to get that 'object pointer'.

Dave D


- Original Message -
From: "keithBacon" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, March 14, 2002 1:15 PM
Subject: RE: Where and when do struts call the method named toString()?


> Does anyone know how to get the object pointer from inside toString so I
can
> make my toString print:-
> theclass@x data: 
>



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




Re: AW: Where and when do struts call the method named toString()?

2002-03-14 Thread keithBacon

I guess so - I only used it in comparators for sorting collections so think oif
it as being a value not address compare.
The lesson I learn here (apart from go do more homework!) is you really ought
to check before making assumptions about how all these things are implemented.
Also be consistent in your app.

--- Oliver_Refle <[EMAIL PROTECTED]> wrote:
> only if you have overridden the method, some classes have
> implemented this, but for your own objects you have to do that on
> you own, he is only look at the pointer
> 
> -Ursprungliche Nachricht-
> Von: keithBacon [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 14. Marz 2002 16:51
> An: Struts Users Mailing List
> Betreff: RE: Where and when do struts call the method named toString()?
> 
> 
> I stand humbled (again).
> I'd better go read some more of the language spec (& the JVM spec & the
> Servlet
> spec & J2EE patterns, & Jane Eyre & the Guardian.)
> Oh despair - there's too much...
> 
> PS isn't boolean equals( Object obj) comparing their values not their object
> pointers. if ( a == b) does that?
> 
> 
> --- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> > For once, I disagree with Keith.  :-(
> >
> > You should always override toString.  The general contract
> > in the "Java Language Specification for toString says that
> > the returned string should be "a concise but informative
> > representation that is easy for a person to read," and "it is recommended
> > that all subclasses override this method."
> >
> > To compare classes, use boolean equals( Object obj).
> >
> > Mark
> >
> > -Original Message-
> > From: keithBacon [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, March 14, 2002 4:39 AM
> > To: Struts Users Mailing List
> > Subject: Re: Where and when do struts call the method named toString()?
> >
> >
> > If you do a  > it's
> > toString() method. Same in other situations where struts expects a String.
> > It's like when you do a System.out.println() java calls toString() on the
> > object if it's not a String already.
> > The default toString inherited from Object just prints
> > classname@memoryaddress.
> > I'm a bit dubious about overriding toString() as sometimes it's good to
> see
> > the
> > memory address of objects (like trying to determine if 2 objects are the
> > same
> > or clones) so being able to use the default toString() is handy.
> > I use a print() method instead - probably my unique hang-up because it's
> > common
> > to use toString like here.
> >
> >
> >
> > --- nsg <[EMAIL PROTECTED]> wrote:
> > > Hi all,
> > > in struts-example, Subscription.java file contains the following method:
> > >
> > > /**
> > >  * Return a String representation of this object.
> > >  */
> > > public String toString() {
> > >
> > > StringBuffer sb = new StringBuffer("Subscription[username=");
> > > sb.append(username);
> > > if (host != null) {
> > > sb.append(", host=");
> > > sb.append(host);
> > > }
> > > if (user != null) {
> > > sb.append(", user=");
> > > sb.append(user.getUsername());
> > > }
> > > sb.append(", autoConnect=");
> > > sb.append(autoConnect);
> > > sb.append("]");
> > > return (sb.toString());
> > >
> > > }
> > >
> > > I  can understand the method,but where and when does struts use it?
> > >
> > >
> > > Thanks in advance
> > >
> > > Laker
> > >
> >
> >
> > =
> > ~~
> > Search the archive:-
> > http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> > ~~
> > Keith Bacon - Looking for struts work - South-East UK.
> > phone UK 07960 011275
> >
> > __
> > Do You Yahoo!?
> > Yahoo! Sports - live college hoops coverage
> > http://sports.yahoo.com/
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> > --
> > To unsubscribe, e-mail

RE: Where and when do struts call the method named toString()?

2002-03-14 Thread keithBacon

OK I'll read Joshua's book after reading the other things listed below! oh boy!
I like Bruce Eckels Thinking in Java.
Looks like I might be having to read up on Swing - oh no! Last time I used it
(on windows) it couldn't draw the screen behind the cursor properly & left bits
of menu all over the place, made my beautiful app look a mess. Hope they've
fixed all that by now! (any know this stuff or where it's discussed?).
I'll have to try to pursuade them to use struts & forms!!
=
Oh yeah I remember why I used print instead of toString - coz in collections &
big classes I had printFull & printShort debug methods.
I should have had:-

void toString() {
  print("heres a bit of the data");
  print("if you want more - call toBloodyGreatLongString");
}

void toBloodyGreatLongString() {
 etc..
}

Nothing more annoying than asking for a print or some diagnostics & getting
flooded by messages.
Does anyone know how to get the object pointer from inside toString so I can
make my toString print:-
theclass@x data: 


--- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> Not if you include a boolean value as a result of instanceof.
> Note that you don't always want to override equals() (in which
> case equals() is equivalent to ==), but when a class has a
> notion of logical equality that differs from mere object
> identity, and a superclass has not already overridden equals()
> to implement the desired behavior (like value classes such as
> Integer or Date, but not typesafe enum classes).  Check out
> pp. 25 - 35 in Joshua Bloch's "Effective Java" (one helluva
> good book!!).
> 
> Mark
> 
> P.S.  Bloch is the Chief Architect of the Java SE API.
> 
> -Original Message-
> From: keithBacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 14, 2002 10:51 AM
> To: Struts Users Mailing List
> Subject: RE: Where and when do struts call the method named toString()?
> 
> 
> I stand humbled (again).
> I'd better go read some more of the language spec (& the JVM spec & the
> Servlet
> spec & J2EE patterns, & Jane Eyre & the Guardian.)
> Oh despair - there's too much...
> 
> PS isn't boolean equals( Object obj) comparing their values not their object
> pointers. if ( a == b) does that?
> 
> 
> --- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> > For once, I disagree with Keith.  :-(
> > 
> > You should always override toString.  The general contract
> > in the "Java Language Specification for toString says that
> > the returned string should be "a concise but informative
> > representation that is easy for a person to read," and "it is recommended
> > that all subclasses override this method."
> > 
> > To compare classes, use boolean equals( Object obj).
> > 
> > Mark
> > 
> > -Original Message-
> > From: keithBacon [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, March 14, 2002 4:39 AM
> > To: Struts Users Mailing List
> > Subject: Re: Where and when do struts call the method named toString()?
> > 
> > 
> > If you do a  > it's
> > toString() method. Same in other situations where struts expects a String.
> > It's like when you do a System.out.println() java calls toString() on the
> > object if it's not a String already.
> > The default toString inherited from Object just prints
> > classname@memoryaddress.
> > I'm a bit dubious about overriding toString() as sometimes it's good to
> see
> > the
> > memory address of objects (like trying to determine if 2 objects are the
> > same
> > or clones) so being able to use the default toString() is handy.
> > I use a print() method instead - probably my unique hang-up because it's
> > common
> > to use toString like here.
> > 
> >  
> > 
> > --- nsg <[EMAIL PROTECTED]> wrote:
> > > Hi all,
> > > in struts-example, Subscription.java file contains the following method:
> > > 
> > > /**
> > >  * Return a String representation of this object.
> > >  */
> > > public String toString() {
> > > 
> > > StringBuffer sb = new StringBuffer("Subscription[username=");
> > > sb.append(username);
> > > if (host != null) {
> > > sb.append(", host=");
> > > sb.append(host);
> > > }
> > > if (user != null) {
> > > sb.appen

RE: Where and when do struts call the method named toString()?

2002-03-14 Thread Galbreath, Mark

Not if you include a boolean value as a result of instanceof.
Note that you don't always want to override equals() (in which
case equals() is equivalent to ==), but when a class has a
notion of logical equality that differs from mere object
identity, and a superclass has not already overridden equals()
to implement the desired behavior (like value classes such as
Integer or Date, but not typesafe enum classes).  Check out
pp. 25 - 35 in Joshua Bloch's "Effective Java" (one helluva
good book!!).

Mark

P.S.  Bloch is the Chief Architect of the Java SE API.

-Original Message-
From: keithBacon [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 10:51 AM
To: Struts Users Mailing List
Subject: RE: Where and when do struts call the method named toString()?


I stand humbled (again).
I'd better go read some more of the language spec (& the JVM spec & the
Servlet
spec & J2EE patterns, & Jane Eyre & the Guardian.)
Oh despair - there's too much...

PS isn't boolean equals( Object obj) comparing their values not their object
pointers. if ( a == b) does that?


--- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> For once, I disagree with Keith.  :-(
> 
> You should always override toString.  The general contract
> in the "Java Language Specification for toString says that
> the returned string should be "a concise but informative
> representation that is easy for a person to read," and "it is recommended
> that all subclasses override this method."
> 
> To compare classes, use boolean equals( Object obj).
> 
> Mark
> 
> -Original Message-
> From: keithBacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 14, 2002 4:39 AM
> To: Struts Users Mailing List
> Subject: Re: Where and when do struts call the method named toString()?
> 
> 
> If you do a  it's
> toString() method. Same in other situations where struts expects a String.
> It's like when you do a System.out.println() java calls toString() on the
> object if it's not a String already.
> The default toString inherited from Object just prints
> classname@memoryaddress.
> I'm a bit dubious about overriding toString() as sometimes it's good to
see
> the
> memory address of objects (like trying to determine if 2 objects are the
> same
> or clones) so being able to use the default toString() is handy.
> I use a print() method instead - probably my unique hang-up because it's
> common
> to use toString like here.
> 
>  
> 
> --- nsg <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > in struts-example, Subscription.java file contains the following method:
> > 
> > /**
> >  * Return a String representation of this object.
> >  */
> > public String toString() {
> > 
> > StringBuffer sb = new StringBuffer("Subscription[username=");
> > sb.append(username);
> > if (host != null) {
> > sb.append(", host=");
> > sb.append(host);
> > }
> > if (user != null) {
> > sb.append(", user=");
> > sb.append(user.getUsername());
> > }
> > sb.append(", autoConnect=");
> > sb.append(autoConnect);
> > sb.append("]");
> > return (sb.toString());
> > 
> > }
> > 
> > I  can understand the method,but where and when does struts use it?
> > 
> > 
> > Thanks in advance
> > 
> > Laker 
> > 
> 
> 
> =
> ~~
> Search the archive:-
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> ~~
> Keith Bacon - Looking for struts work - South-East UK.
> phone UK 07960 011275
> 
> __
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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

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




AW: Where and when do struts call the method named toString()?

2002-03-14 Thread Oliver Refle

only if you have overridden the method, some classes have
implemented this, but for your own objects you have to do that on
you own, he is only look at the pointer

-Ursprungliche Nachricht-
Von: keithBacon [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 14. Marz 2002 16:51
An: Struts Users Mailing List
Betreff: RE: Where and when do struts call the method named toString()?


I stand humbled (again).
I'd better go read some more of the language spec (& the JVM spec & the
Servlet
spec & J2EE patterns, & Jane Eyre & the Guardian.)
Oh despair - there's too much...

PS isn't boolean equals( Object obj) comparing their values not their object
pointers. if ( a == b) does that?


--- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> For once, I disagree with Keith.  :-(
>
> You should always override toString.  The general contract
> in the "Java Language Specification for toString says that
> the returned string should be "a concise but informative
> representation that is easy for a person to read," and "it is recommended
> that all subclasses override this method."
>
> To compare classes, use boolean equals( Object obj).
>
> Mark
>
> -Original Message-
> From: keithBacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 14, 2002 4:39 AM
> To: Struts Users Mailing List
> Subject: Re: Where and when do struts call the method named toString()?
>
>
> If you do a  it's
> toString() method. Same in other situations where struts expects a String.
> It's like when you do a System.out.println() java calls toString() on the
> object if it's not a String already.
> The default toString inherited from Object just prints
> classname@memoryaddress.
> I'm a bit dubious about overriding toString() as sometimes it's good to
see
> the
> memory address of objects (like trying to determine if 2 objects are the
> same
> or clones) so being able to use the default toString() is handy.
> I use a print() method instead - probably my unique hang-up because it's
> common
> to use toString like here.
>
>
>
> --- nsg <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > in struts-example, Subscription.java file contains the following method:
> >
> > /**
> >  * Return a String representation of this object.
> >  */
> > public String toString() {
> >
> > StringBuffer sb = new StringBuffer("Subscription[username=");
> > sb.append(username);
> > if (host != null) {
> > sb.append(", host=");
> > sb.append(host);
> > }
> > if (user != null) {
> > sb.append(", user=");
> > sb.append(user.getUsername());
> > }
> > sb.append(", autoConnect=");
> > sb.append(autoConnect);
> > sb.append("]");
> > return (sb.toString());
> >
> > }
> >
> > I  can understand the method,but where and when does struts use it?
> >
> >
> > Thanks in advance
> >
> > Laker
> >
>
>
> =
> ~~
> Search the archive:-
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> ~~
> Keith Bacon - Looking for struts work - South-East UK.
> phone UK 07960 011275
>
> __
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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


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




RE: Where and when do struts call the method named toString()?

2002-03-14 Thread keithBacon

I stand humbled (again).
I'd better go read some more of the language spec (& the JVM spec & the Servlet
spec & J2EE patterns, & Jane Eyre & the Guardian.)
Oh despair - there's too much...

PS isn't boolean equals( Object obj) comparing their values not their object
pointers. if ( a == b) does that?


--- "Galbreath, Mark" <[EMAIL PROTECTED]> wrote:
> For once, I disagree with Keith.  :-(
> 
> You should always override toString.  The general contract
> in the "Java Language Specification for toString says that
> the returned string should be "a concise but informative
> representation that is easy for a person to read," and "it is recommended
> that all subclasses override this method."
> 
> To compare classes, use boolean equals( Object obj).
> 
> Mark
> 
> -Original Message-
> From: keithBacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 14, 2002 4:39 AM
> To: Struts Users Mailing List
> Subject: Re: Where and when do struts call the method named toString()?
> 
> 
> If you do a  it's
> toString() method. Same in other situations where struts expects a String.
> It's like when you do a System.out.println() java calls toString() on the
> object if it's not a String already.
> The default toString inherited from Object just prints
> classname@memoryaddress.
> I'm a bit dubious about overriding toString() as sometimes it's good to see
> the
> memory address of objects (like trying to determine if 2 objects are the
> same
> or clones) so being able to use the default toString() is handy.
> I use a print() method instead - probably my unique hang-up because it's
> common
> to use toString like here.
> 
>  
> 
> --- nsg <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > in struts-example, Subscription.java file contains the following method:
> > 
> > /**
> >  * Return a String representation of this object.
> >  */
> > public String toString() {
> > 
> > StringBuffer sb = new StringBuffer("Subscription[username=");
> > sb.append(username);
> > if (host != null) {
> > sb.append(", host=");
> > sb.append(host);
> > }
> > if (user != null) {
> > sb.append(", user=");
> > sb.append(user.getUsername());
> > }
> > sb.append(", autoConnect=");
> > sb.append(autoConnect);
> > sb.append("]");
> > return (sb.toString());
> > 
> > }
> > 
> > I  can understand the method,but where and when does struts use it?
> > 
> > 
> > Thanks in advance
> > 
> > Laker 
> > 
> 
> 
> =
> ~~
> Search the archive:-
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> ~~
> Keith Bacon - Looking for struts work - South-East UK.
> phone UK 07960 011275
> 
> __
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




RE: Where and when do struts call the method named toString()?

2002-03-14 Thread Galbreath, Mark

For once, I disagree with Keith.  :-(

You should always override toString.  The general contract
in the "Java Language Specification for toString says that
the returned string should be "a concise but informative
representation that is easy for a person to read," and "it is recommended
that all subclasses override this method."

To compare classes, use boolean equals( Object obj).

Mark

-Original Message-
From: keithBacon [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 4:39 AM
To: Struts Users Mailing List
Subject: Re: Where and when do struts call the method named toString()?


If you do a  wrote:
> Hi all,
> in struts-example, Subscription.java file contains the following method:
> 
> /**
>  * Return a String representation of this object.
>  */
> public String toString() {
> 
> StringBuffer sb = new StringBuffer("Subscription[username=");
> sb.append(username);
> if (host != null) {
> sb.append(", host=");
> sb.append(host);
> }
> if (user != null) {
> sb.append(", user=");
> sb.append(user.getUsername());
> }
> sb.append(", autoConnect=");
> sb.append(autoConnect);
> sb.append("]");
> return (sb.toString());
> 
> }
> 
> I  can understand the method,but where and when does struts use it?
> 
> 
> Thanks in advance
> 
> Laker 
> 


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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

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




Re: Where and when do struts call the method named toString()?

2002-03-14 Thread keithBacon

If you do a  wrote:
> Hi all,
> in struts-example, Subscription.java file contains the following method:
> 
> /**
>  * Return a String representation of this object.
>  */
> public String toString() {
> 
> StringBuffer sb = new StringBuffer("Subscription[username=");
> sb.append(username);
> if (host != null) {
> sb.append(", host=");
> sb.append(host);
> }
> if (user != null) {
> sb.append(", user=");
> sb.append(user.getUsername());
> }
> sb.append(", autoConnect=");
> sb.append(autoConnect);
> sb.append("]");
> return (sb.toString());
> 
> }
> 
> I  can understand the method,but where and when does struts use it?
> 
> 
> Thanks in advance
> 
> Laker 
> 


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Where and when do struts call the method named toString()?

2002-03-13 Thread nsg
Hi all,
in struts-example, Subscription.java file contains the following method:

/**
 * Return a String representation of this object.
 */
public String toString() {

StringBuffer sb = new StringBuffer("Subscription[username=");
sb.append(username);
if (host != null) {
sb.append(", host=");
sb.append(host);
}
if (user != null) {
sb.append(", user=");
sb.append(user.getUsername());
}
sb.append(", autoConnect=");
sb.append(autoConnect);
sb.append("]");
return (sb.toString());

}

I  can understand the method,but where and when does struts use it?


Thanks in advance

Laker