001: /*
002: * Created on Nov 19, 2004
003: */
004: package org.openedit.store.customer;
005:
006: import com.openedit.users.PropertyContainer;
007:
008: /**
009: * @author dbrown
010: *
011: */
012: public class Address {
013: protected PropertyContainer fieldPropertyContainer;
014: protected String fieldPrefix;
015: public static final String ADDRESS1 = "Address1";
016: public static final String ADDRESS2 = "Address2";
017: public static final String CITY = "City";
018: public static final String STATE = "State";
019: public static final String COUNTRY = "Country";
020: public static final String ZIP = "ZipCode";
021: public static final String DESCRIPTION = "Description";
022:
023: public Address() {
024: }
025:
026: public Address(PropertyContainer inPropertyContainer) {
027: setPropertyContainer(inPropertyContainer);
028: }
029:
030: protected String getProperty(String inPropertyName) {
031: return (String) getPropertyContainer().get(
032: getPrefix() + inPropertyName);
033: }
034:
035: protected void putProperty(String inPropertyName, String inValue) {
036: getPropertyContainer().safePut(getPrefix() + inPropertyName,
037: inValue);
038: }
039:
040: public String getPrefix() {
041: if (fieldPrefix == null) {
042: fieldPrefix = "";
043: }
044: return fieldPrefix;
045: }
046:
047: public void setPrefix(String inPrefix) {
048: fieldPrefix = inPrefix;
049: }
050:
051: public String getAddress1() {
052: return getProperty(ADDRESS1);
053: }
054:
055: public void setAddress1(String inAddress1) {
056: putProperty(ADDRESS1, inAddress1);
057: }
058:
059: public String getAddress2() {
060: return getProperty(ADDRESS2);
061: }
062:
063: public void setAddress2(String inAddress2) {
064: putProperty(ADDRESS2, inAddress2);
065: }
066:
067: public String getCity() {
068: return getProperty(CITY);
069: }
070:
071: public void setCity(String inCity) {
072: putProperty(CITY, inCity);
073: }
074:
075: public String getCountry() {
076: return getProperty(COUNTRY);
077: }
078:
079: public void setCountry(String inCountry) {
080: putProperty(COUNTRY, inCountry);
081: }
082:
083: public String getState() {
084: return getProperty(STATE);
085: }
086:
087: public void setState(String inState) {
088: putProperty(STATE, inState);
089: }
090:
091: public String getZipCode() {
092: return getProperty(ZIP);
093: }
094:
095: public String get5DigitZipCode() {
096: String zip = getProperty(ZIP);
097: if (getCountry().equals("USA") && zip.length() > 5) {
098: zip = zip.substring(0, 5);
099: }
100: return zip;
101: }
102:
103: public void setZipCode(String inZipCode) {
104: putProperty(ZIP, inZipCode);
105: }
106:
107: public PropertyContainer getPropertyContainer() {
108: return fieldPropertyContainer;
109: }
110:
111: public void setPropertyContainer(
112: PropertyContainer inPropertyContainer) {
113: fieldPropertyContainer = inPropertyContainer;
114: }
115:
116: public void setCityState(String inCityState) {
117: if (inCityState != null && inCityState.indexOf(",") > -1) {
118: String[] both = inCityState.split(",");
119: setCity(both[0]);
120: setState(both[1]);
121: }
122: }
123:
124: public String getCityState() {
125: return getCity() + ", " + getState();
126: }
127:
128: public String getDescription() {
129: return getProperty(DESCRIPTION);
130: }
131:
132: public void setDescription(String inDescription) {
133: putProperty(DESCRIPTION, inDescription);
134: }
135: }
|