KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > docoriented > client > LineItem


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
2  http://developer.sun.com/berkeley_license.html
3  $Id: LineItem.java,v 1.9 2005/08/12 19:43:02 smitha Exp $ */

4
5 package com.sun.j2ee.blueprints.docoriented.client;
6
7 import org.w3c.dom.*;
8
9 public class LineItem {
10     
11     private String JavaDoc itemId;
12     private int quantity;
13     private float price;
14     
15     public LineItem() {}
16     
17     public LineItem(String JavaDoc itemId,
18             int quantity, float price) {
19         this.itemId = itemId;
20         this.quantity = quantity;
21         this.price = price;
22     }
23     
24     public String JavaDoc getItemId() {
25         return this.itemId;
26     }
27     
28     public int getQuantity() {
29         return this.quantity;
30     }
31     
32     public float getPrice() {
33         return this.price;
34     }
35     
36     public void setItemId(String JavaDoc itemId) {
37         this.itemId = itemId;
38         return;
39     }
40     
41     public void setQuantity(int quantity) {
42         this.quantity = quantity;
43         return;
44     }
45     
46     public void setPrice(float price) {
47         this.price = price;
48         return;
49     }
50     
51     public Node toDOM(Document doc) {
52         Element liElem = doc.createElement("items");
53         Element elem = doc.createElement("itemId");
54         elem.appendChild(doc.createTextNode(itemId));
55         liElem.appendChild(elem);
56         elem = doc.createElement("price");
57         elem.appendChild(doc.createTextNode(String.valueOf(price)));
58         liElem.appendChild(elem);
59         elem = doc.createElement("quantity");
60         elem.appendChild(doc.createTextNode(String.valueOf(quantity)));
61         liElem.appendChild(elem);
62         return liElem;
63     }
64 }
65
66
Popular Tags