Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 175   Methods: 2
NCLOC: 98   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeCapability.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    package com.ontotext.wsmo4j.parser.xml;
 19   
 20    /**
 21    * <p>Title: WSMO4J</p>
 22    * <p>Description: WSMO API and a Reference Implementation</p>
 23    * <p>Copyright: Copyright (c) 2004-2005</p>
 24    * <p>Company: OntoText Lab. / SIRMA </p>
 25    * @author not attributable
 26    * @version 1.0
 27    *
 28    */
 29   
 30    import java.util.*;
 31   
 32    import org.omwg.ontology.*;
 33    import org.w3c.dom.*;
 34    import org.wsmo.common.*;
 35    import org.wsmo.common.exception.*;
 36    import org.wsmo.service.*;
 37    import org.wsmo.wsml.*;
 38   
 39    import com.ontotext.wsmo4j.serializer.xml.*;
 40   
 41    /**
 42    * Helper type to serialize/deserialize xml element capability
 43    *
 44    * @author not attributable
 45    */
 46    class NodeCapability {
 47  0 static Capability deserialize(Node xmlNode, WsmlXmlParser parser)
 48    throws InvalidModelException, ParserException {
 49  0 if (xmlNode == null || parser == null || xmlNode.getNodeName() != "capability") {
 50  0 throw new IllegalArgumentException();
 51    }
 52   
 53  0 IRI iriCapability = parser.getFactory().createIRI(
 54    WsmlXmlHelper.getAttrValue(xmlNode, "name"));
 55  0 Capability capability = parser.getFactory().createCapability(iriCapability);
 56  0 NodeTopEntity.processTopEntityNode(capability, xmlNode, parser);
 57   
 58  0 NodeList nodes = xmlNode.getChildNodes();
 59  0 for (int i = 0; i < nodes.getLength(); i++) {
 60  0 Node node = nodes.item(i);
 61   
 62  0 if (node.getNodeName() == "nonFunctionalProperties"
 63    && node.getNodeType() == Node.ELEMENT_NODE) {
 64  0 NodeNFP.deserialize(capability, node, parser);
 65    }
 66  0 else if (node.getNodeName() == "sharedVariable" && node.getNodeType() == Node.ELEMENT_NODE) {
 67  0 NodeList childNodes = node.getChildNodes();
 68  0 for (int j = 0; j < childNodes.getLength(); j++) {
 69  0 Node childNode = childNodes.item(j);
 70  0 if (childNode.getNodeName() == "variable") {
 71  0 capability.addSharedVariable(
 72    parser.getLEFactory().createVariable(
 73    WsmlXmlHelper.getElementText(node)));
 74    }
 75    }
 76    }
 77  0 else if (node.getNodeName() == "precondition") {
 78  0 capability.addPreCondition(NodeLogExp.deserialize(node, parser));
 79    }
 80  0 else if (node.getNodeName() == "assumption") {
 81  0 capability.addAssumption(NodeLogExp.deserialize(node, parser));
 82    }
 83  0 else if (node.getNodeName() == "postcondition") {
 84  0 capability.addPostCondition(NodeLogExp.deserialize(node, parser));
 85    }
 86  0 else if (node.getNodeName() == "effect") {
 87  0 capability.addEffect(NodeLogExp.deserialize(node, parser));
 88    }
 89    }
 90   
 91  0 return capability;
 92    }
 93   
 94  0 static Element serialize(Capability capability, WsmlXmlSerializer serializer) {
 95  0 Element capabilityElement = serializer.createElement("capability");
 96  0 NodeTopEntity.serializeTopEntity(capabilityElement, capability, serializer);
 97   
 98  0 if (!capability.listNFPValues().isEmpty()) {
 99  0 NodeNFP.serialize(capabilityElement, capability, serializer);
 100    }
 101   
 102  0 if (!capability.listSharedVariables().isEmpty()) {
 103  0 Element sharedVarElement = serializer.createElement("sharedVariable");
 104  0 capabilityElement.appendChild(sharedVarElement);
 105  0 for (Iterator i = capability.listSharedVariables().iterator(); i.hasNext();) {
 106  0 Variable var = (Variable) i.next();
 107  0 Element variableElement = serializer.createElement("variable");
 108  0 variableElement.appendChild(serializer.createTextNode("?" + var.getName()));
 109    }
 110    }
 111   
 112  0 if (!capability.listPreConditions().isEmpty()) {
 113  0 for (Iterator i = capability.listPreConditions().iterator(); i.hasNext();) {
 114  0 Axiom axiom = (Axiom) i.next();
 115  0 capabilityElement.appendChild(serializer.createElement("precondition").appendChild(
 116    NodeLogExp.serialize("precondition", axiom, serializer)));
 117    }
 118    }
 119   
 120  0 if (!capability.listAssumptions().isEmpty()) {
 121  0 for (Iterator i = capability.listPreConditions().iterator(); i.hasNext();) {
 122  0 Axiom axiom = (Axiom) i.next();
 123  0 capabilityElement.appendChild(serializer.createElement("assumption").appendChild(
 124    NodeLogExp.serialize("assumption", axiom, serializer)));
 125    }
 126    }
 127   
 128  0 if (!capability.listPostConditions().isEmpty()) {
 129  0 for (Iterator i = capability.listPostConditions().iterator(); i.hasNext();) {
 130  0 Axiom axiom = (Axiom) i.next();
 131  0 capabilityElement.appendChild(serializer.createElement("postcondition").appendChild(
 132    NodeLogExp.serialize("postcondition", axiom, serializer)));
 133    }
 134    }
 135   
 136  0 if (!capability.listEffects().isEmpty()) {
 137  0 for (Iterator i = capability.listEffects().iterator(); i.hasNext();) {
 138  0 Axiom axiom = (Axiom) i.next();
 139  0 capabilityElement.appendChild(serializer.createElement("effect").appendChild(
 140    NodeLogExp.serialize("effect", axiom, serializer)));
 141    }
 142    }
 143   
 144  0 return capabilityElement;
 145    }
 146    }
 147   
 148    /*
 149    * $Log$
 150    * Revision 1.3 2006/06/21 07:46:29 vassil_momtchev
 151    * createVariable(String) method moved from WsmoFactory to LogicalExpressionFactory interface
 152    *
 153    * Revision 1.2 2006/03/29 11:20:51 vassil_momtchev
 154    * mediator support added; some code refactored; minor bugs fixed
 155    *
 156    * Revision 1.1 2005/11/28 14:03:48 vassil_momtchev
 157    * package refactored from com.ontotext.wsmo4j.xmlparser to com.ontotext.wsmo4j.parser.xml
 158    *
 159    * Revision 1.8 2005/09/16 14:02:45 alex_simov
 160    * Identifier.asString() removed, use Object.toString() instead
 161    * (Implementations MUST override toString())
 162    *
 163    * Revision 1.7 2005/08/31 09:24:22 vassil_momtchev
 164    * add InvalidModelException and ParserException to LogicalExpressionFactory::createLogixExpression methods
 165    *
 166    * Revision 1.6 2005/08/31 09:04:42 alex_simov
 167    * fix: Variable objects must be created only by the WsmoFactory
 168    *
 169    * Revision 1.5 2005/08/31 08:36:14 alex_simov
 170    * bugfix: Variable.getName() now returns the name without leading '?'
 171    *
 172    * Revision 1.4 2005/08/08 08:24:40 vassil_momtchev
 173    * javadoc added, bugfixes
 174    *
 175    */