KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > invicta > api > ProductContainer


1 package net.sf.invicta.api;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.List JavaDoc;
5
6 /**
7  * A container of multiple products. Simplies the some actions on a list of
8  * multiple products: finding products by type or by name, removing products,
9  * iterating over products, etc.
10  *
11  */

12 public interface ProductContainer {
13
14     /**
15      * Inserts a new product into the container.
16      * @param product Product to insert.
17      */

18     public void insert(Product product);
19     
20     /**
21      * Removes a product from the container that equals to the given
22      * product.
23      * @param product Product to remove.
24      */

25     public void removeByProduct(Product product);
26     
27     /**
28      * Removes a product with the given key from the container.
29      * @param key of the product to remove.
30      */

31     public void removeByKey(String JavaDoc key);
32     
33     /**
34      * Returns all products of this container as a list.
35      * @return List of Product objects.
36      */

37     public List JavaDoc findAll();
38     
39     /**
40      * Returns a product container with all products of this container that
41      * have the given name.
42      * @param name The name of the products to find.
43      * @return ProductContainer
44      */

45     public ProductContainer findByName(String JavaDoc name);
46     
47     /**
48      * Returns a product container with all products of this container that
49      * are of the given type.
50      * @param type The type of the products to find.
51      * @return ProductContainer
52      */

53     public ProductContainer findByType(String JavaDoc type);
54     
55     /**
56      * Returns a product container with all products of this container that
57      * are of the given type and name.
58      * @param name The name of the products to find.
59      * @param type The type of the products to find.
60      * @return ProductContainer
61      */

62     public ProductContainer findByTypeAndName(String JavaDoc name, String JavaDoc type);
63     
64     /**
65      * Returns a product of this container that has the given key.
66      * @param key The key of the product to find.
67      * @return Product
68      */

69     public Product findByKey(String JavaDoc key);
70     
71     /**
72      * Returns the number of products in this container.
73      * @return int. Number of products.
74      */

75     public int size();
76     
77     /**
78      * Inserts all products of the given container into this container.
79      * @param productContainer container of products to insert.
80      */

81     public void insertAll(ProductContainer productContainer);
82     
83     /**
84      * Remove all products of the given container that exist in this
85      * container.
86      * @param productContainer container of products to remove.
87      */

88     public void removeAll(ProductContainer productContainer);
89     
90     /**
91      * Returns whether the given product exists in this container.
92      * @param product
93      * @return boolean
94      */

95     public boolean containsProduct(Product product);
96     
97     /**
98      * Returns whether a product with the given key exists in this container.
99      * @param key
100      * @return boolean
101      */

102     public boolean containsKey(String JavaDoc key);
103     
104     /**
105      * Returns whether a product with the given name exists in this container.
106      * @param name
107      * @return boolean
108      */

109     public boolean containsName(String JavaDoc name);
110     
111     /**
112      * Returns an iterator to the beginning of the list of products of this
113      * container.
114      * @return Iterator
115      */

116     public Iterator JavaDoc iterator();
117 }
Popular Tags