Package jestr.examples.example4

This example illustrates child filtering.


Class Summary

Package jestr.examples.example4 Description

This example illustrates child filtering. You can run it with "ant -f runexample4.xml" from the root of the distribution.

Suppose I have a class that defines an attribute I wish to be excluded from the string representation. It may be an attribute that is especially lengthy, provides redundant information, or perhaps contains sensitive information we wish to keep out of the logs. Then we can define a child filter to exclude this attribute from stringification.

In this example we introduce three attributes to the Account class that we wish to exclude:

    public class Account {
        private Balance currentBalance = new Balance(100.00, "USD", new Date());
        private Balance endingBalance = new Balance(62.44, "USD", new Date() );
        private Balance ledgerBalance = new Balance(89.75, "USD", new Date());
        private String id = "123";
        private String useless1 = "Useless attribute 1";
        private String useless2 = "Useless attribute 2";
        private String useless3 = "Useless attribute 3";

Child filtering can also be used to change the names of existing children. To illustrate this let's prefix "the" to each field name.

The "" file is shown below:


The output is as follows:

        Balance theCurrentBalance = Balance(100.0 USD as of Sat Mar 20 00:04:07 EST 2004)
        Balance theEndingBalance = Balance(62.44 USD as of Sat Mar 20 00:04:07 EST 2004)
        Balance theLedgerBalance = Balance(89.75 USD as of Sat Mar 20 00:04:07 EST 2004)
        String theId = "123"

The three attributes with the word "useless" in the name were omitted per the ".*Useless.*" regular expression, and the names have been changed as dicated by the two substitutions listed.

Copyright (c) 2001-2003 - Apache Software Foundation