001: /**
002: * Title: EJOSA - Enterprise Java Open Source Architecture
003: * My Piggy Bank Example
004: * Description: Business Object
005: * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
006: * Company: University of Muenster, HTWK Leipzig
007: * @author B. Lofi Dewanto, T. Menzel
008: * @version 1.2
009: */package net.sourceforge.ejosa.piggybank.business.entity;
010:
011: //import java.util.*;
012:
013: import net.sourceforge.ejosa.piggybank.business.*;
014: import net.sourceforge.ejosa.piggybank.data.coin.*;
015: import net.sourceforge.ejosa.piggybank.spec.business.*;
016: import net.sourceforge.ejosa.piggybank.spec.*;
017:
018: /**
019: * The state/value object/data transfer object class.
020: *
021: * @author B. Lofi Dewanto, T. Menzel
022: * @version 1.2
023: */
024: public class CoinImpl implements Coin {
025: // Data object
026: protected CoinDO myDO = null;
027:
028: // Primary Key
029: public String id;
030:
031: // Object state
032: public String date;
033: public String amount;
034: public String currency;
035:
036: /**
037: * Constructor.
038: */
039: public CoinImpl() throws CoinException {
040: try {
041: this .myDO = CoinDO.createVirgin();
042: } catch (Exception ex) {
043: System.out.println("Exception: " + ex);
044: //throw new CoinBusinessException("Exception in Coin():"+ ex.printStackTrace());
045: }
046: }
047:
048: /**
049: * Constructor.
050: */
051: public CoinImpl(CoinDO theCoin) throws CoinException {
052: try {
053: this .myDO = theCoin;
054: } catch (Exception ex) {
055: System.out.println("Exception: " + ex);
056: //throw new CoinException("Exception in Coin(CoinDO):"+ ex.printStackTrace());
057: }
058: }
059:
060: /**
061: * Constructor.
062: */
063: public CoinImpl(String id) throws CoinException {
064: try {
065: this .id = id;
066: } catch (Exception ex) {
067: System.out.println("Exception: " + ex);
068: //throw new CoinException("Exception in Coin(String):"+ ex.printStackTrace());
069: }
070: }
071:
072: public String getHandle() throws CoinException {
073: try {
074: return this .myDO.getHandle();
075: } catch (Exception ex) {
076: System.out.println("Exception: " + ex);
077: //throw new CoinException("Exception in getHandle():"+ ex.printStackTrace());
078: return null;
079: }
080: }
081:
082: /**
083: * Gets the Id of the coin.
084: *
085: * @return the Id of the coin.
086: * @exception CoinException.
087: */
088: public String getId() throws CoinException {
089: try {
090: id = myDO.getID();
091: return id;
092: } catch (Exception ex) {
093: System.out.println("Exception: " + ex);
094: //throw new CoinException("Exception in getId():"+ ex.printStackTrace());
095: return null;
096: }
097: }
098:
099: /**
100: * Sets the Id of the coin.
101: *
102: * @param the Id to be changed.
103: * @exception CoinException.
104: */
105: public void setId(String id) throws CoinException {
106: try {
107: this .id = id;
108: this .myDO.setID(id);
109: } catch (Exception ex) {
110: System.out.println("Exception: " + ex);
111: //throw new CoinException("Exception in setId(String):"+ ex.printStackTrace());
112: }
113: }
114:
115: /**
116: * Gets the date of insertion.
117: *
118: * @return the date of insertion.
119: * @exception CoinException.
120: */
121: public String getDate() throws CoinException {
122: try {
123: date = myDO.getDATE();
124: return date;
125: } catch (Exception ex) {
126: System.out.println("Exception: " + ex);
127: //throw new CoinException("Exception in getDate():"+ ex.printStackTrace());
128: return null;
129: }
130: }
131:
132: /**
133: * Sets the date of insertion.
134: *
135: * @param the date to be changed.
136: * @exception CoinException.
137: */
138: public void setDate(String inputDate) throws CoinException {
139: try {
140: date = inputDate;
141: this .myDO.setDATE(inputDate);
142: } catch (Exception ex) {
143: System.out.println("Exception: " + ex);
144: //throw new CoinException("Exception in setDate(String):"+ ex.printStackTrace());
145: }
146: }
147:
148: /**
149: * Gets the amount of the coin.
150: *
151: * @return the amount of the coin.
152: * @exception CoinException.
153: */
154: public String getAmount() throws CoinException {
155: try {
156: amount = myDO.getAMOUNT();
157: return amount;
158: } catch (Exception ex) {
159: System.out.println("Exception: " + ex);
160: //throw new CoinException("Exception in getAmount():"+ ex.printStackTrace());
161: return null;
162: }
163: }
164:
165: /**
166: * Sets the amount of the coin.
167: *
168: * @param the amount to be changed.
169: * @exception CoinException.
170: */
171: public void setAmount(String amount) throws CoinException {
172: try {
173: this .amount = amount;
174: this .myDO.setAMOUNT(amount);
175: } catch (Exception ex) {
176: System.out.println("Exception: " + ex);
177: //throw new CoinException("Exception in setAmount(String):"+ ex.printStackTrace());
178: }
179: }
180:
181: /**
182: * Gets the currency of the coin.
183: *
184: * @return the currency of the coin.
185: * @exception CoinException.
186: */
187: public String getCurrency() throws CoinException {
188: try {
189: currency = myDO.getCURENCY();
190: return currency;
191: } catch (Exception ex) {
192: System.out.println("Exception: " + ex);
193: //throw new CoinException("Exception in getCurrency():"+ ex.printStackTrace());
194: return null;
195: }
196: }
197:
198: /**
199: * Sets the currency of the coin.
200: *
201: * @param the currency to be changed.
202: * @exception CoinException.
203: */
204: public void setCurrency(String currency) throws CoinException {
205: try {
206: this .currency = currency;
207: this .myDO.setCURENCY(currency);
208: } catch (Exception ex) {
209: System.out.println("Exception: " + ex);
210: //throw new CoinException("Exception in setCurrency(String):"+ ex.printStackTrace());
211: }
212: }
213:
214: /**
215: * Commits all changes to the database.
216: *
217: * @exception CoinException if an error occurs
218: * retrieving data (usually due to an underlying data layer
219: * error).
220: */
221: public void save() throws CoinException {
222: try {
223: this .myDO.commit();
224: } catch (Exception ex) {
225: System.out.println("Exception: " + ex);
226: //throw new CoinException("Exception in save():"+ ex.printStackTrace());
227: }
228: }
229:
230: /**
231: * Deletes the disc from the database.
232: *
233: * @exception CoinException if an error occurs
234: * deleting data (usually due to an underlying data layer
235: * error).
236: */
237: public void delete() throws CoinException {
238: try {
239: this .myDO.delete();
240: } catch (Exception ex) {
241: System.out.println("Exception: " + ex);
242: //throw new CoinException("Exception in delete():"+ ex.printStackTrace());
243: }
244: }
245: }
|