01 package examples.xml.stax;
02
03 /**
04 * Data representation of an item.
05 *
06 * @author Copyright (c) 2009, Oracle and/or its affiliates. All Rights Reserved.
07 */
08 public class ItemBO
09 {
10 private String number;
11 private String description;
12 private int quantity;
13 private double price;
14
15 // constructors
16 public ItemBO() { }
17
18 public ItemBO(String pNumber,
19 String pDescription,
20 int pQuantity,
21 double pPrice)
22 {
23 this.number = pNumber;
24 this.description = pDescription;
25 this.quantity = pQuantity;
26 this.price = pPrice;
27 }
28
29 // getters
30 public String getItemNumber() { return this.number; }
31 public String getDescription() { return this.description; }
32 public int getQuantity() { return this.quantity; }
33 public double getPrice() { return this.price; }
34
35 // setters
36 public void setItemNumber(String pNumber) { this.number = pNumber; }
37 public void setDescription(String pDescription) {
38 this.description = pDescription;
39 }
40 public void setQuantity(String pQuantity) {
41 this.quantity = Integer.parseInt(pQuantity);
42 }
43 public void setPrice(String pPrice) {
44 this.price = Double.parseDouble(pPrice);
45 }
46
47 public String toString() {
48 StringBuffer str = new StringBuffer();
49 str.append("Item:");
50 str.append("\n "+getItemNumber()+" "+getDescription()+", "+
51 getQuantity()+" @ $"+getPrice()+" per");
52 return str.toString();
53 }
54
55 }
|