001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    /*
017     * Created on Mar 7, 2006
018     *
019     */
020    package org.kuali.kfs.module.purap.businessobject;
021    
022    import java.util.ArrayList;
023    import java.util.List;
024    
025    import org.apache.commons.lang.builder.ToStringBuilder;
026    
027    public class ElectronicInvoicePostalAddress {
028      // no deliverTo attributes currently
029      private String type;
030      private String line1 = "";
031      private String line2 = "";
032      private String line3 = "";
033      private String cityName;
034      private String stateCode;
035      private String postalCode;
036      private String countryCode;
037      private String countryName;
038      
039      private List names = new ArrayList();
040      
041      private List<String> street = new ArrayList<String>();
042      
043      public ElectronicInvoicePostalAddress() {
044        super();
045      }
046      
047      public void addName(String name) {
048        this.names.add(name);
049      }
050      
051      /**
052       * @return first name found in names list
053       */
054      public String getName() {
055        if (names.isEmpty()) {
056          return "";
057        } else {
058          return (String)names.get(0);
059        }
060      }
061      /**
062       * @return Returns the cityName.
063       */
064      public String getCityName() {
065        return cityName;
066      }
067      /**
068       * @param cityName The cityName to set.
069       */
070      public void setCityName(String cityName) {
071        this.cityName = cityName;
072      }
073      /**
074       * @return Returns the countryCode.
075       */
076      public String getCountryCode() {
077        return countryCode;
078      }
079      /**
080       * @param countryCode The countryCode to set.
081       */
082      public void setCountryCode(String countryCode) {
083        this.countryCode = countryCode;
084      }
085      /**
086       * @return Returns the countryName.
087       */
088      public String getCountryName() {
089        return countryName;
090      }
091      /**
092       * @param countryName The countryName to set.
093       */
094      public void setCountryName(String countryName) {
095        this.countryName = countryName;
096      }
097      /**
098       * @return Returns the line1.
099       */
100      public String getLine1() {
101    //    return line1;
102          if (street.size() > 0){
103              return street.get(0);
104          }else{
105              return null;
106          }
107      }
108      /**
109       * @param line1 The line1 to set.
110       */
111      public void setLine1(String line1) {
112        this.line1 = line1;
113      }
114      /**
115       * @return Returns the line2.
116       */
117      public String getLine2() {
118    //    return line2;
119          if (street.size() > 1){
120              return street.get(1);
121          }else{
122              return null;
123          }
124      }
125      /**
126       * @param line2 The line2 to set.
127       */
128      public void setLine2(String line2) {
129        this.line2 = line2;
130      }
131      /**
132       * @return Returns the line3.
133       */
134      public String getLine3() {
135    //    return line3;
136          if (street.size() > 2){
137              return street.get(2);
138          }else{
139              return null;
140          }
141      }
142      /**
143       * @param line3 The line3 to set.
144       */
145      public void setLine3(String line3) {
146        this.line3 = line3;
147      }
148      /**
149       * @return Returns the names.
150       */
151      public List getNames() {
152        return names;
153      }
154      /**
155       * @param names The names to set.
156       */
157      public void setNames(List names) {
158        this.names = names;
159      }
160      /**
161       * @return Returns the postalCode.
162       */
163      public String getPostalCode() {
164        return postalCode;
165      }
166      /**
167       * @param postalCode The postalCode to set.
168       */
169      public void setPostalCode(String postalCode) {
170        this.postalCode = postalCode;
171      }
172      /**
173       * @return Returns the stateCode.
174       */
175      public String getStateCode() {
176        return stateCode;
177      }
178      /**
179       * @param stateCode The stateCode to set.
180       */
181      public void setStateCode(String stateCode) {
182        this.stateCode = stateCode;
183      }
184      /**
185       * @return Returns the type.
186       */
187      public String getType() {
188        return type;
189      }
190      /**
191       * @param type The type to set.
192       */
193      public void setType(String type) {
194        this.type = type;
195      }
196      
197      public void addStreet(String street){
198          this.street.add(street);
199      }
200      
201      public String toString(){
202          
203          ToStringBuilder toString = new ToStringBuilder(this);
204          
205          toString.append("type",getType());
206          toString.append("line1",getLine1());
207          toString.append("line2",getLine2());
208          toString.append("line3",getLine3());
209          toString.append("cityName",getCityName());
210          toString.append("stateCode",getStateCode());
211          toString.append("postalCode",getPostalCode());
212          toString.append("countryCode",getCountryCode());
213          toString.append("countryName",getCountryName());
214          toString.append("Names(DeliverTo)",getNames());
215          
216          return toString.toString();
217      }
218    }