Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 126   Methods: 8
NCLOC: 65   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BinaryImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3    Copyright (c) 2004, DERI Innsbruck
 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 java.util.List;
 20    import java.util.Vector;
 21   
 22    import org.deri.wsmo4j.logicalexpression.util.ExpressionContainmentUtil;
 23    import org.deri.wsmo4j.logicalexpression.util.SetUtil;
 24    import org.omwg.logicalexpression.*;
 25   
 26   
 27    /**
 28    * This class reunites all binary logical expressions
 29    * (e.g LogExpr1 op LogExpr2)
 30    * @author DERI Innsbruck, reto.krummenacher@deri.org
 31    * @author DERI Innsbruck, thomas.haselwanter@deri.org
 32    * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
 33    * @see org.omwg.logicalexpression.Binary
 34    */
 35    public abstract class BinaryImpl extends LogicalExpressionImpl
 36    implements Binary {
 37   
 38    protected LogicalExpression exprLeft;
 39   
 40    protected LogicalExpression exprRight;
 41   
 42    /**
 43    * @param exprLeft the logical expression left of the operator
 44    * @param exprRight the logical expression right of the operator
 45    * @throws IllegalArgumentException
 46    * <p>in case one of the two logical expressions is null
 47    * <p>in case the operator is different from AND, EQUIVALENT, IMPLIEDBY, IMPLIES,
 48    * LP_IMPL or OR</p>
 49    * <p>in case one of the two logical expressions contains a nested CONSTRAINT</p>
 50    */
 51  0 public BinaryImpl(LogicalExpression exprLeft, LogicalExpression exprRight)
 52    throws IllegalArgumentException {
 53  0 if (exprLeft == null || exprRight == null) {
 54  0 throw new IllegalArgumentException("null not allowed for Arguments of Binary operator");
 55    }
 56  0 if (ExpressionContainmentUtil.contains(exprLeft, Constraint.class)
 57    || ExpressionContainmentUtil.contains(exprRight, Constraint.class)) {
 58  0 throw new IllegalArgumentException("Nested Constraint not allowed in Binary Operator");
 59    }
 60  0 this.exprLeft = exprLeft;
 61  0 this.exprRight = exprRight;
 62    }
 63   
 64  0 public LogicalExpression getLeftOperand() {
 65  0 return exprLeft;
 66    }
 67   
 68  0 public LogicalExpression getRightOperand() {
 69  0 return exprRight;
 70    }
 71   
 72    /**
 73    * @see CompoundExpression#listOperands()
 74    */
 75  0 public List <LogicalExpression> listOperands() {
 76  0 Vector <LogicalExpression> ret = new Vector <LogicalExpression>();
 77  0 ret.add(exprLeft);
 78  0 ret.add(exprRight);
 79  0 return ret;
 80    }
 81   
 82  0 public int hashCode() {
 83  0 return exprLeft.hashCode() + exprRight.hashCode();
 84    }
 85   
 86    /* (non-Javadoc)
 87    * @see org.omwg.logicalexpression.Binary#setLeftOperand(org.omwg.logicalexpression.LogicalExpression)
 88    */
 89  0 public void setLeftOperand(LogicalExpression le) {
 90  0 if (le == null) {
 91  0 throw new IllegalArgumentException("null not allowed for Arguments of Binary operator");
 92    }
 93  0 if (ExpressionContainmentUtil.contains(le, Constraint.class)) {
 94  0 throw new IllegalArgumentException("Nested Constraint not allowed in Binary Operator");
 95    }
 96  0 exprLeft = le;
 97   
 98    }
 99   
 100    /* (non-Javadoc)
 101    * @see org.omwg.logicalexpression.Binary#setRightOperand(org.omwg.logicalexpression.LogicalExpression)
 102    */
 103  0 public void setRightOperand(LogicalExpression le) {
 104  0 if (le == null) {
 105  0 throw new IllegalArgumentException("null not allowed for Arguments of Binary operator");
 106    }
 107  0 if (ExpressionContainmentUtil.contains(le, Constraint.class)) {
 108  0 throw new IllegalArgumentException("Nested Constraint not allowed in Binary Operator");
 109    }
 110  0 exprRight = le;
 111    }
 112   
 113    /* (non-Javadoc)
 114    * @see org.omwg.logicalexpression.CompoundExpression#setOperands(java.util.List)
 115    */
 116  0 public void setOperands(List operands) {
 117  0 if (operands.size()!=2){
 118  0 throw new IllegalArgumentException("For a Binary Operator exactly 2 expressions are necessary!");
 119    }
 120  0 if (!SetUtil.allOfType(operands, LogicalExpression.class)){
 121  0 throw new IllegalArgumentException("Operands of a Binary must be Logical Expressions!!");
 122    }
 123  0 setLeftOperand((LogicalExpression)operands.get(0));
 124  0 setRightOperand((LogicalExpression)operands.get(1));
 125    }
 126    }