KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejosa > piggybank > business > entity > CoinImpl


1 /**
2  * Title: EJOSA - Enterprise Java Open Source Architecture
3  * My Piggy Bank Example
4  * Description: Business Object
5  * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
6  * Company: University of Muenster, HTWK Leipzig
7  * @author B. Lofi Dewanto, T. Menzel
8  * @version 1.2
9  */

10 package net.sourceforge.ejosa.piggybank.business.entity;
11
12 //import java.util.*;
13

14 import net.sourceforge.ejosa.piggybank.business.*;
15 import net.sourceforge.ejosa.piggybank.data.coin.*;
16 import net.sourceforge.ejosa.piggybank.spec.business.*;
17 import net.sourceforge.ejosa.piggybank.spec.*;
18
19
20 /**
21  * The state/value object/data transfer object class.
22  *
23  * @author B. Lofi Dewanto, T. Menzel
24  * @version 1.2
25  */

26 public class CoinImpl implements Coin {
27     // Data object
28
protected CoinDO myDO = null;
29     
30     // Primary Key
31
public String JavaDoc id;
32
33     // Object state
34
public String JavaDoc date;
35     public String JavaDoc amount;
36     public String JavaDoc currency;
37
38     /**
39      * Constructor.
40      */

41     public CoinImpl() throws CoinException {
42         try {
43           this.myDO = CoinDO.createVirgin();
44         } catch (Exception JavaDoc ex) {
45             System.out.println("Exception: " + ex);
46             //throw new CoinBusinessException("Exception in Coin():"+ ex.printStackTrace());
47
}
48     }
49     
50     /**
51      * Constructor.
52      */

53     public CoinImpl(CoinDO theCoin) throws CoinException {
54         try {
55           this.myDO = theCoin;
56         } catch (Exception JavaDoc ex) {
57             System.out.println("Exception: " + ex);
58             //throw new CoinException("Exception in Coin(CoinDO):"+ ex.printStackTrace());
59
}
60     }
61     
62     /**
63      * Constructor.
64      */

65     public CoinImpl(String JavaDoc id) throws CoinException {
66         try {
67           this.id = id;
68         } catch (Exception JavaDoc ex) {
69             System.out.println("Exception: " + ex);
70             //throw new CoinException("Exception in Coin(String):"+ ex.printStackTrace());
71
}
72     }
73     
74     public String JavaDoc getHandle() throws CoinException {
75         try {
76           return this.myDO.getHandle();
77         } catch (Exception JavaDoc ex) {
78             System.out.println("Exception: " + ex);
79             //throw new CoinException("Exception in getHandle():"+ ex.printStackTrace());
80
return null;
81         }
82     }
83
84     /**
85      * Gets the Id of the coin.
86      *
87      * @return the Id of the coin.
88      * @exception CoinException.
89      */

90     public String JavaDoc getId() throws CoinException {
91         try {
92           id = myDO.getID();
93           return id;
94         } catch (Exception JavaDoc ex) {
95             System.out.println("Exception: " + ex);
96             //throw new CoinException("Exception in getId():"+ ex.printStackTrace());
97
return null;
98         }
99     }
100
101     /**
102      * Sets the Id of the coin.
103      *
104      * @param the Id to be changed.
105      * @exception CoinException.
106      */

107     public void setId(String JavaDoc id) throws CoinException {
108         try {
109           this.id = id;
110           this.myDO.setID(id);
111         } catch (Exception JavaDoc ex) {
112             System.out.println("Exception: " + ex);
113             //throw new CoinException("Exception in setId(String):"+ ex.printStackTrace());
114
}
115     }
116
117     /**
118      * Gets the date of insertion.
119      *
120      * @return the date of insertion.
121      * @exception CoinException.
122      */

123     public String JavaDoc getDate() throws CoinException {
124         try {
125           date = myDO.getDATE();
126           return date;
127         } catch (Exception JavaDoc ex) {
128             System.out.println("Exception: " + ex);
129             //throw new CoinException("Exception in getDate():"+ ex.printStackTrace());
130
return null;
131         }
132     }
133
134     /**
135      * Sets the date of insertion.
136      *
137      * @param the date to be changed.
138      * @exception CoinException.
139      */

140     public void setDate(String JavaDoc inputDate) throws CoinException {
141         try {
142           date = inputDate;
143           this.myDO.setDATE(inputDate);
144         } catch (Exception JavaDoc ex) {
145             System.out.println("Exception: " + ex);
146             //throw new CoinException("Exception in setDate(String):"+ ex.printStackTrace());
147
}
148     }
149
150     /**
151      * Gets the amount of the coin.
152      *
153      * @return the amount of the coin.
154      * @exception CoinException.
155      */

156     public String JavaDoc getAmount() throws CoinException {
157         try {
158           amount = myDO.getAMOUNT();
159           return amount;
160         } catch (Exception JavaDoc ex) {
161             System.out.println("Exception: " + ex);
162             //throw new CoinException("Exception in getAmount():"+ ex.printStackTrace());
163
return null;
164         }
165     }
166
167     /**
168      * Sets the amount of the coin.
169      *
170      * @param the amount to be changed.
171      * @exception CoinException.
172      */

173     public void setAmount(String JavaDoc amount) throws CoinException {
174         try {
175           this.amount = amount;
176           this.myDO.setAMOUNT(amount);
177         } catch (Exception JavaDoc ex) {
178             System.out.println("Exception: " + ex);
179             //throw new CoinException("Exception in setAmount(String):"+ ex.printStackTrace());
180
}
181     }
182
183     /**
184      * Gets the currency of the coin.
185      *
186      * @return the currency of the coin.
187      * @exception CoinException.
188      */

189     public String JavaDoc getCurrency() throws CoinException {
190         try {
191           currency = myDO.getCURENCY();
192           return currency;
193         } catch (Exception JavaDoc ex) {
194             System.out.println("Exception: " + ex);
195             //throw new CoinException("Exception in getCurrency():"+ ex.printStackTrace());
196
return null;
197         }
198     }
199
200     /**
201      * Sets the currency of the coin.
202      *
203      * @param the currency to be changed.
204      * @exception CoinException.
205      */

206     public void setCurrency(String JavaDoc currency) throws CoinException {
207         try {
208           this.currency = currency;
209           this.myDO.setCURENCY(currency);
210         } catch (Exception JavaDoc ex) {
211             System.out.println("Exception: " + ex);
212             //throw new CoinException("Exception in setCurrency(String):"+ ex.printStackTrace());
213
}
214     }
215     
216     /**
217      * Commits all changes to the database.
218      *
219      * @exception CoinException if an error occurs
220      * retrieving data (usually due to an underlying data layer
221      * error).
222      */

223     public void save() throws CoinException {
224         try {
225             this.myDO.commit();
226         } catch(Exception JavaDoc ex) {
227             System.out.println("Exception: " + ex);
228             //throw new CoinException("Exception in save():"+ ex.printStackTrace());
229
}
230     }
231     
232     /**
233      * Deletes the disc from the database.
234      *
235      * @exception CoinException if an error occurs
236      * deleting data (usually due to an underlying data layer
237      * error).
238      */

239     public void delete() throws CoinException {
240         try {
241             this.myDO.delete();
242         } catch(Exception JavaDoc ex) {
243             System.out.println("Exception: " + ex);
244             //throw new CoinException("Exception in delete():"+ ex.printStackTrace());
245
}
246     }
247 }
Popular Tags