1 4 package com.openedit.store.customer; 5 6 import com.openedit.users.PropertyContainer; 7 8 12 public class Address 13 { 14 protected PropertyContainer fieldPropertyContainer; 15 protected String fieldPrefix; 16 public static final String ADDRESS1 = "Address1"; 17 public static final String ADDRESS2 = "Address2"; 18 public static final String CITY = "City"; 19 public static final String STATE = "State"; 20 public static final String COUNTRY = "Country"; 21 public static final String ZIP = "ZipCode"; 22 23 public Address() 24 { 25 } 26 27 public Address(PropertyContainer inPropertyContainer) 28 { 29 setPropertyContainer(inPropertyContainer); 30 } 31 32 protected String getProperty(String inPropertyName) 33 { 34 return (String )getPropertyContainer().get(getPrefix() + inPropertyName); 35 } 36 37 protected void putProperty(String inPropertyName, String inValue) 38 { 39 getPropertyContainer().safePut(getPrefix() + inPropertyName, inValue); 40 } 41 42 public String getPrefix() 43 { 44 if ( fieldPrefix == null ) 45 { 46 fieldPrefix = ""; 47 } 48 return fieldPrefix; 49 } 50 public void setPrefix(String inPrefix) 51 { 52 fieldPrefix = inPrefix; 53 } 54 55 public String getAddress1() 56 { 57 return getProperty(ADDRESS1); 58 } 59 public void setAddress1(String inAddress1) 60 { 61 putProperty(ADDRESS1, inAddress1); 62 } 63 public String getAddress2() 64 { 65 return getProperty(ADDRESS2); 66 } 67 public void setAddress2(String inAddress2) 68 { 69 putProperty(ADDRESS2, inAddress2); 70 } 71 public String getCity() 72 { 73 return getProperty(CITY); 74 } 75 public void setCity(String inCity) 76 { 77 putProperty(CITY, inCity); 78 } 79 public String getCountry() 80 { 81 return getProperty(COUNTRY); 82 } 83 public void setCountry(String inCountry) 84 { 85 putProperty(COUNTRY, inCountry); 86 } 87 public String getState() 88 { 89 return getProperty(STATE); 90 } 91 public void setState(String inState) 92 { 93 putProperty(STATE, inState); 94 } 95 public String getZipCode() 96 { 97 return getProperty(ZIP); 98 } 99 public String get5DigitZipCode() 100 { 101 String zip = getProperty(ZIP); 102 if (getCountry().equals("USA") && zip.length() > 5) 103 { 104 zip = zip.substring(0,5); 105 } 106 return zip; 107 } 108 109 public void setZipCode(String inZipCode) 110 { 111 putProperty(ZIP, inZipCode); 112 } 113 114 public PropertyContainer getPropertyContainer() 115 { 116 return fieldPropertyContainer; 117 } 118 public void setPropertyContainer(PropertyContainer inPropertyContainer) 119 { 120 fieldPropertyContainer = inPropertyContainer; 121 } 122 123 public void setCityState( String inCityState ) 124 { 125 if ( inCityState != null && inCityState.indexOf(",") > -1) 126 { 127 String [] both = inCityState.split(","); 128 setCity(both[0]); 129 setState(both[1]); 130 } 131 } 132 public String getCityState() 133 { 134 return getCity() + ", " + getState(); 135 } 136 } 137 | Popular Tags |