Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 151   Methods: 11
NCLOC: 82   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FunctionSymbolHelper.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.validator;
 17   
 18    import java.util.Iterator;
 19    import java.util.List;
 20   
 21    import org.deri.wsmo4j.io.serializer.wsml.LogExprSerializerWSML;
 22    import org.deri.wsmo4j.logicalexpression.AbstractVisitor;
 23    import org.omwg.logicalexpression.Atom;
 24    import org.omwg.logicalexpression.AttributeConstraintMolecule;
 25    import org.omwg.logicalexpression.AttributeInferenceMolecule;
 26    import org.omwg.logicalexpression.AttributeValueMolecule;
 27    import org.omwg.logicalexpression.CompoundMolecule;
 28    import org.omwg.logicalexpression.LogicalExpression;
 29    import org.omwg.logicalexpression.MembershipMolecule;
 30    import org.omwg.logicalexpression.Molecule;
 31    import org.omwg.logicalexpression.SubConceptMolecule;
 32    import org.omwg.logicalexpression.terms.BuiltInConstructedTerm;
 33    import org.omwg.logicalexpression.terms.ConstructedTerm;
 34    import org.omwg.logicalexpression.terms.Term;
 35    import org.omwg.ontology.Axiom;
 36    import org.wsmo.validator.ValidationError;
 37   
 38    /**
 39    * The FunctionSymbolHelper checks Atoms and Molecules for unallowed
 40    * function symbols.
 41    *
 42    * <pre>
 43    * Created on Okt 28, 2005
 44    * Committed by $Author: morcen $
 45    * $Source$,
 46    * </pre>
 47    *
 48    * @author nathalie.steinmetz@deri.org
 49    *
 50    * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
 51    */
 52    public class FunctionSymbolHelper extends AbstractVisitor{
 53   
 54    private Axiom axiom = null;
 55   
 56    private List <ValidationError> errors = null;
 57   
 58    private String variant = null;
 59   
 60    private LogExprSerializerWSML leSerializer = null;
 61   
 62   
 63  0 protected FunctionSymbolHelper(Axiom axiom, List <ValidationError> errors, String variant, WsmlFullValidator validator) {
 64  0 leSerializer = validator.leSerializer;
 65  0 this.axiom = axiom;
 66  0 this.errors = errors;
 67  0 this.variant = variant;
 68    }
 69   
 70  0 public void visitAtom(Atom expr) {
 71  0 Iterator it = expr.listParameters().iterator();
 72  0 while (it.hasNext()) {
 73  0 Term t = (Term) it.next();
 74  0 if (t instanceof ConstructedTerm && !(t instanceof BuiltInConstructedTerm)) {
 75  0 addError(expr, ValidationErrorImpl.AX_ATOMIC_ERR + ": function symbols are not " +
 76    "allowed\n" + leSerializer.serialize(expr));
 77    }
 78    }
 79    }
 80   
 81  0 public void visitAttributeContraintMolecule(AttributeConstraintMolecule expr) {
 82  0 checkTerm(expr.getRightParameter(),expr);
 83  0 checkTerm(expr.getLeftParameter(), expr);
 84  0 checkTerm(expr.getAttribute(), expr);
 85    }
 86   
 87  0 public void visitAttributeInferenceMolecule(AttributeInferenceMolecule expr) {
 88  0 checkTerm(expr.getRightParameter(),expr);
 89  0 checkTerm(expr.getLeftParameter(), expr);
 90  0 checkTerm(expr.getAttribute(), expr);
 91    }
 92   
 93  0 public void visitAttributeValueMolecule(AttributeValueMolecule expr) {
 94  0 checkTerm(expr.getRightParameter(),expr);
 95  0 checkTerm(expr.getLeftParameter(), expr);
 96  0 checkTerm(expr.getAttribute(), expr);
 97    }
 98   
 99  0 public void visitCompoundMolecule(CompoundMolecule expr) {
 100  0 Iterator it = expr.listOperands().iterator();
 101  0 while(it.hasNext()){
 102  0 ((Molecule)it.next()).accept(this);
 103    }
 104    }
 105   
 106  0 public void visitMemberShipMolecule(MembershipMolecule expr) {
 107  0 checkTerm(expr.getRightParameter(),expr);
 108  0 checkTerm(expr.getLeftParameter(), expr);
 109    }
 110   
 111  0 public void visitSubConceptMolecule(SubConceptMolecule expr) {
 112  0 checkTerm(expr.getRightParameter(), expr);
 113  0 checkTerm(expr.getLeftParameter(), expr);
 114    }
 115   
 116  0 private void checkTerm(Term t, LogicalExpression expr){
 117  0 if (t instanceof ConstructedTerm && !(t instanceof BuiltInConstructedTerm)) {
 118  0 addError(expr, ValidationErrorImpl.AX_ATOMIC_ERR + ": function symbols are not " +
 119    "allowed\n" + leSerializer.serialize(expr));
 120    }
 121    }
 122   
 123    /**
 124    * @return List of collected errors
 125    */
 126  0 public List getErrors() {
 127  0 return errors;
 128    }
 129   
 130   
 131  0 private void addError(LogicalExpression logexp, String msg) {
 132  0 errors.add(new LogicalExpressionErrorImpl(axiom, logexp, msg, variant));
 133    }
 134    }
 135   
 136    /*
 137    * $Log$
 138    * Revision 1.4 2007/04/02 12:13:19 morcen
 139    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 140    *
 141    * Revision 1.3 2005/11/15 16:56:09 nathaliest
 142    * changed access at ValidationError
 143    *
 144    * Revision 1.2 2005/10/31 07:59:10 holgerlausen
 145    * corrected function symbol check
 146    *
 147    * Revision 1.1 2005/10/28 17:19:55 nathaliest
 148    * new helper file
 149    *
 150    *
 151    */