KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > golfShop > data > item > ItemDO


1 /*
2  * Enhydra Java Application Server
3  * The Initial Developer of the Original Code is Lutris Technologies Inc.
4  * Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies
5  * Inc.
6  * All Rights Reserved.
7  *
8  * The contents of this file are subject to the Enhydra Public License Version
9  * 1.0 (the "License"); you may not use this file except in compliance with the
10  * License. You may obtain a copy of the License at
11  * http://www.enhydra.org/software/license/epl.html
12  *
13  * Software distributed under the License is distributed on an "AS IS" basis,
14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15  * License for the specific language governing rights and limitations under the
16  * License.
17  *
18  *
19  */

20
21 package golfShop.data.item;
22
23 import java.util.Vector JavaDoc;
24 import java.util.Enumeration JavaDoc;
25
26
27 /**
28  * Individual items for sale.
29  *
30  * @author Scott Pirie
31  * @version $Revision: 1.1 $
32  */

33 public class ItemDO implements java.io.Serializable JavaDoc
34 {
35     /*----------------------------------------------------------------------*/
36     // Class Data
37
/*----------------------------------------------------------------------*/
38     private static ItemStore storage = null;
39
40     /*----------------------------------------------------------------------*/
41     // Class Methods
42
/*----------------------------------------------------------------------*/
43
44     /*
45      * Determine the store media selected for the category and item database
46      */

47
48
49 public static void InitializeStorageOption(String JavaDoc opt,String JavaDoc dir)
50   {
51     try
52     {
53   if (opt.equalsIgnoreCase("memory"))
54        {
55         storage = new ItemStoreMemory();
56             storage.initializeItemStore();
57         }
58         else if (opt.equalsIgnoreCase("file"))
59         {
60             storage = new ItemStoreFile();
61             storage.initializeItemStore(dir);
62         }
63         else
64         {
65         storage = new ItemStoreMemory();
66             storage.initializeItemStore();
67         }
68     } catch (Exception JavaDoc e)
69     {
70     }
71     
72     
73   }
74
75
76
77
78     /**
79      * Constructor.
80      */

81     protected ItemDO(long objectid, String JavaDoc SKU, double price,
82             String JavaDoc name, String JavaDoc desc)
83     {
84
85     this.objectid = objectid;
86     this.SKU = SKU;
87     this.price = price;
88     this.name = name;
89     this.desc = desc;
90     }
91
92     // TODO - delete this method
93

94     /*
95      * Find the item with the given object id.
96      */

97     public static ItemDO getItemByObjectId(long objectId)
98     {
99
100     return(storage.findItemInStore(objectId));
101     }
102
103     /*----------------------------------------------------------------------*/
104     // Instance Data
105
/*----------------------------------------------------------------------*/
106     private long objectid ; // Application index
107
private String JavaDoc SKU ; // Corporate index
108
private double price ; // Item cost
109
private String JavaDoc name ; // Human-readable
110
private String JavaDoc desc ; // Description or location of desc
111

112     /*----------------------------------------------------------------------*/
113     // Instance Methods
114
/*----------------------------------------------------------------------*/
115
116     public long getObjectId()
117     {
118     return this.objectid;
119     }
120     // This is a key so it shouldn't be changed by anyone.
121
protected void setObjectId(long newId)
122     {
123     this.objectid = newId;
124     }
125
126     public String JavaDoc getSKU()
127     {
128     return this.SKU;
129     }
130     public void setSKU(String JavaDoc newSKU)
131     {
132     this.SKU = newSKU;
133     }
134
135     public double getPrice()
136     {
137     return this.price;
138     }
139     public void setPrice(double newPrice)
140     {
141     this.price = newPrice;
142     }
143
144     public String JavaDoc getName()
145     {
146     return this.name;
147     }
148     public void setName(String JavaDoc newName)
149     {
150     this.desc = newName;
151     }
152
153     public String JavaDoc getDescription()
154     {
155     return this.desc;
156     }
157     public void setDescription(String JavaDoc newDesc)
158     {
159     this.desc = newDesc;
160     }
161
162     /*----------------------------------------------------------------------*/
163     // Private Methods
164
/*----------------------------------------------------------------------*/
165 }
166
Popular Tags