View Javadoc
1 /* 2 * $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java,v 1.10 2002/05/17 15:24:10 jstrachan Exp $ 3 * $Revision: 1.10 $ 4 * $Date: 2002/05/17 15:24:10 $ 5 * 6 * ==================================================================== 7 * 8 * The Apache Software License, Version 1.1 9 * 10 * Copyright (c) 1999-2002 The Apache Software Foundation. All rights 11 * reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in 22 * the documentation and/or other materials provided with the 23 * distribution. 24 * 25 * 3. The end-user documentation included with the redistribution, if 26 * any, must include the following acknowlegement: 27 * "This product includes software developed by the 28 * Apache Software Foundation (http://www.apache.org/)." 29 * Alternately, this acknowlegement may appear in the software itself, 30 * if and wherever such third-party acknowlegements normally appear. 31 * 32 * 4. The names "The Jakarta Project", "Commons", and "Apache Software 33 * Foundation" must not be used to endorse or promote products derived 34 * from this software without prior written permission. For written 35 * permission, please contact apache@apache.org. 36 * 37 * 5. Products derived from this software may not be called "Apache" 38 * nor may "Apache" appear in their names without prior written 39 * permission of the Apache Group. 40 * 41 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 42 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 45 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 47 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 49 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 50 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 51 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 * SUCH DAMAGE. 53 * ==================================================================== 54 * 55 * This software consists of voluntary contributions made by many 56 * individuals on behalf of the Apache Software Foundation. For more 57 * information on the Apache Software Foundation, please see 58 * <http://www.apache.org/>;. 59 * 60 * $Id: CustomerBean.java,v 1.10 2002/05/17 15:24:10 jstrachan Exp $ 61 */ 62 package org.apache.commons.betwixt; 63 64 import java.io.Serializable; 65 import java.math.BigDecimal; 66 import java.math.BigInteger; 67 import java.sql.Date; 68 import java.sql.Time; 69 import java.sql.Timestamp; 70 import java.util.ArrayList; 71 import java.util.ArrayList; 72 import java.util.Enumeration; 73 import java.util.Iterator; 74 import java.util.List; 75 import java.util.Map; 76 77 import org.apache.commons.collections.iterators.IteratorEnumeration; 78 79 import org.apache.commons.logging.Log; 80 import org.apache.commons.logging.LogFactory; 81 82 /*** <p><code>CustomerBean</code> is a sample bean for use by the test cases.</p> 83 * 84 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 85 * @author <a href="mailto:michael.davey@coderage.org">Michael Davey</a> 86 * @version $Revision: 1.10 $ 87 */ 88 public class CustomerBean implements Serializable { 89 90 /*** Logger */ 91 private static final Log log = LogFactory.getLog( CustomerBean.class ); 92 93 private String id; 94 private String name; 95 private String nickName; 96 private String[] emails; 97 private int[] numbers; 98 private AddressBean address; 99 private Map projectMap; 100 private List locations = new ArrayList(); 101 private Date date; 102 private Time time; 103 private Timestamp timestamp; 104 private BigDecimal bigDecimal; 105 private BigInteger bigInteger; 106 107 public CustomerBean() { 108 } 109 110 public String getID() { 111 return id; 112 } 113 114 public String getNickName() { 115 return nickName; 116 } 117 118 119 public String getName() { 120 return name; 121 } 122 123 public String[] getEmails() { 124 return emails; 125 } 126 127 public int[] getNumbers() { 128 return numbers; 129 } 130 131 public AddressBean getAddress() { 132 return address; 133 } 134 135 public Map getProjectMap() { 136 return projectMap; 137 } 138 139 public Iterator getProjectNames() { 140 if ( projectMap == null ) { 141 return null; 142 } 143 return projectMap.keySet().iterator(); 144 } 145 146 public Enumeration getProjectURLs() { 147 if ( projectMap == null ) { 148 return null; 149 } 150 return new IteratorEnumeration( projectMap.values().iterator() ); 151 } 152 153 public List getLocations() { 154 return locations; 155 } 156 157 /*** An indexed property */ 158 public String getLocation(int index) { 159 return (String) locations.get(index); 160 } 161 162 public void setID(String id) { 163 this.id = id; 164 } 165 166 public void setName(String name) { 167 this.name = name; 168 } 169 170 public void setNickName(String nickName) { 171 this.nickName = nickName; 172 } 173 174 public void setEmails(String[] emails) { 175 this.emails = emails; 176 } 177 178 public void addEmail(String email) { 179 int newLength = (emails == null) ? 1 : emails.length+1; 180 String[] newArray = new String[newLength]; 181 for (int i=0; i< newLength-1; i++) { 182 newArray[i] = emails[i]; 183 } 184 newArray[newLength-1] = email; 185 emails = newArray; 186 } 187 188 public void setNumbers(int[] numbers) { 189 this.numbers = numbers; 190 } 191 192 public void addNumber(int number) { 193 System.out.println( "Adding number: " + number ); 194 195 int newLength = (numbers == null) ? 1 : numbers.length+1; 196 int[] newArray = new int[newLength]; 197 for (int i=0; i< newLength-1; i++) { 198 newArray[i] = numbers[i]; 199 } 200 newArray[newLength-1] = number; 201 numbers = newArray; 202 } 203 204 public void setAddress(AddressBean address) { 205 this.address = address; 206 207 if ( log.isDebugEnabled() ) { 208 log.debug( "Setting the address to be: " + address ); 209 } 210 } 211 212 public void setProjectMap(Map projectMap) { 213 this.projectMap = projectMap; 214 } 215 216 public void addLocation(String location) { 217 locations.add(location); 218 } 219 220 /*** An indexed property */ 221 public void setLocation(int index, String location) { 222 if ( index == locations.size() ) { 223 locations.add( location ); 224 } 225 else { 226 locations.set(index, location); 227 } 228 } 229 230 public String toString() { 231 return "[" + this.getClass().getName() + ": ID=" + id + ", name=" + name 232 + ", address=" + address + "]"; 233 } 234 235 public boolean equals( Object obj ) { 236 if ( obj == null ) return false; 237 return this.hashCode() == obj.hashCode(); 238 } 239 240 public int hashCode() { 241 return toString().hashCode(); 242 } 243 /*** 244 * Returns the date. 245 * @return Date 246 */ 247 public Date getDate() { 248 return date; 249 } 250 251 /*** 252 * Returns the time. 253 * @return Time 254 */ 255 public Time getTime() { 256 return time; 257 } 258 259 /*** 260 * Returns the timestamp. 261 * @return Timestamp 262 */ 263 public Timestamp getTimestamp() { 264 return timestamp; 265 } 266 267 /*** 268 * Sets the date. 269 * @param date The date to set 270 */ 271 public void setDate(Date date) { 272 this.date = date; 273 } 274 275 /*** 276 * Sets the time. 277 * @param time The time to set 278 */ 279 public void setTime(Time time) { 280 this.time = time; 281 } 282 283 /*** 284 * Sets the timestamp. 285 * @param timestamp The timestamp to set 286 */ 287 public void setTimestamp(Timestamp timestamp) { 288 this.timestamp = timestamp; 289 } 290 291 /*** 292 * Returns the bigDecimal. 293 * @return BigDecimal 294 */ 295 public BigDecimal getBigDecimal() { 296 return bigDecimal; 297 } 298 299 /*** 300 * Returns the bigInteger. 301 * @return BigInteger 302 */ 303 public BigInteger getBigInteger() { 304 return bigInteger; 305 } 306 307 /*** 308 * Sets the bigDecimal. 309 * @param bigDecimal The bigDecimal to set 310 */ 311 public void setBigDecimal(BigDecimal bigDecimal) { 312 this.bigDecimal = bigDecimal; 313 } 314 315 /*** 316 * Sets the bigInteger. 317 * @param bigInteger The bigInteger to set 318 */ 319 public void setBigInteger(BigInteger bigInteger) { 320 this.bigInteger = bigInteger; 321 } 322 323 }

This page was automatically generated by Maven