Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 137   Methods: 2
NCLOC: 73   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeRelationInstance.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   
 37    import com.ontotext.wsmo4j.serializer.xml.*;
 38   
 39    /**
 40    * Helper type to serialize/deserialize xml element relation instance
 41    *
 42    * @author not attributable
 43    */
 44    class NodeRelationInstance {
 45  0 static RelationInstance deserialize(Node xmlNode, WsmlXmlParser parser)
 46    throws InvalidModelException {
 47  0 if (xmlNode == null || parser == null || xmlNode.getNodeName() != "relationInstance"
 48    || xmlNode.getNodeType() != Node.ELEMENT_NODE) {
 49  0 throw new IllegalArgumentException();
 50    }
 51   
 52  0 Identifier relInstanceId = null;
 53  0 RelationInstance relInstance = null;
 54  0 if (xmlNode.getAttributes().getNamedItem("name") == null)
 55  0 relInstanceId = parser.getFactory().createAnonymousID();
 56    else {
 57  0 relInstanceId = parser.getFactory().createIRI(
 58    WsmlXmlHelper.getAttrValue(xmlNode, "name"));
 59    }
 60   
 61  0 NodeList nodes = xmlNode.getChildNodes();
 62  0 byte paramArity = 0;
 63  0 for (int i = 0; i < nodes.getLength(); i++) {
 64  0 Node node = nodes.item(i);
 65  0 if (node.getNodeName() == "memberOf" && node.getNodeType() == Node.ELEMENT_NODE) {
 66  0 Identifier relationId = null;
 67  0 if (WsmlXmlHelper.getElementText(node).equals("_#"))
 68  0 relationId = parser.getFactory().createAnonymousID();
 69    else
 70  0 relationId = parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node));
 71  0 relInstance = parser.getFactory().createRelationInstance(relInstanceId,
 72    parser.getFactory().getRelation(relationId));
 73    }
 74  0 else if (node.getNodeName() == "nonFunctionalProperties"
 75    && node.getNodeType() == Node.ELEMENT_NODE) {
 76  0 NodeNFP.deserialize(relInstance, node, parser);
 77    }
 78  0 else if (node.getNodeName() == "parameterValue"
 79    && node.getNodeType() == Node.ELEMENT_NODE) {
 80  0 NodeList childNodes = node.getChildNodes();
 81  0 for (int j = 0; j < childNodes.getLength(); j++) {
 82  0 Node childNode = childNodes.item(j);
 83  0 if (childNode.getNodeName() == "value") {
 84  0 relInstance.setParameterValue(paramArity,
 85    NodeValue.deserialize(childNode, parser));
 86    }
 87    }
 88    }
 89    }
 90   
 91  0 return relInstance;
 92    }
 93   
 94  0 static Element serialize(RelationInstance relInstance, WsmlXmlSerializer serializer) {
 95  0 Element relInstanceElement = serializer.createElement("relationInstance");
 96   
 97  0 if (!relInstance.listNFPValues().isEmpty()) {
 98  0 NodeNFP.serialize(relInstanceElement, relInstance, serializer);
 99    }
 100   
 101  0 if (relInstance.getRelation() != null) {
 102  0 Element memberOfElement = serializer.createElement("memberOf");
 103  0 memberOfElement.appendChild(serializer.createTextNode(
 104    relInstance.getIdentifier().toString()));
 105  0 relInstanceElement.appendChild(memberOfElement);
 106    }
 107   
 108  0 if (!relInstance.listParameterValues().isEmpty()) {
 109  0 Element parameterElement = serializer.createElement("parameterValue");
 110  0 for (Iterator i = relInstance.listParameterValues().iterator(); i.hasNext();) {
 111  0 parameterElement.appendChild(NodeValue.serialize(i.next(), serializer));
 112    }
 113    }
 114   
 115  0 return relInstanceElement;
 116    }
 117    }
 118   
 119    /*
 120    * $Log$
 121    * Revision 1.2 2006/03/29 11:20:51 vassil_momtchev
 122    * mediator support added; some code refactored; minor bugs fixed
 123    *
 124    * Revision 1.1 2005/11/28 14:03:48 vassil_momtchev
 125    * package refactored from com.ontotext.wsmo4j.xmlparser to com.ontotext.wsmo4j.parser.xml
 126    *
 127    * Revision 1.5 2005/09/16 14:02:45 alex_simov
 128    * Identifier.asString() removed, use Object.toString() instead
 129    * (Implementations MUST override toString())
 130    *
 131    * Revision 1.4 2005/09/13 09:01:22 vassil_momtchev
 132    * use WsmoFactory.createRelationInstance(Identifier, Relation) instead of WsmoFactory.createRelationInstance(Identifier) RelationInstance.setRelation(Relation)
 133    *
 134    * Revision 1.3 2005/08/08 08:24:40 vassil_momtchev
 135    * javadoc added, bugfixes
 136    *
 137    */