KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.izforge.izpack.rules;
22
23 import java.util.List JavaDoc;
24 import java.util.Properties JavaDoc;
25
26 import net.n3.nanoxml.XMLElement;
27 import com.izforge.izpack.util.Debug;
28
29 /**
30  * @author Dennis Reil, <Dennis.Reil@reddot.de>
31  * @version $Id: OrCondition.java,v 1.1 2006/09/29 14:40:38 dennis Exp $
32  */

33 public class OrCondition extends Condition
34 {
35
36     public static final String JavaDoc RDE_VCS_REVISION = "$Revision: 1.1 $";
37
38     public static final String JavaDoc RDE_VCS_NAME = "$Name: $";
39
40     protected Condition leftoperand;
41
42     protected Condition rightoperand;
43
44     /**
45      *
46      */

47     public OrCondition()
48     {
49         super();
50         // TODO Auto-generated constructor stub
51
}
52
53     /**
54      *
55      */

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

67     /*
68      * public boolean isTrue(Properties variables) { return this.leftoperand.isTrue(variables) ||
69      * this.rightoperand.isTrue(variables); }
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("or-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 or-condition");
91         }
92     }
93
94     /*
95      * public boolean isTrue(Properties variables, List selectedpacks) { return
96      * this.leftoperand.isTrue(variables, selectedpacks) || this.rightoperand.isTrue(variables,
97      * selectedpacks); }
98      */

99     public boolean isTrue()
100     {
101         return this.leftoperand.isTrue() || this.rightoperand.isTrue();
102     }
103 }
104
Popular Tags