001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata masks may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: ProductDO.java,v $
031: * Revision 1.9 2005/10/12 18:19:42 colinmacleod
032: * Fixed some style issues.
033: *
034: * Revision 1.8 2005/10/03 10:17:24 colinmacleod
035: * Fixed some style and javadoc issues.
036: *
037: * Revision 1.7 2005/09/14 12:41:33 colinmacleod
038: * Added serialVersionUID.
039: *
040: * Revision 1.6 2005/04/09 18:04:13 colinmacleod
041: * Changed copyright text to GPL v2 explicitly.
042: *
043: * Revision 1.5 2005/01/19 12:17:02 colinmacleod
044: * Added logging to catch form clear bug.
045: *
046: * Revision 1.4 2005/01/07 09:13:04 colinmacleod
047: * Added newline to end of file.
048: *
049: * Revision 1.3 2005/01/07 08:08:18 colinmacleod
050: * Moved up a version number.
051: * Changed copyright notices to 2005.
052: * Updated the documentation:
053: * - started working on multiproject:site docu.
054: * - changed the logo.
055: * Added checkstyle and fixed LOADS of style issues.
056: * Added separate third-party subproject.
057: * Added struts (in web), util and webgui (in webtheme) from ivata op.
058: *
059: * Revision 1.2 2004/11/11 13:17:13 colinmacleod
060: * Changed to extend DemoValueObject.
061: *
062: * Revision 1.1.1.1 2004/05/16 20:40:07 colinmacleod
063: * Ready for 0.1 release
064: * -----------------------------------------------------------------------------
065: */
066: package com.ivata.mask.web.demo.product;
067:
068: import java.math.BigDecimal;
069:
070: import org.apache.log4j.Logger;
071:
072: import com.ivata.mask.web.demo.valueobject.DemoValueObject;
073:
074: /**
075: * <p>
076: * Represents a single product which can be ordered.
077: * </p>
078: *
079: * @author Colin MacLeod
080: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
081: * @since ivata masks 0.1 (2004-05-09)
082: * @version $Revision: 1.9 $
083: */
084: public final class ProductDO extends DemoValueObject {
085: /**
086: * Serialization version (for <code>Serializable</code> interface).
087: */
088: private static final long serialVersionUID = 1L;
089:
090: /**
091: * Logger for this class.
092: */
093: private static final Logger logger = Logger
094: .getLogger(ProductDO.class);
095:
096: /**
097: * <p>
098: * Full text description of the product.
099: * </p>
100: */
101: private String description;
102: /**
103: * <p>
104: * Name of the product. Clear text name, should be unique, though this is
105: * not enforced.
106: * </p>
107: */
108: private String name;
109: /**
110: * <p>
111: * Cost of each item of this product.
112: * </p>
113: */
114: private BigDecimal price;
115:
116: /**
117: * <p>
118: * Construct a new product instance with no id.
119: * </p>
120: */
121: public ProductDO() {
122: super ();
123: }
124:
125: /**
126: * <p>
127: * Construct a new product instance with the given unique identifier.
128: * </p>
129: *
130: * @param id
131: * unique identifier of this product.
132: */
133: public ProductDO(final int id) {
134: super (id);
135: }
136:
137: /**
138: * The product's description is a long text designed to make you desperate
139: * to own one immediately.
140: *
141: * @return long text designed to make you drool.
142: */
143: public String getDescription() {
144: return description;
145: }
146:
147: /**
148: * For products, the value displayed is always the product's name.
149: *
150: * @return just returns the product's name.
151: * @see com.ivata.mask.valueobject.ValueObject#getStringValue()
152: */
153: public String getDisplayValue() {
154: return name;
155: }
156:
157: /**
158: * The name of a product is unique among products - that short text which
159: * uniquely identifies it.
160: *
161: * @return unique name of this product.
162: */
163: public String getName() {
164: return name;
165: }
166:
167: /**
168: * What price quality? This is the cost of a single unit of the product.
169: *
170: * @return cost of a single unit of the product.
171: */
172: public BigDecimal getPrice() {
173: return price;
174: }
175:
176: /**
177: * The product's description is a long text designed to make you desperate
178: * to own one immediately.
179: *
180: * @param descriptionParam long text designed to make you drool.
181: */
182: public void setDescription(final String descriptionParam) {
183: if (logger.isDebugEnabled()) {
184: logger.debug("Set description was '" + description
185: + "', now '" + descriptionParam + "'");
186: }
187: description = descriptionParam;
188: }
189:
190: /**
191: * The name of a product is unique among products - that short text which
192: * uniquely identifies it.
193: *
194: * @param nameParam unique name of this product.
195: */
196: public void setName(final String nameParam) {
197: if (logger.isDebugEnabled()) {
198: logger.debug("Set name was '" + name + "', now '"
199: + nameParam + "'");
200: }
201: name = nameParam;
202: }
203:
204: /**
205: * Set the cost of one unit of this product.
206: *
207: * @param priceParam cost of a single unit of this product.
208: */
209: public void setPrice(final BigDecimal priceParam) {
210: if (logger.isDebugEnabled()) {
211: logger.debug("Set price was '" + price + "', now '"
212: + priceParam + "'");
213: }
214: if ((price != null) && (priceParam == null)) {
215: throw new NullPointerException();
216: }
217: price = priceParam;
218: }
219: }
|