KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > wstore > WebBasket


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.wstore;
15
16 import java.util.*;
17 import java.math.*;
18
19 import org.apache.log4j.Logger;
20
21 import org.compiere.util.Env;
22 import org.compiere.www.*;
23
24
25 /**
26  * Web Basket
27  *
28  * @author Jorg Janke
29  * @version $Id: WebBasket.java,v 1.3 2003/04/11 05:50:48 jjanke Exp $
30  */

31 public class WebBasket
32 {
33     /**
34      * Constructor
35      */

36     public WebBasket()
37     {
38     } // WebBasket
39

40     /** Attribute Name - also in JSPs */
41     public static final String JavaDoc NAME = "webBasket";
42
43     /** Logging */
44     private Logger log = Logger.getLogger(getClass());
45     /** Lines */
46     private ArrayList m_lines = new ArrayList();
47     /** Total w/o tax */
48     private BigDecimal m_total;
49     /** Line (max) counter */
50     private int m_lineNo = 0;
51     private int m_PriceList_Version_ID = -1;
52     private int m_PriceList_ID = -1;
53
54     /**
55      * String Representation
56      * @return info
57      */

58     public String JavaDoc toString()
59     {
60         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("WebBasket[");
61         sb.append(m_lines.size()).append("-").append(m_total)
62             .append(",M_PriceList_ID=" + m_PriceList_ID)
63             .append("]");
64         return sb.toString();
65     } // toString
66

67     /**
68      * Get Total
69      * @return total
70      */

71     public BigDecimal getTotal()
72     {
73         if (m_total == null)
74             return Env.ZERO;
75         return m_total;
76     } // getTotal
77

78     /**
79      * Get Line Count
80      * @return line count
81      */

82     public int getLineCount()
83     {
84         return m_lines.size();
85     } // getLineCount
86

87     /**
88      * Get Lines
89      * @return lines
90      */

91     public ArrayList getLines()
92     {
93         return m_lines;
94     } // getLines
95

96     /**
97      * Add Line
98      * @param wbl line
99      */

100     public void add (WebBasketLine wbl)
101     {
102         wbl.setLine (m_lineNo++);
103         m_lines.add(wbl);
104         m_total = getTotal().add(wbl.getTotal());
105     } // add
106

107     /**
108      * Delete Line
109      * @param no line no
110      */

111     public void delete (int no)
112     {
113         for (int i = 0; i < m_lines.size(); i++)
114         {
115             WebBasketLine wbl = (WebBasketLine)m_lines.get(i);
116             if (wbl.getLine() == no)
117             {
118                 m_total = getTotal().subtract(wbl.getTotal());
119                 m_lines.remove(i);
120                 break;
121             }
122         }
123     } // delete
124

125     public int getM_PriceList_Version_ID()
126     {
127         return m_PriceList_Version_ID;
128     }
129     public void setM_PriceList_Version_ID(int PriceList_Version_ID)
130     {
131         if (PriceList_Version_ID > 0)
132             m_PriceList_Version_ID = PriceList_Version_ID;
133     }
134     public int getM_PriceList_ID()
135     {
136         return m_PriceList_ID;
137     }
138     public void setM_PriceList_ID(int PriceList_ID)
139     {
140         if (PriceList_ID > 0)
141             m_PriceList_ID = PriceList_ID;
142     }
143
144 } // WebBasket
145
Popular Tags