View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3    Copyright (c) 2005, University of Innsbruck, Austria
4    This library is free software; you can redistribute it and/or modify it under
5    the terms of the GNU Lesser General Public License as published by the Free
6    Software Foundation; either version 2.1 of the License, or (at your option)
7    any later version.
8    This library is distributed in the hope that it will be useful, but WITHOUT
9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11   details.
12   You should have received a copy of the GNU Lesser General Public License along
13   with this library; if not, write to the Free Software Foundation, Inc.,
14   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15   */
16  package org.deri.wsmo4j.logicalexpression;
17  
18  
19  import org.omwg.logicalexpression.*;
20  
21  
22  /**
23   * This abstract class represents a visitor for the logical expression
24   * tree structure.
25   * @author DERI Innsbruck, reto.krummenacher@deri.org
26   * @version $Revision: 947 $ $Date: 2005-09-13 20:45:06 +0300 (Tue, 13 Sep 2005) $
27   * @see org.omwg.logicalexpression.Visitor
28   * @see <a href "http://en.wikipedia.org/wiki/Visitor_pattern">Visitor Pattern</a>
29   */
30  public abstract class AbstractVisitor
31          implements Visitor {
32  
33      /**
34       * @param expr Atom
35       * @see org.omwg.logicalexpression.Visitor#visitAtom(org.omwg.logicalexpression.Atom)
36       */
37      public void visitAtom(Atom expr) {
38  
39      }
40  
41      /**
42       * @param expr Molecule
43       * @see org.omwg.logicalexpression.Visitor#visitMolecule(org.omwg.logicalexpression.Molecule)
44       */
45      public void visitMolecule(Molecule expr) {
46  
47      }
48  
49      /**
50       * @param expr Unary with operator NEG
51       * @see org.omwg.logicalexpression.Visitor#visitNegation(Negation)
52       */
53      public void visitNegation(Negation expr) {
54          expr.getOperand().accept(this);
55      }
56  
57      /**
58       * @param expr Unary with operator NAF
59       * @see org.omwg.logicalexpression.Visitor#visitNegationAsFailure(NegationAsFailure)
60       */
61      public void visitNegationAsFailure(NegationAsFailure expr) {
62          expr.getOperand().accept(this);
63      }
64  
65      /**
66       * @param expr Unary with operator CONSTRAINT
67       * @see org.omwg.logicalexpression.Visitor#visitConstraint(Constraint)
68       */
69      public void visitConstraint(Constraint expr) {
70          expr.getOperand().accept(this);
71      }
72  
73      /**
74       * @param expr Binary with operator AND
75       * @see org.omwg.logicalexpression.Visitor#visitConjunction(Conjunction)
76       */
77      public void visitConjunction(Conjunction expr) {
78          expr.getLeftOperand().accept(this);
79          expr.getRightOperand().accept(this);
80      }
81  
82      /**
83       * @param expr Binary with operator OR
84       * @see org.omwg.logicalexpression.Visitor#visitDisjunction(Disjunction)
85       */
86      public void visitDisjunction(Disjunction expr) {
87          expr.getLeftOperand().accept(this);
88          expr.getRightOperand().accept(this);
89      }
90  
91      /**
92       * @param expr Binary with operator IMPLIEDBY
93       * @see org.omwg.logicalexpression.Visitor#visitInverseImplication(InverseImplication)
94       */
95      public void visitInverseImplication(InverseImplication expr) {
96          expr.getLeftOperand().accept(this);
97          expr.getRightOperand().accept(this);
98      }
99  
100     /**
101      * @param expr Binary with operator IMPLIES
102      * @see org.omwg.logicalexpression.Visitor#visitImplication(Implication)
103      */
104     public void visitImplication(Implication expr) {
105         expr.getLeftOperand().accept(this);
106         expr.getRightOperand().accept(this);
107     }
108 
109     /**
110      * @param expr Binary with operator EQUIVALENT
111      * @see org.omwg.logicalexpression.Visitor#visitEquivalence(Equivalence)
112      */
113     public void visitEquivalence(Equivalence expr) {
114         expr.getLeftOperand().accept(this);
115         expr.getRightOperand().accept(this);
116     }
117 
118     /**
119      * @param expr Binary with operator IMPLIESLP
120      * @see org.omwg.logicalexpression.Visitor#visitLogicProgrammingRule(LogicProgrammingRule)
121      */
122     public void visitLogicProgrammingRule(LogicProgrammingRule expr) {
123         expr.getLeftOperand().accept(this);
124         expr.getRightOperand().accept(this);
125     }
126 
127     /**
128      * @param expr Quantified with operator FORALL
129      * @see org.omwg.logicalexpression.Visitor#visitUniversalQuantification(UniversalQuantification)
130      */
131     public void visitUniversalQuantification(UniversalQuantification expr) {
132         expr.getOperand().accept(this);
133     }
134 
135     /**
136      * @param expr Quantified with operator EXISTS
137      * @see org.omwg.logicalexpression.Visitor#visitExistentialQuantification(ExistentialQuantification)
138      */
139     public void visitExistentialQuantification(ExistentialQuantification expr) {
140         expr.getOperand().accept(this);
141     }
142 }