|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
toString()
method.
See:
Description
Class Summary | |
Account | |
Balance | |
RunIt |
This example shows how to override an existing toString()
method.
You can run it with "ant -f runexample2.xml
" from the root of the distribution.
In this example we override the default behavior with respect to the Balance
class,
forcing the class' native toString()
method to be ignored so that the framework
can list its attributes individually. The jestr.properties
setting to do this is
jestr.category.jestr.examples.example2.Balance=tsNotPreferred,singleLine
This assigns two predefined stringifiers to the
Balance
class and its subclasses: "tsNotPreferred
", which specifies that the object's toString()
method is to be
ignored, even if one is explicitly defined, and the object's attributes listed individually instead; and "singleLine
", which specifies that the attributes are to be listed on a single line
(which results in a more compact listing since Balance
's have only a handful of attributes). The output is as follows:
Account(
Balance currentBalance = Balance[asof=Fri Mar 19 22:31:56 EST 2004|currency="USD"|amount=100]
Balance endingBalance = Balance[asof=Fri Mar 19 22:31:56 EST 2004|currency="USD"|amount=62.44]
Balance ledgerBalance = Balance[asof=Fri Mar 19 22:31:56 EST 2004|currency="USD"|amount=89.75]
String id = "123"
)
Red highlighting shows the change from the previous example. Attributes of the Balance
class are now listed individually and the class' toString()
method is not called.
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |