KickJava   Java API By Example, From Geeks To Geeks.

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


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

31 public class XOrCondition extends OrCondition
32 {
33
34     /**
35      *
36      */

37     public XOrCondition()
38     {
39         super();
40         // TODO Auto-generated constructor stub
41
}
42
43     /**
44      * @param operand1
45      * @param operand2
46      */

47     public XOrCondition(Condition operand1, Condition operand2)
48     {
49         super(operand1, operand2);
50     }
51
52     /*
53      * (non-Javadoc)
54      *
55      * @see de.reddot.installer.util.OrCondition#isTrue()
56      */

57     /*
58     public boolean isTrue(Properties variables)
59     {
60         boolean op1true = leftoperand.isTrue(variables);
61         boolean op2true = rightoperand.isTrue(variables);
62
63         if (op1true && op2true)
64         {
65             // in case where both are true
66             return false;
67         }
68         return op1true || op2true;
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("xor-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 xor-condition");
91         }
92     }
93
94     public boolean isTrue()
95     {
96         boolean op1true = leftoperand.isTrue();
97         boolean op2true = rightoperand.isTrue();
98
99         if (op1true && op2true)
100         {
101             // in case where both are true
102
return false;
103         }
104         return op1true || op2true;
105     }
106
107     /*
108     public boolean isTrue(Properties variables, List selectedpacks)
109     {
110         boolean op1true = leftoperand.isTrue(variables, selectedpacks);
111         boolean op2true = rightoperand.isTrue(variables, selectedpacks);
112
113         if (op1true && op2true)
114         {
115             // in case where both are true
116             return false;
117         }
118         return op1true || op2true;
119     }
120     */

121 }
122
Popular Tags