|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| GetRootUtil.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 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.logicalexpression.util; | |
| 17 | ||
| 18 | import java.util.Vector; | |
| 19 | ||
| 20 | import org.deri.wsmo4j.validator.WsmlDLValidator; | |
| 21 | import org.omwg.logicalexpression.LogicalExpression; | |
| 22 | import org.omwg.ontology.Variable; | |
| 23 | import org.wsmo.factory.Factory; | |
| 24 | import org.wsmo.validator.ValidationError; | |
| 25 | import org.wsmo.validator.ValidationWarning; | |
| 26 | ||
| 27 | /** | |
| 28 | * Utility class to extract the root/s variable/s from a WSML-DL | |
| 29 | * logical expression. | |
| 30 | * | |
| 31 | * <pre> | |
| 32 | * Created on Sep 27, 2006 | |
| 33 | * Committed by $Author: morcen $ | |
| 34 | * $Source$, | |
| 35 | * </pre> | |
| 36 | * | |
| 37 | * @author Nathalie Steinmetz, DERI Innsbruck | |
| 38 | * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $ | |
| 39 | */ | |
| 40 | public class GetRootUtil { | |
| 41 | ||
| 42 | 0 | public GetRootUtil() { |
| 43 | ||
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Validates a given formula and gets the root variable if it is a valid | |
| 48 | * WSML-DL formula. | |
| 49 | * | |
| 50 | * @param logExpr | |
| 51 | * @return root Variable or null, if there is no root variable or if the | |
| 52 | * formula is not valid WSML-DL | |
| 53 | */ | |
| 54 | 0 | public Variable getRootVariable(LogicalExpression logExpr) { |
| 55 | 0 | WsmlDLValidator validator = new WsmlDLValidator( |
| 56 | Factory.createLogicalExpressionFactory(null)); | |
| 57 | 0 | boolean valid = validator.isValid(logExpr, new Vector <ValidationError>(), new Vector <ValidationWarning>()); |
| 58 | 0 | if (valid) { |
| 59 | 0 | return validator.getRootVariable(logExpr); |
| 60 | } | |
| 61 | else { | |
| 62 | 0 | return null; |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | } | |
| 67 | /* | |
| 68 | * $Log$ | |
| 69 | * Revision 1.3 2007/04/02 12:13:23 morcen | |
| 70 | * Generics support added to wsmo-api, wsmo4j and wsmo-test | |
| 71 | * | |
| 72 | * Revision 1.2 2006/09/28 14:45:10 nathaliest | |
| 73 | * *** empty log message *** | |
| 74 | * | |
| 75 | * Revision 1.1 2006/09/28 13:11:34 nathaliest | |
| 76 | * added utility method to geet root variable of valid WSML-DL formula and added corresponding tests | |
| 77 | * | |
| 78 | * | |
| 79 | */ |
|
||||||||||