001: /*
002: * Copyright (c) 2001 - 2004 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: OrderItemDO.java,v $
031: * Revision 1.5 2005/09/14 12:41:33 colinmacleod
032: * Added serialVersionUID.
033: *
034: * Revision 1.4 2005/04/09 18:04:13 colinmacleod
035: * Changed copyright text to GPL v2 explicitly.
036: *
037: * Revision 1.3 2005/01/07 09:13:04 colinmacleod
038: * Added newline to end of file.
039: *
040: * Revision 1.2 2005/01/07 08:08:18 colinmacleod
041: * Moved up a version number.
042: * Changed copyright notices to 2005.
043: * Updated the documentation:
044: * - started working on multiproject:site docu.
045: * - changed the logo.
046: * Added checkstyle and fixed LOADS of style issues.
047: * Added separate thirdparty subproject.
048: * Added struts (in web), util and webgui (in webtheme) from ivata op.
049: *
050: * Revision 1.1 2004/11/10 17:18:20 colinmacleod
051: * New value object classes - first version in CVS.
052: * -----------------------------------------------------------------------------
053: */
054: package com.ivata.mask.web.demo.order.item;
055:
056: import com.ivata.mask.web.demo.product.ProductDO;
057: import com.ivata.mask.web.demo.valueobject.DemoValueObject;
058:
059: /**
060: * <p>
061: * Represents a single order item of this imaginary system.
062: * </p>
063: *
064: * @author Colin MacLeod
065: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
066: * @since ivata masks 0.2 (2004-05-20)
067: * @version $Revision: 1.5 $
068: */
069: public final class OrderItemDO extends DemoValueObject {
070: /**
071: * Serialization version (for <code>Serializable</code> interface).
072: */
073: private static final long serialVersionUID = 1L;
074: /**
075: * <p>
076: * Product being ordered.
077: * </p>
078: */
079: private ProductDO product;
080: /**
081: * <p>
082: * Number of instances of this product being ordered.
083: * </p>
084: */
085: private int quantity;
086:
087: /**
088: * <p>
089: * Construct a new order item instance with no id.
090: * </p>
091: */
092: public OrderItemDO() {
093: super ();
094: }
095:
096: /**
097: * <p>
098: * Construct a new order item instance with the given unique identifier.
099: * </p>
100: *
101: * @param idParam unique identifier of this product.
102: */
103: public OrderItemDO(final int idParam) {
104: super (idParam);
105: }
106:
107: /**
108: * Identifies the product being ordered as this item.
109: *
110: * @return product instance for this order.
111: */
112: public ProductDO getProduct() {
113: return product;
114: }
115:
116: /**
117: * Number of units of product being ordered.
118: *
119: * @return number of units of product being ordered.
120: */
121: public int getQuantity() {
122: return quantity;
123: }
124:
125: /**
126: * Identifies the product being ordered as this item.
127: *
128: * @param productParam new product instance for this order.
129: */
130: public void setProduct(final ProductDO productParam) {
131: product = productParam;
132: }
133:
134: /**
135: * Number of units of product being ordered.
136: *
137: * @param quantityParam number of units of product being ordered.
138: */
139: public void setQuantity(final int quantityParam) {
140: quantity = quantityParam;
141: }
142:
143: /**
144: * For an order item, the display value is given as "product
145: * x quantity".
146: *
147: * @see com.ivata.mask.valueobject.ValueObject#getStringValue()
148: */
149: public String getDisplayValue() {
150: String productValue;
151: if (product == null) {
152: productValue = "[None]";
153: } else {
154: productValue = product.getDisplayValue();
155: }
156: return quantity + "x " + productValue;
157: }
158: }
|