001: /*
002: * Enhydra Java Application Server
003: * The Initial Developer of the Original Code is Lutris Technologies Inc.
004: * Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies
005: * Inc.
006: * All Rights Reserved.
007: *
008: * The contents of this file are subject to the Enhydra Public License Version
009: * 1.0 (the "License"); you may not use this file except in compliance with the
010: * License. You may obtain a copy of the License at
011: * http://www.enhydra.org/software/license/epl.html
012: *
013: * Software distributed under the License is distributed on an "AS IS" basis,
014: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
015: * License for the specific language governing rights and limitations under the
016: * License.
017: *
018: *
019: */
020:
021: package golfShop.data.item;
022:
023: import java.util.Vector;
024: import java.util.Enumeration;
025:
026: /**
027: * Individual items for sale.
028: *
029: * @author Scott Pirie
030: * @version $Revision: 1.1 $
031: */
032: public class ItemDO implements java.io.Serializable {
033: /*----------------------------------------------------------------------*/
034: // Class Data
035: /*----------------------------------------------------------------------*/
036: private static ItemStore storage = null;
037:
038: /*----------------------------------------------------------------------*/
039: // Class Methods
040: /*----------------------------------------------------------------------*/
041:
042: /*
043: * Determine the store media selected for the category and item database
044: */
045:
046: public static void InitializeStorageOption(String opt, String dir) {
047: try {
048: if (opt.equalsIgnoreCase("memory")) {
049: storage = new ItemStoreMemory();
050: storage.initializeItemStore();
051: } else if (opt.equalsIgnoreCase("file")) {
052: storage = new ItemStoreFile();
053: storage.initializeItemStore(dir);
054: } else {
055: storage = new ItemStoreMemory();
056: storage.initializeItemStore();
057: }
058: } catch (Exception e) {
059: }
060:
061: }
062:
063: /**
064: * Constructor.
065: */
066: protected ItemDO(long objectid, String SKU, double price,
067: String name, String desc) {
068:
069: this .objectid = objectid;
070: this .SKU = SKU;
071: this .price = price;
072: this .name = name;
073: this .desc = desc;
074: }
075:
076: // TODO - delete this method
077:
078: /*
079: * Find the item with the given object id.
080: */
081: public static ItemDO getItemByObjectId(long objectId) {
082:
083: return (storage.findItemInStore(objectId));
084: }
085:
086: /*----------------------------------------------------------------------*/
087: // Instance Data
088: /*----------------------------------------------------------------------*/
089: private long objectid; // Application index
090: private String SKU; // Corporate index
091: private double price; // Item cost
092: private String name; // Human-readable
093: private String desc; // Description or location of desc
094:
095: /*----------------------------------------------------------------------*/
096: // Instance Methods
097: /*----------------------------------------------------------------------*/
098:
099: public long getObjectId() {
100: return this .objectid;
101: }
102:
103: // This is a key so it shouldn't be changed by anyone.
104: protected void setObjectId(long newId) {
105: this .objectid = newId;
106: }
107:
108: public String getSKU() {
109: return this .SKU;
110: }
111:
112: public void setSKU(String newSKU) {
113: this .SKU = newSKU;
114: }
115:
116: public double getPrice() {
117: return this .price;
118: }
119:
120: public void setPrice(double newPrice) {
121: this .price = newPrice;
122: }
123:
124: public String getName() {
125: return this .name;
126: }
127:
128: public void setName(String newName) {
129: this .desc = newName;
130: }
131:
132: public String getDescription() {
133: return this .desc;
134: }
135:
136: public void setDescription(String newDesc) {
137: this .desc = newDesc;
138: }
139:
140: /*----------------------------------------------------------------------*/
141: // Private Methods
142: /*----------------------------------------------------------------------*/
143: }
|