Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 118   Methods: 3
NCLOC: 65   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NFPAnalysis.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2004-2005, OntoText Lab. / SIRMA
 5   
 6    This library is free software; you can redistribute it and/or modify it under
 7    the terms of the GNU Lesser General Public License as published by the Free
 8    Software Foundation; either version 2.1 of the License, or (at your option)
 9    any later version.
 10    This library is distributed in the hope that it will be useful, but WITHOUT
 11    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 12    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 13    details.
 14    You should have received a copy of the GNU Lesser General Public License along
 15    with this library; if not, write to the Free Software Foundation, Inc.,
 16    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18   
 19    /**
 20    * <p>Title: WSMO4J</p>
 21    * <p>Description: WSMO API and a Reference Implementation</p>
 22    * <p>Copyright: Copyright (c) 2004-2005</p>
 23    * <p>Company: OntoText Lab. / SIRMA </p>
 24    */
 25   
 26    package com.ontotext.wsmo4j.parser.wsml;
 27   
 28    import java.util.*;
 29   
 30    import org.omwg.logicalexpression.terms.*;
 31    import org.omwg.ontology.*;
 32    import org.wsmo.common.*;
 33    import org.wsmo.common.exception.*;
 34    import org.wsmo.wsml.compiler.node.*;
 35   
 36    import com.ontotext.wsmo4j.parser.*;
 37   
 38    public class NFPAnalysis extends ASTAnalysis {
 39   
 40    private Stack termsStack;
 41    private Stack identifierStack;
 42    private Stack entityStack;
 43   
 44  0 public NFPAnalysis(ASTAnalysisContainer container) {
 45  0 if (container == null) {
 46  0 throw new IllegalArgumentException();
 47    }
 48  0 termsStack = container.getStack(Term[].class);
 49  0 identifierStack = container.getStack(Identifier.class);
 50  0 entityStack = container.getStack(Entity.class);
 51   
 52    // register the handled nodes
 53  0 container.registerNodeHandler(ANfp.class, this);
 54  0 container.registerNodeHandler(PNfp.class, this);
 55    }
 56   
 57    private Object rootIdentifier;
 58    private Object rootTerm;
 59   
 60  0 public void inANfp(ANfp node) {
 61    // keep a handle to the stack's last element
 62  0 if (!termsStack.isEmpty())
 63  0 rootTerm = termsStack.peek();
 64    else
 65  0 rootTerm = null;
 66  0 if (!identifierStack.isEmpty())
 67  0 rootIdentifier = identifierStack.peek();
 68    else
 69  0 rootIdentifier = null;
 70    }
 71   
 72  0 public void outANfp(ANfp node) {
 73  0 if (entityStack.isEmpty()) {
 74  0 return; // NFP node outside of known Entity set
 75    }
 76  0 Entity entity = (Entity) entityStack.peek();
 77   
 78  0 try {
 79  0 Term[] terms = null;
 80  0 while (!identifierStack.isEmpty() &&
 81    identifierStack.peek() != rootIdentifier) {
 82   
 83  0 if (termsStack.isEmpty()) {
 84  0 throw new RuntimeException("The NFP term queue is shorter then iri queue!");
 85    }
 86   
 87  0 IRI iri = (IRI) identifierStack.pop();
 88  0 terms = (Term[]) termsStack.pop();
 89   
 90  0 for (int i = 0; i < terms.length; i++) {
 91  0 if (terms[i] instanceof DataValue)
 92  0 entity.addNFPValue(iri, (DataValue) terms[i]);
 93    else // Identifier
 94  0 entity.addNFPValue(iri, (Identifier) terms[i]);
 95    }
 96    }
 97   
 98    // check that the last stack element did not change
 99  0 if (!termsStack.isEmpty() &&
 100    termsStack.peek() != rootTerm) {
 101  0 throw new RuntimeException("The NFP term queue is longer then iri queue!");
 102    }
 103    }
 104    catch (InvalidModelException ime) {
 105  0 throw new WrappedInvalidModelException(ime);
 106    }
 107    }
 108    }
 109   
 110    /*
 111    * $Log$
 112    * Revision 1.2 2006/02/10 14:37:25 vassil_momtchev
 113    * parser addapted to the grammar changes; unused class variables removed;
 114    *
 115    * Revision 1.1 2005/11/28 13:55:26 vassil_momtchev
 116    * AST analyses
 117    *
 118    */