KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > listdata > data > SimpleRule


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: SimpleRule.java,v 1.4 2007/01/07 06:14:50 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.patterns.listdata.data;
23
24 import java.io.Serializable JavaDoc;
25 import java.util.List JavaDoc;
26
27 /**
28  * This class represents set of data conditions which are connected with logical
29  * operation and can be used to filter or match data object. Since only single
30  * operator such as AND or OR is used to connect all data condition it is
31  * considered to be a simple rule (as oposed to complex rule where these operations
32  * could be mixed).
33  *
34  * @version $Id: SimpleRule.java,v 1.4 2007/01/07 06:14:50 bastafidli Exp $
35  * @author Peter Satury
36  * @code.reviewer Miro Halas
37  * @code.reviewed 1.2 2004/12/18 06:18:41 bastafidli
38  */

39 public class SimpleRule implements Serializable JavaDoc
40 {
41    // Cached values ////////////////////////////////////////////////////////////
42

43    /**
44     * AND operand code
45     */

46    public static final int LOGICAL_AND = 1;
47
48    /**
49     * OR operand code
50     */

51    public static final int LOGICAL_OR = 2;
52    
53    /**
54     * This rule matches all data
55     */

56    public static final SimpleRule ALL_DATA = new SimpleRule(LOGICAL_OR,
57                                                             null);
58    
59    // Attributes ///////////////////////////////////////////////////////////////
60

61    /**
62     * Generated serial version UID.
63     */

64    private static final long serialVersionUID = -6988653599832397651L;
65
66    /**
67     * Logical operation to connect data condition. Use one of LOGICAL_XXX constants.
68     */

69    protected int m_iLogicalOperation;
70    
71    /**
72     * List of DataCondition objects connected with the logical operation.
73     */

74    protected List JavaDoc m_conditions;
75
76    // Constructors /////////////////////////////////////////////////////////////
77

78    /**
79     * Default constructor.
80     */

81    public SimpleRule()
82    {
83       this(LOGICAL_AND, null);
84    }
85
86    /**
87     * Constructor with all parameters
88     *
89     * @param iLogicalOperation - logical operation to connect data condition.
90     * Use one of LOGICAL_XXX constants.
91     * @param conditions - list of DataConditions
92     */

93    public SimpleRule(
94       int iLogicalOperation,
95       List JavaDoc conditions
96    )
97    {
98       m_iLogicalOperation = iLogicalOperation;
99       m_conditions = conditions;
100    }
101    
102    /**
103     * @return List - list of DataCondition objects, can be null
104     */

105    public List JavaDoc getConditions()
106    {
107       return m_conditions;
108    }
109
110    /**
111     * @return int - logical operation, one of LOGICAL_XXX constants
112     */

113    public int getConditionsOperand()
114    {
115       return m_iLogicalOperation;
116    }
117 }
118
Popular Tags