Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 143   Methods: 2
NCLOC: 83   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeMediator.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.w3c.dom.*;
 33    import org.wsmo.common.*;
 34    import org.wsmo.common.exception.*;
 35    import org.wsmo.mediator.*;
 36   
 37    import com.ontotext.wsmo4j.serializer.xml.*;
 38   
 39    /**
 40    * Helper type to serialize/deserialize xml element mediator
 41    *
 42    * @author not attributable
 43    */
 44    class NodeMediator {
 45  0 static TopEntity processMediatorNode(Node xmlNode, WsmlXmlParser parser)
 46    throws InvalidModelException {
 47  0 if (xmlNode == null || parser == null || !xmlNode.getNodeName().endsWith("Mediator")
 48    || xmlNode.getNodeType() != Element.ELEMENT_NODE) {
 49  0 throw new IllegalArgumentException();
 50    }
 51   
 52  0 Mediator mediator = null;
 53  0 IRI mediatorIri = parser.getFactory()
 54    .createIRI(WsmlXmlHelper.getAttrValue(xmlNode, "name"));
 55  0 if (xmlNode.getNodeName().startsWith("oo")) {
 56  0 mediator = parser.getFactory().createOOMediator(mediatorIri);
 57    }
 58  0 else if (xmlNode.getNodeName().startsWith("gg")) {
 59  0 mediator = parser.getFactory().createGGMediator(mediatorIri);
 60    }
 61  0 else if (xmlNode.getNodeName().startsWith("wg")) {
 62  0 mediator = parser.getFactory().createWGMediator(mediatorIri);
 63    }
 64  0 else if (xmlNode.getNodeName().startsWith("ww")) {
 65  0 mediator = parser.getFactory().createWWMediator(mediatorIri);
 66    }
 67    else {
 68  0 throw new IllegalArgumentException(); // should never happens if
 69    // schema valid
 70    }
 71   
 72  0 NodeTopEntity.processTopEntityNode(mediator, xmlNode, parser);
 73  0 NodeList nodes = xmlNode.getChildNodes();
 74  0 for (int i = 0; i < nodes.getLength(); i++) {
 75  0 Node node = nodes.item(i);
 76  0 if (node.getNodeName() == "nonFunctionalProperties") {
 77  0 NodeNFP.deserialize(mediator, node, parser);
 78    }
 79  0 else if (node.getNodeName() == "source") {
 80  0 mediator.addSource(parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node)));
 81    }
 82  0 else if (node.getNodeName() == "target") {
 83  0 mediator.setTarget(parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node)));
 84    }
 85  0 else if (node.getNodeName() == "usesService") {
 86  0 mediator.setMediationService(parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node)));
 87    }
 88    }
 89   
 90  0 return mediator;
 91    }
 92   
 93  0 static void serializeMediator(Element parent, Mediator mediator, WsmlXmlSerializer serializer) {
 94  0 Element mediatorElement = null;
 95  0 if (mediator instanceof OOMediator)
 96  0 mediatorElement = serializer.createElement("ooMediator");
 97  0 else if (mediator instanceof GGMediator)
 98  0 mediatorElement = serializer.createElement("ggMediator");
 99  0 else if (mediator instanceof WGMediator)
 100  0 mediatorElement = serializer.createElement("wgMediator");
 101  0 else if (mediator instanceof WWMediator)
 102  0 mediatorElement = serializer.createElement("wwMediator");
 103    else
 104  0 throw new IllegalArgumentException("Invalid mediator type!");
 105  0 mediatorElement.setAttribute("name", mediator.getIdentifier().toString());
 106  0 parent.appendChild(mediatorElement);
 107  0 NodeTopEntity.serializeTopEntity(mediatorElement, mediator, serializer);
 108   
 109  0 if (!mediator.listNFPValues().isEmpty()) {
 110  0 NodeNFP.serialize(mediatorElement, mediator, serializer);
 111    }
 112   
 113  0 if (mediator.getTarget() != null) {
 114  0 Element target = serializer.createElement("target");
 115  0 mediatorElement.appendChild(target);
 116  0 target.appendChild(serializer.createTextNode(mediator.getIdentifier().toString()));
 117    }
 118   
 119  0 if (mediator.listSources().size() > 0) {
 120  0 for (Iterator i = mediator.listSources().iterator(); i.hasNext();) {
 121  0 Element source = serializer.createElement("source");
 122  0 mediatorElement.appendChild(source);
 123  0 source.appendChild(serializer.createTextNode(((IRI) i.next()).toString()));
 124    }
 125    }
 126    }
 127    }
 128   
 129    /*
 130    * $Log$
 131    * Revision 1.3 2007/04/04 08:37:59 alex_simov
 132    * The serializer is enabled for all types of topentities
 133    *
 134    * Revision 1.2 2006/03/29 11:20:51 vassil_momtchev
 135    * mediator support added; some code refactored; minor bugs fixed
 136    *
 137    * Revision 1.1 2005/11/28 14:03:48 vassil_momtchev
 138    * package refactored from com.ontotext.wsmo4j.xmlparser to com.ontotext.wsmo4j.parser.xml
 139    *
 140    * Revision 1.2 2005/08/08 08:24:40 vassil_momtchev
 141    * javadoc added, bugfixes
 142    *
 143    */