|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ExpressionContainmentUtil.java | - | 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 | ||
19 | import org.omwg.logicalexpression.*; | |
20 | ||
21 | ||
22 | /** | |
23 | * Utility to check if a specific operator is included in a logical expression. | |
24 | * | |
25 | * <pre> | |
26 | * Created on Aug 2, 2005 | |
27 | * Committed by $Author: marin_dimitrov $ | |
28 | * </pre> | |
29 | * | |
30 | * @author Holger Lausen (holger.lausen@deri.org) | |
31 | * | |
32 | * @version $Revision: 896 $ $Date: 2005-09-09 18:51:42 +0300 (Fri, 09 Sep 2005) $ | |
33 | */ | |
34 | public class ExpressionContainmentUtil { | |
35 | ||
36 | /** | |
37 | * Checks if a specific operator is contained within a logical expression. | |
38 | * @param logexp logical expression that will be checked | |
39 | * @param operator operator that will be checked for (e.g. CompoundExpression.AND) | |
40 | * @return true if an compound expression with specified operator is contained. | |
41 | */ | |
42 | 0 | public static boolean contains(LogicalExpression logexp, Class operator) { |
43 | 0 | return contains(logexp, new Class[] {operator}); |
44 | } | |
45 | ||
46 | /** | |
47 | * Checks if a specific operator is contained within a logical expression. | |
48 | * @param logexp logical expression that will be checked | |
49 | * @param operators array of operators that will be checked for | |
50 | * (e.g. new int[] {CompoundExpression.AND,CompoundExpression.OR) | |
51 | * @return true if an compound expression with specified operator is contained. | |
52 | */ | |
53 | 0 | public static boolean contains(LogicalExpression logexp, Class[] operators) { |
54 | 0 | VisitorContainsCheck vCC = new VisitorContainsCheck(operators); |
55 | 0 | logexp.accept(vCC); |
56 | 0 | return vCC.isContained(); |
57 | } | |
58 | ||
59 | } |
|