Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 86   Methods: 2
NCLOC: 44   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LogExprParserImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3    Copyright (c) 2005, University of Innsbruck, Austria
 4    This library is free software; you can redistribute it and/or modify it under
 5    the terms of the GNU Lesser General Public License as published by the Free
 6    Software Foundation; either version 2.1 of the License, or (at your option)
 7    any later version.
 8    This library is distributed in the hope that it will be useful, but WITHOUT
 9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 10    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 11    details.
 12    You should have received a copy of the GNU Lesser General Public License along
 13    with this library; if not, write to the Free Software Foundation, Inc.,
 14    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 15    */
 16    package org.deri.wsmo4j.io.parser.xml;
 17   
 18   
 19    import java.util.*;
 20   
 21    import org.w3c.dom.*;
 22    import org.wsmo.factory.*;
 23    import org.wsmo.wsml.*;
 24   
 25   
 26    /**
 27    * <p>This singleton class is used to create a LogicalExpression XML Parser</p>
 28    * <p>The Singleton design pattern allows to ensure that only one instance of a class
 29    * is created, to provide a global point of access to the object and to allow multiple
 30    * instances in the future without affecting a singleton class's clients</p>
 31    * @author retkru
 32    * @see org.omwg.logicalexpression.io.Parser
 33    * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton Pattern</a>
 34    */
 35    public class LogExprParserImpl {
 36   
 37    WsmoFactory factory;
 38    LogicalExpressionFactory leFactory;
 39    DataFactory dataFactory;
 40    XMLExprParser xmlParser;
 41   
 42  0 public LogExprParserImpl(Map map){
 43  0 if (map==null){
 44  0 map = new HashMap();
 45    }
 46  0 Object o = map.get(Factory.WSMO_FACTORY);
 47  0 if (o == null || ! (o instanceof WsmoFactory)) {
 48  0 o = Factory.createWsmoFactory(new HashMap <String, Object> ());
 49    }
 50  0 factory = (WsmoFactory)o;
 51  0 assert (factory != null);
 52   
 53  0 o = map.get(Factory.LE_FACTORY);
 54  0 if (o == null || ! (o instanceof LogicalExpressionFactory)) {
 55  0 o = Factory.createLogicalExpressionFactory(new HashMap <String, Object> ());
 56    }
 57  0 leFactory = (LogicalExpressionFactory)o;
 58  0 assert (leFactory != null);
 59   
 60  0 o = map.get(Factory.DATA_FACTORY);
 61  0 if (o == null || ! (o instanceof DataFactory)) {
 62  0 o = Factory.createDataFactory(new HashMap <String, Object> ());
 63    }
 64  0 dataFactory = (DataFactory)o;
 65  0 assert (dataFactory != null);
 66   
 67  0 xmlParser = new XMLExprParser(factory, leFactory, dataFactory);
 68    }
 69   
 70    /**
 71    * This method parses a XML Node.
 72    * @param node
 73    * XML Element Node that will be parsed
 74    * @return logical expression object model
 75    * @throws IllegalArgumentException in case node is not of Type Node
 76    */
 77  0 public org.omwg.logicalexpression.LogicalExpression parse(Object node)
 78    throws IllegalArgumentException, ParserException {
 79  0 if (node instanceof Node) {
 80  0 Element exprNode = (Element)node;
 81  0 return xmlParser.evaluateXML(exprNode);
 82    }
 83  0 throw new IllegalArgumentException(
 84    "XML Parse Error: LogExprParser.parse requiers object of type org.w3c.dom.Node");
 85    }
 86    }