1 /***
2 * Producer.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2002 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.processing;
27
28 /***
29 * The interface describing the common behaviors to every producer. This
30 * Interface along with the Consumer Interface is designed to enable to easily
31 * string "consumption - production" pieces together. It enables to separate the
32 * successive operations applied to data so that the developers can concentrate
33 * their efforts on the operations themselves and not on how they are to be
34 * stringed or how the application will be architectured (distributed producers
35 * and consumers, pools, load balancing...) The architecture issues merely
36 * appear at deployment time.
37 *
38 * @author $Author: dbregeon $
39 * @version $Revision: 1.2 $
40 */
41 public interface Producer {
42 /***
43 * Sets a flag that shows whether the production is over.
44 *
45 * @param bool
46 * The boolean value that the flag has to be set on.
47 */
48 void setProductionOver(boolean bool);
49
50 /***
51 * Returns true if the production is over, false if not.
52 *
53 * @return True if the production is over, false if not.
54 */
55 boolean isProductionOver();
56
57 /***
58 * Returns the next item free for consumption.
59 *
60 * @return The next item free for consumption.
61 */
62 Object nextItem();
63
64 /***
65 * Validates an item, i.e. marks it as having been consumed.
66 *
67 * @param theItem
68 * The item to be validated.
69 * @return true if the object was validated.
70 */
71 boolean validateItem(Object theItem);
72
73 /***
74 * Produces next item, i.e. marks it as consumable.
75 *
76 * @return True if there are still objects to produce, false otherwise.
77 */
78 boolean produceItem();
79 }
80