View Javadoc

1   /*
2    * Copyright (c) 2001 - 2004 ivata limited.
3    * All rights reserved.
4    * -----------------------------------------------------------------------------
5    * ivata masks may be redistributed under the GNU General Public
6    * License as published by the Free Software Foundation;
7    * version 2 of the License.
8    *
9    * These programs are free software; you can redistribute them and/or
10   * modify them under the terms of the GNU General Public License
11   * as published by the Free Software Foundation; version 2 of the License.
12   *
13   * These programs are distributed in the hope that they will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16   *
17   * See the GNU General Public License in the file LICENSE.txt for more
18   * details.
19   *
20   * If you would like a copy of the GNU General Public License write to
21   *
22   * Free Software Foundation, Inc.
23   * 59 Temple Place - Suite 330
24   * Boston, MA 02111-1307, USA.
25   *
26   *
27   * To arrange commercial support and licensing, contact ivata at
28   *                  http://www.ivata.com/contact.jsp
29   * -----------------------------------------------------------------------------
30   * $Log: OrderItemDO.java,v $
31   * Revision 1.4  2005/04/09 18:04:13  colinmacleod
32   * Changed copyright text to GPL v2 explicitly.
33   *
34   * Revision 1.3  2005/01/07 09:13:04  colinmacleod
35   * Added newline to end of file.
36   *
37   * Revision 1.2  2005/01/07 08:08:18  colinmacleod
38   * Moved up a version number.
39   * Changed copyright notices to 2005.
40   * Updated the documentation:
41   *   - started working on multiproject:site docu.
42   *   - changed the logo.
43   * Added checkstyle and fixed LOADS of style issues.
44   * Added separate thirdparty subproject.
45   * Added struts (in web), util and webgui (in webtheme) from ivata op.
46   *
47   * Revision 1.1  2004/11/10 17:18:20  colinmacleod
48   * New value object classes - first version in CVS.
49   * -----------------------------------------------------------------------------
50   */
51  package com.ivata.mask.web.demo.order.item;
52  import com.ivata.mask.web.demo.product.ProductDO;
53  import com.ivata.mask.web.demo.valueobject.DemoValueObject;
54  /***
55   * <p>
56   * Represents a single order item of this imaginary system.
57   * </p>
58   *
59   * @author Colin MacLeod
60   * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
61   * @since ivata masks 0.2 (2004-05-20)
62   * @version $Revision: 1.4 $
63   */
64  public final class OrderItemDO extends DemoValueObject {
65      /***
66       * <p>
67       * Product being ordered.
68       * </p>
69       */
70      private ProductDO product;
71      /***
72       * <p>
73       * Number of instances of this product being ordered.
74       * </p>
75       */
76      private int quantity;
77      /***
78       * <p>
79       * Construct a new order item instance with no id.
80       * </p>
81       */
82      public OrderItemDO() {
83          super();
84      }
85      /***
86       * <p>
87       * Construct a new order item instance with the given unique identifier.
88       * </p>
89       *
90       * @param idParam unique identifier of this product.
91       */
92      public OrderItemDO(final int idParam) {
93          super(idParam);
94      }
95      /***
96       * Identifies the product being ordered as this item.
97       *
98       * @return product instance for this order.
99       */
100     public ProductDO getProduct() {
101         return product;
102     }
103     /***
104      * Number of units of product being ordered.
105      *
106      * @return number of units of product being ordered.
107      */
108     public int getQuantity() {
109         return quantity;
110     }
111     /***
112      * Identifies the product being ordered as this item.
113      *
114      * @param productParam new product instance for this order.
115      */
116     public void setProduct(final ProductDO productParam) {
117         product = productParam;
118     }
119     /***
120      * Number of units of product being ordered.
121      *
122      * @param quantityParam number of units of product being ordered.
123      */
124     public void setQuantity(final int quantityParam) {
125         quantity = quantityParam;
126     }
127     /***
128      * For an order item, the display value is given as &quot;product
129      * x quantity&quot;.
130      *
131      * @see com.ivata.mask.valueobject.ValueObject#getStringValue()
132      */
133     public String getDisplayValue() {
134         String productValue;
135         if (product == null) {
136             productValue = "[None]";
137         } else {
138             productValue = product.getDisplayValue();
139         }
140         return quantity
141             + "x "
142             + productValue;
143     }
144 }
145