001 /*
002 *
003 * $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
004 *
005 * This file is part of *** M y C o R e ***
006 * See http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, in a file called gpl.txt or license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 */
023
024 package org.mycore.parsers.bool;
025
026 import org.jdom.Attribute;
027 import org.jdom.Element;
028
029 /**
030 * @author Frank Lützenkirchen
031 */
032 public class MCRNotCondition implements MCRCondition {
033 private MCRCondition child;
034
035 public MCRNotCondition(MCRCondition child) {
036 this.child = child;
037 }
038
039 public MCRCondition getChild() {
040 return child;
041 }
042
043 public String toString() {
044 return "not (" + child + ")";
045 }
046
047 public boolean evaluate(Object o) {
048 return !child.evaluate(o);
049 }
050
051 public Element toXML() {
052 Element not = new Element("boolean");
053 not.setAttribute("operator", "not");
054 not.addContent(child.toXML());
055 return not;
056 }
057
058 public Element info() {
059 Element el = new Element("info");
060 el.setAttribute(new Attribute("type", "not"));
061 el.setAttribute(new Attribute("children", "1"));
062
063 return el;
064 }
065
066 public void accept(MCRConditionVisitor visitor) {
067 visitor.visitType(info());
068 child.accept(visitor);
069 }
070 }