Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 151   Methods: 2
NCLOC: 84   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeOntology.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 org.omwg.ontology.*;
 31    import org.w3c.dom.*;
 32    import org.wsmo.common.*;
 33    import org.wsmo.common.exception.*;
 34    import org.wsmo.wsml.*;
 35   
 36    import com.ontotext.wsmo4j.serializer.xml.*;
 37   
 38    /**
 39    * Helper type to serialize/deserialize xml element ontology
 40    *
 41    * @author not attributable
 42    */
 43    class NodeOntology {
 44   
 45  0 static Ontology deserialize(Node xmlNode, WsmlXmlParser parser) throws InvalidModelException,
 46    ParserException {
 47  0 if (parser == null || xmlNode == null || xmlNode.getNodeName() != "ontology") {
 48  0 throw new IllegalArgumentException();
 49    }
 50   
 51  0 IRI iri = parser.getFactory().createIRI(WsmlXmlHelper.getAttrValue(xmlNode, "name"));
 52  0 Ontology ontology = parser.getFactory().createOntology(iri);
 53  0 NodeTopEntity.processTopEntityNode(ontology, xmlNode, parser);
 54   
 55  0 NodeList nodes = xmlNode.getChildNodes();
 56  0 for (int i = 0; i < nodes.getLength(); i++) {
 57  0 Node node = nodes.item(i);
 58  0 if (node.getNodeName() == "nonFunctionalProperties") {
 59  0 NodeNFP.deserialize(ontology, node, parser);
 60    }
 61  0 else if (node.getNodeName() == "concept") {
 62  0 ontology.addConcept(NodeConcept.deserialize(node, parser));
 63    }
 64  0 else if (node.getNodeName() == "relation") {
 65  0 ontology.addRelation(NodeRelation.deserialize(node, parser));
 66    }
 67  0 else if (node.getNodeName() == "instance") {
 68  0 ontology.addInstance(NodeInstance.deserialize(node, parser));
 69    }
 70  0 else if (node.getNodeName() == "relationInstance") {
 71  0 ontology.addRelationInstance(NodeRelationInstance.deserialize(node, parser));
 72    }
 73  0 else if (node.getNodeName() == "axiom") {
 74  0 ontology.addAxiom(NodeLogExp.deserialize(node, parser));
 75    }
 76    }
 77   
 78  0 return ontology;
 79    }
 80   
 81  0 static Element serialize(Ontology ontology, WsmlXmlSerializer serializer) {
 82  0 Element ontologyElement = serializer.createElement("ontology");
 83  0 ontologyElement.setAttribute("name", ontology.getIdentifier().toString());
 84  0 NodeTopEntity.serializeTopEntity(ontologyElement, ontology, serializer);
 85   
 86  0 if (!ontology.listNFPValues().isEmpty()) {
 87  0 NodeNFP.serialize(ontologyElement, ontology, serializer);
 88    }
 89   
 90  0 if (!ontology.listConcepts().isEmpty()) {
 91  0 Object[] concepts = ontology.listConcepts().toArray();
 92  0 for (int i = 0; i < concepts.length; i++) {
 93  0 ontologyElement.appendChild(NodeConcept
 94    .serialize((Concept) concepts[i], serializer));
 95    }
 96    }
 97   
 98  0 if (!ontology.listInstances().isEmpty()) {
 99  0 Object[] instances = ontology.listInstances().toArray();
 100  0 for (int i = 0; i < instances.length; i++) {
 101  0 ontologyElement.appendChild(NodeInstance.serialize((Instance) instances[i],
 102    serializer));
 103    }
 104    }
 105   
 106  0 if (!ontology.listRelations().isEmpty()) {
 107  0 Object[] relations = ontology.listRelations().toArray();
 108  0 for (int i = 0; i < relations.length; i++)
 109  0 ontologyElement.appendChild(NodeRelation.serialize((Relation) relations[i],
 110    serializer));
 111    }
 112   
 113  0 if (!ontology.listRelationInstances().isEmpty()) {
 114  0 Object[] relationInstances = ontology.listRelationInstances().toArray();
 115  0 for (int i = 0; i < relationInstances.length; i++) {
 116  0 ontologyElement.appendChild(NodeRelationInstance.serialize(
 117    (RelationInstance) relationInstances[i], serializer));
 118    }
 119    }
 120   
 121  0 if (!ontology.listAxioms().isEmpty()) {
 122  0 Object[] axioms = ontology.listAxioms().toArray();
 123  0 for (int i = 0; i < axioms.length; i++) {
 124  0 ontologyElement.appendChild(
 125    NodeLogExp.serialize("axiom", (Axiom) axioms[i], serializer));
 126    }
 127    }
 128   
 129  0 return ontologyElement;
 130    }
 131    }
 132   
 133    /*
 134    * $Log$
 135    * Revision 1.2 2006/03/29 11:20:51 vassil_momtchev
 136    * mediator support added; some code refactored; minor bugs fixed
 137    *
 138    * Revision 1.1 2005/11/28 14:03:48 vassil_momtchev
 139    * package refactored from com.ontotext.wsmo4j.xmlparser to com.ontotext.wsmo4j.parser.xml
 140    *
 141    * Revision 1.5 2005/09/16 14:02:45 alex_simov
 142    * Identifier.asString() removed, use Object.toString() instead
 143    * (Implementations MUST override toString())
 144    *
 145    * Revision 1.4 2005/08/31 09:24:22 vassil_momtchev
 146    * add InvalidModelException and ParserException to LogicalExpressionFactory::createLogixExpression methods
 147    *
 148    * Revision 1.3 2005/08/08 08:24:40 vassil_momtchev
 149    * javadoc added, bugfixes
 150    *
 151    */