KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > rules > AndCondition


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2007 Dennis Reil
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.izforge.izpack.rules;
23
24 import java.util.List JavaDoc;
25 import java.util.Properties JavaDoc;
26
27 import net.n3.nanoxml.XMLElement;
28 import com.izforge.izpack.util.Debug;
29
30 /**
31  * Defines a condition where both operands have to be true
32  *
33  * @author Dennis Reil, <Dennis.Reil@reddot.de>
34  */

35 public class AndCondition extends Condition
36 {
37
38     protected Condition leftoperand;
39
40     protected Condition rightoperand;
41
42     /**
43      *
44      */

45     public AndCondition()
46     {
47         super();
48     }
49
50     /**
51      *
52      */

53     public AndCondition(Condition operand1, Condition operand2)
54     {
55         this.leftoperand = operand1;
56         this.rightoperand = operand2;
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see de.reddot.installer.util.Condition#isTrue()
63      */

64     /*
65     public boolean isTrue(Properties variables)
66     {
67         return leftoperand.isTrue(variables) && rightoperand.isTrue(variables);
68     }
69     */

70
71     /*
72      * (non-Javadoc)
73      *
74      * @see de.reddot.installer.rules.Condition#readFromXML(net.n3.nanoxml.XMLElement)
75      */

76     public void readFromXML(XMLElement xmlcondition)
77     {
78         try
79         {
80             if (xmlcondition.getChildrenCount() != 2)
81             {
82                 Debug.log("and-condition needs two conditions as operands");
83                 return;
84             }
85             this.leftoperand = RulesEngine.analyzeCondition(xmlcondition.getChildAtIndex(0));
86             this.rightoperand = RulesEngine.analyzeCondition(xmlcondition.getChildAtIndex(1));
87         }
88         catch (Exception JavaDoc e)
89         {
90             Debug.log("missing element in and-condition");
91         }
92     }
93
94     /*
95     public boolean isTrue(Properties variables, List selectedpacks)
96     {
97         return leftoperand.isTrue(variables, selectedpacks)
98                 && rightoperand.isTrue(variables, selectedpacks);
99     }
100     */

101     public boolean isTrue()
102     {
103         return leftoperand.isTrue() && rightoperand.isTrue();
104     }
105 }
106
Popular Tags