KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > example > ajax > cart > ShoppingCart


1 /*
2  * Copyright (c) 2005 Your Corporation. All Rights Reserved.
3  */

4 package com.opensymphony.webwork.example.ajax.cart;
5
6 import com.opensymphony.webwork.example.ajax.catalog.Product;
7
8 import java.util.Set JavaDoc;
9
10 /**
11  * ShoppingCart
12  *
13  * @author Jason Carreira <jcarreira@eplus.com>
14  */

15 public interface ShoppingCart {
16     /**
17      * Adds the specified quantity of the given {@link Product} to the shopping cart. This will add to any
18      * existing quantity of this {@link Product} in the cart.
19      *
20      * @param quantity the quantity to add to the cart
21      * @param product the {@link Product} to add the quantity of
22      */

23     void addToCart(int quantity, Product product);
24
25     /**
26      * Sets the quantity of the specifed {@link Product} in the shopping cart. If the {@link Product} does not
27      * exist in the Cart, it is added.
28      *
29      * @param quantity the quantity to set in the cart for the {@link Product}
30      * @param product the {@link Product} to set the quantity for
31      */

32     void setQuantity(int quantity, Product product);
33
34     /**
35      * Removes the given {@link Product} from the Cart
36      *
37      * @param product the {@link Product} to remove from the Cart
38      */

39     void removeFromCart(Product product);
40
41     /**
42      * Get a {@link java.util.List} of {@link CartEntry} objects in the cart
43      *
44      * @return a {@link java.util.List} of {@link CartEntry} objects in the Cart. Will not return null.
45      */

46     Set JavaDoc getContents();
47
48     /**
49      * Get the quantity of the product in the shopping cart
50      *
51      * @param product
52      * @return the quantity, or 0 if the product is not in the cart
53      */

54     int getQuantityForProduct(Product product);
55
56     interface CartEntry {
57         int getQuantity();
58
59         Product getProduct();
60
61         void setQuantity(int quantity);
62     }
63 }
64
Popular Tags