1 25 26 package org.objectweb.speedo.tutorial.pobjects.additional.detach; 27 28 31 public class AddressId { 32 33 public static final String SEP = ":"; 34 public String street; 35 public String zipCode; 36 37 public AddressId() { 38 } 39 40 public AddressId(String street, String zipCode) { 41 this.street = street; 42 this.zipCode = zipCode; 43 } 44 45 public AddressId(String str) { 46 setValue(str); 47 } 48 49 private void setValue(String str) { 50 if (str == null) { 51 throw new NullPointerException ("String representation of Address Identifier is null"); 52 } 53 int idx = str.indexOf(SEP); 54 if (idx == -1) { 55 throw new NullPointerException ("Bad String representation of Address Identifier: " + str); 56 } 57 street = str.substring(0, idx); 58 zipCode = str.substring(idx + SEP.length()); 59 } 60 61 public String toString() { 62 return street + SEP + zipCode; 63 } 64 65 } 66 | Popular Tags |