KickJava   Java API By Example, From Geeks To Geeks.

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


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  */

30 public class NotCondition extends Condition
31 {
32
33     protected Condition operand;
34
35     /**
36      *
37      */

38     public NotCondition()
39     {
40         super();
41         // TODO Auto-generated constructor stub
42
}
43
44     /**
45      *
46      */

47     public NotCondition(Condition operand)
48     {
49         this.operand = operand;
50     }
51
52     /*
53      * (non-Javadoc)
54      *
55      * @see de.reddot.installer.util.Condition#isTrue()
56      */

57     /*
58     public boolean isTrue(Properties variables)
59     {
60         return !operand.isTrue(variables);
61     }
62     */

63
64     /*
65      * (non-Javadoc)
66      *
67      * @see de.reddot.installer.rules.Condition#readFromXML(net.n3.nanoxml.XMLElement)
68      */

69     public void readFromXML(XMLElement xmlcondition)
70     {
71         try
72         {
73             if (xmlcondition.getChildrenCount() != 1)
74             {
75                 Debug.log("not-condition needs one condition as operand");
76                 return;
77             }
78             this.operand = RulesEngine.analyzeCondition(xmlcondition.getChildAtIndex(0));
79         }
80         catch (Exception JavaDoc e)
81         {
82             Debug.log("missing element in not-condition");
83         }
84     }
85
86     /*
87     public boolean isTrue(Properties variables, List selectedpacks)
88     {
89         return !operand.isTrue(variables, selectedpacks);
90     }
91     */

92     public boolean isTrue()
93     {
94         return !operand.isTrue();
95     }
96 }
97
Popular Tags