001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2007 Dennis Reil
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021: package com.izforge.izpack.rules;
022:
023: import net.n3.nanoxml.XMLElement;
024:
025: import com.izforge.izpack.util.Debug;
026:
027: /**
028: * @author Dennis Reil, <Dennis.Reil@reddot.de>
029: */
030: public class NotCondition extends Condition {
031:
032: /**
033: *
034: */
035: private static final long serialVersionUID = 3194843222487006309L;
036: protected Condition operand;
037:
038: /**
039: *
040: */
041: public NotCondition() {
042: super ();
043: // TODO Auto-generated constructor stub
044: }
045:
046: /**
047: *
048: */
049: public NotCondition(Condition operand) {
050: this .operand = operand;
051: }
052:
053: /*
054: * (non-Javadoc)
055: *
056: * @see de.reddot.installer.util.Condition#isTrue()
057: */
058: /*
059: public boolean isTrue(Properties variables)
060: {
061: return !operand.isTrue(variables);
062: }
063: */
064:
065: /*
066: * (non-Javadoc)
067: *
068: * @see de.reddot.installer.rules.Condition#readFromXML(net.n3.nanoxml.XMLElement)
069: */
070: public void readFromXML(XMLElement xmlcondition) {
071: try {
072: if (xmlcondition.getChildrenCount() != 1) {
073: Debug
074: .log("not-condition needs one condition as operand");
075: return;
076: }
077: this .operand = RulesEngine.analyzeCondition(xmlcondition
078: .getChildAtIndex(0));
079: } catch (Exception e) {
080: Debug.log("missing element in not-condition");
081: }
082: }
083:
084: /*
085: public boolean isTrue(Properties variables, List selectedpacks)
086: {
087: return !operand.isTrue(variables, selectedpacks);
088: }
089: */
090: public boolean isTrue() {
091: return !operand.isTrue();
092: }
093:
094: /* (non-Javadoc)
095: * @see com.izforge.izpack.rules.Condition#getDependenciesDetails()
096: */
097: public String getDependenciesDetails() {
098: StringBuffer details = new StringBuffer();
099: details.append(this .id);
100: details.append(" depends on:<ul><li>NOT ");
101: details.append(operand.getDependenciesDetails());
102: details.append("</li></ul>");
103: return details.toString();
104: }
105: }
|