Coverage Report - org.deri.wsmo4j.choreography.rule.AbstractQuantifiedRuleRI
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractQuantifiedRuleRI
0%
0/25
0%
0/8
0
 
 1  
 /*
 2  
  wsmo4j extension - a Choreography API and Reference Implementation
 3  
 
 4  
  Copyright (c) 2005, University of Innsbruck, Austria
 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  
 
 19  
 package org.deri.wsmo4j.choreography.rule;
 20  
 
 21  
 import java.util.Collections;
 22  
 import java.util.HashSet;
 23  
 import java.util.Iterator;
 24  
 import java.util.Set;
 25  
 
 26  
 import org.omwg.ontology.Variable;
 27  
 import org.wsmo.service.choreography.rule.ChoreographyQuantifiedRule;
 28  
 import org.wsmo.service.rule.*;
 29  
 
 30  
 /**
 31  
  * Provides common implementation methods for the quantified rules (Forall and
 32  
  * Choose).
 33  
  * 
 34  
  * <pre>
 35  
  *     Created on Jul 26, 2005
 36  
  *     Committed by $Author: vassil_momtchev $
 37  
  *     $Source$
 38  
  * </pre>
 39  
  * 
 40  
  * @author Thomas Haselwanter
 41  
  * @author James Scicluna
 42  
  * 
 43  
  * @version $Revision: 1844 $ $Date: 2006-10-24 17:11:48 +0300 (Tue, 24 Oct 2006) $
 44  
  */
 45  
 public abstract class AbstractQuantifiedRuleRI extends AbstractTransitionRuleRI implements
 46  
         ChoreographyQuantifiedRule {
 47  
 
 48  
     protected static <E> Set<E> makeSet(E element) {
 49  0
         Set<E> s = new HashSet<E>();
 50  0
         s.add(element);
 51  0
         return s;
 52  
     }
 53  
 
 54  0
     protected Set<Variable> variables = new HashSet<Variable>();
 55  
 
 56  
     /**
 57  
      * @param variables
 58  
      *            A Set of Quantified Variable objects
 59  
      * @param condition
 60  
      *            Logical Expression defining the condition of the rule
 61  
      * @param rules
 62  
      *            A set of inner Rule objects of the rule
 63  
      */
 64  
     public AbstractQuantifiedRuleRI(Set<Variable> variables, Condition condition, Set<ChoreographyRule> rules) {
 65  0
         super();
 66  0
         this.variables = variables;
 67  0
         this.condition = condition;
 68  0
         this.rules = rules;
 69  0
     }
 70  
 
 71  
     /*
 72  
      * (non-Javadoc)
 73  
      * 
 74  
      * @see org.wsmo.service.choreography.rule.QuantifiedRule#listVariables()
 75  
      */
 76  
     public Set<Variable> listVariables() {
 77  0
         return Collections.unmodifiableSet(variables);
 78  
     }
 79  
 
 80  
     /*
 81  
      * (non-Javadoc)
 82  
      * 
 83  
      * @see org.wsmo.service.choreography.rule.QuantifiedRule#addVariable(org.omwg.ontology.Variable)
 84  
      */
 85  
     public void addVariable(Variable variable) {
 86  0
         if (variable != null)
 87  0
             variables.add(variable);
 88  0
     }
 89  
 
 90  
     /*
 91  
      * (non-Javadoc)
 92  
      * 
 93  
      * @see org.wsmo.service.choreography.rule.QuantifiedRule#addVariable(java.util.Set)
 94  
      */
 95  
     public void addVariables(Set<Variable> variable) {
 96  0
         if (variable != null)
 97  0
             variables.addAll(variable);
 98  0
     }
 99  
 
 100  
     /*
 101  
      * (non-Javadoc)
 102  
      * 
 103  
      * @see org.wsmo.service.choreography.rule.QuantifiedRule#removeVariable(org.omwg.ontology.Variable)
 104  
      */
 105  
     public void removeVariable(Variable variable) {
 106  0
         variables.remove(variable);
 107  0
     }
 108  
 
 109  
     protected String stringVariables() {
 110  0
         String s = "";
 111  0
         Iterator<Variable> i = this.variables.iterator();
 112  0
         while (i.hasNext()) {
 113  0
             s += i.next().toString();
 114  0
             if (i.hasNext())
 115  0
                 s += ",";
 116  
         }
 117  0
         return s;
 118  
     }
 119  
 
 120  
 }