1 /* ==================================================================== 2 * License: 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * 3. The end-user documentation included with the redistribution, 17 * if any, must include the following acknowledgment: 18 * "This product includes software developed by 19 * Robert Half International (http://www.rhi.com/)." 20 * Alternately, this acknowledgment may appear in the software itself, 21 * if and wherever such third-party acknowledgments normally appear. 22 * 23 * 4. The names "Parc", "RHI", and "Robert Half International" must 24 * not be used to endorse or promote products derived from this 25 * software without prior written permission. For written 26 * permission, please contact pete.mckinstry@rhi.com. 27 * 28 * 5. Products derived from this software may not be called "PARC", 29 * nor may "PARC" appear in their name, without prior written 30 * permission of Robert Half International. 31 * 32 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 33 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 34 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 36 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 43 * SUCH DAMAGE. 44 * ==================================================================== 45 * 46 */ 47 package com.rhi.architecture.logging; 48 49 //rhi classes 50 import com.rhi.architecture.parc.Record; 51 import com.rhi.architecture.parc.Error; 52 53 // java classes 54 import java.math.BigDecimal; 55 import java.util.ArrayList; 56 import java.util.List; 57 58 /*** 59 * Simple class for testing. 60 * 61 * @author Pete McKinstry 62 * @copyright 2002, Robert Half Int'l., Inc. All rights reserved. 63 * 64 * @since 1.0 65 */ 66 public class Book implements Record { 67 68 69 private Integer id; 70 private String title; 71 private String author; 72 private String subject; 73 private BigDecimal price; 74 75 private ArrayList errors = new ArrayList(); 76 77 78 /*** 79 * Castor requires a default constructor 80 * 81 * @since 1.0 82 */ 83 public Book() { 84 // default ctor. 85 } 86 87 88 /*** 89 * constructor 90 * @param title 91 * @param author 92 * @param subject 93 * @param price 94 */ 95 public Book( String title, String author, 96 String subject, BigDecimal price ) { 97 this.title = title; 98 this.author = author; 99 this.subject = subject; 100 this.price = price; 101 } 102 103 104 /*** 105 * Return the book id. 106 * 107 * @return the book id. 108 * 109 * @since 1.0 110 */ 111 public Object getSourceKey() { 112 return id.toString(); 113 } 114 115 /*** 116 * get id 117 * @return id 118 */ 119 public Integer getId() { 120 return id; 121 } 122 /*** 123 * set id 124 * @param id 125 */ 126 public void setId(Integer id) { 127 this.id = id; 128 } 129 130 131 /*** 132 * get title 133 * @return String title 134 */ 135 public String getTitle() { 136 return title; 137 } 138 /*** 139 * set title 140 * @param title 141 */ 142 public void setTitle(String title) { 143 this.title = title; 144 } 145 146 147 148 /*** 149 * get author 150 * @return String author 151 */ 152 public String getAuthor() { 153 return author; 154 } 155 /*** 156 * set author 157 * @param author 158 */ 159 public void setAuthor(String author) { 160 this.author = author; 161 } 162 163 164 /*** 165 * get subject 166 * @return String subject 167 */ 168 public String getSubject() { 169 return subject; 170 } 171 /*** 172 * set subject 173 * @param subject 174 */ 175 public void setSubject(String subject) { 176 this.subject = subject; 177 } 178 179 180 /*** 181 * get price 182 * @return BigDecimal 183 */ 184 public BigDecimal getPrice() { 185 return price; 186 } 187 /*** 188 * set price 189 * @param price 190 */ 191 public void setPrice(BigDecimal price) { 192 this.price = price; 193 } 194 195 196 /*** 197 * Is the Record valid. What isValid() really means, is up to 198 * the concrete record class. Normally, isValid() & isErrored() 199 * should return opposite values. 200 * 201 * @return boolean True/False 202 * 203 * @since 1.0 204 */ 205 public boolean isValid() { 206 return errors.size()==0; 207 } 208 209 /*** 210 * Is the Record in an errored state. What isErrored() 211 * really means is up to the concrete record class. Normally 212 * isValid() and isErrored() should return opposite boolean 213 * values. 214 * <br/> 215 * If isErrored() returns true, the getErrors() method should 216 * return a List w/ size() > 1. If the error list is empty, 217 * isErrored should be false. 218 * 219 * @return boolean True/False 220 * 221 * @since 1.0 222 */ 223 public boolean isErrored() { 224 return errors.size()>0; 225 } 226 227 /*** 228 * Add error to this record. 229 * 230 * @param errorMsg error msg 231 * 232 * @since 1.0 233 */ 234 public void addError( String errorMsg ) { 235 this.errors.add( errorMsg ); 236 } 237 238 /*** 239 * Return the list of errors attached to this record. 240 * Allows a cummulative process for attaching errors 241 * to the record where the first error in the list is 242 * the first error found during processing. 243 * 244 * @return List - the list of errors attached to this 245 * record. 246 * 247 * @since 1.0 248 */ 249 public List getErrors() { 250 return this.errors; 251 } 252 253 254 /*** 255 * Return a String representation of this Record. 256 * 257 * @return boolean True/False 258 * 259 * @since 1.0 260 */ 261 public String toString() { 262 StringBuffer buf = new StringBuffer(100); 263 buf.append(id).append(title).append(author); 264 buf.append(subject).append(price); 265 return buf.toString(); 266 } 267 268 /*** Add error to this record. 269 * 270 * @param error msg 271 * 272 * @since 1.0 273 */ 274 public void addError(Error error) { 275 errors.add(error); 276 } 277 278 } 279 280

This page was automatically generated by Maven