View Javadoc
1   package info.ejava.examples.ejb.interceptor.normalizer;
2   
3   import info.ejava.examples.ejb.interceptor.bo.Contact;
4   import info.ejava.examples.ejb.interceptor.bo.PhoneInfo;
5   import info.ejava.examples.ejb.interceptor.bo.PostalAddress;
6   import info.ejava.examples.ejb.interceptor.bo.PostalInfo;
7   
8   public class ContactNormalizer extends NormalizerBase {
9       public Contact normalize(Contact contact) {
10          if (contact==null) { return null; }
11          
12          //normalize name
13          contact.setName(normalizeName(contact.getName()));
14          
15          return contact;
16      }
17      
18      public PostalAddress normalize(PostalAddress address) {
19          if (address==null) { return null; }
20          
21          address.setStreet1(normalizeName(address.getStreet1()));
22          address.setStreet2(normalizeName(address.getStreet2()));
23          address.setCity(normalizeName(address.getCity()));
24          address.setState(toUpper(address.getState()));
25          
26          //todo normalize zip code
27          return address;
28      }
29      
30      public PostalInfo normalize(PostalInfo pi) {
31          if (pi==null) { return null; }
32          normalize(pi.getAddress());
33          return pi;
34      }
35      
36      
37      public PhoneInfo normalize(PhoneInfo pi) {
38          if (pi==null) { return null; }
39          
40          //todo normalize phone#
41          
42          return pi;
43      }
44  }