| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractTransitionRuleRI |
|
| 0.0;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.wsmo.service.choreography.rule.ChoreographyTransitionRule; | |
| 27 | import org.wsmo.service.rule.*; | |
| 28 | ||
| 29 | /** | |
| 30 | * Implements common functionality for a Transition Rule. | |
| 31 | * | |
| 32 | * <pre> | |
| 33 | * Created on Jul 26, 2005 | |
| 34 | * Committed by $Author: vassil_momtchev $ | |
| 35 | * $Source$ | |
| 36 | * </pre> | |
| 37 | * | |
| 38 | * @author Thomas Haselwanter | |
| 39 | * @author James Scicluna | |
| 40 | * | |
| 41 | * @version $Revision: 1844 $ $Date: 2006-10-24 17:11:48 +0300 (Tue, 24 Oct 2006) $ | |
| 42 | */ | |
| 43 | public abstract class AbstractTransitionRuleRI implements ChoreographyTransitionRule { | |
| 44 | ||
| 45 | protected Condition condition; | |
| 46 | ||
| 47 | /** | |
| 48 | * @uml.property name="rules" | |
| 49 | * @uml.associationEnd multiplicity="(0 -1)" elementType="org.wsmo.service.rule.ChoreographyRule" | |
| 50 | */ | |
| 51 | 0 | protected Set<ChoreographyRule> rules = new HashSet<ChoreographyRule>(); |
| 52 | ||
| 53 | /** | |
| 54 | * Default constructor for Abstract Transition Rules | |
| 55 | */ | |
| 56 | public AbstractTransitionRuleRI() { | |
| 57 | 0 | super(); |
| 58 | 0 | } |
| 59 | ||
| 60 | /* | |
| 61 | * (non-Javadoc) | |
| 62 | * | |
| 63 | * @see org.wsmo.service.choreography.rule.TransitionRule#getCondition() | |
| 64 | */ | |
| 65 | public Condition getCondition() { | |
| 66 | 0 | return this.condition; |
| 67 | } | |
| 68 | ||
| 69 | /* (non-Javadoc) | |
| 70 | * @see org.wsmo.service.choreography.rule.TransitionRule#setCondition(org.wsmo.service.choreography.rule.Condition) | |
| 71 | */ | |
| 72 | public void setCondition(Condition condition) { | |
| 73 | 0 | this.condition = condition; |
| 74 | 0 | } |
| 75 | ||
| 76 | /* | |
| 77 | * (non-Javadoc) | |
| 78 | * | |
| 79 | * @see org.wsmo.service.choreography.rule.TransitionRule#listNestedRules() | |
| 80 | */ | |
| 81 | public Set<ChoreographyRule> listNestedRules() { | |
| 82 | 0 | return Collections.unmodifiableSet(rules); |
| 83 | } | |
| 84 | ||
| 85 | /* | |
| 86 | * (non-Javadoc) | |
| 87 | * | |
| 88 | * @see org.wsmo.service.choreography.rule.TransitionRule#clearNestedRules() | |
| 89 | */ | |
| 90 | public void clearNestedRules() { | |
| 91 | 0 | this.rules.clear(); |
| 92 | 0 | } |
| 93 | ||
| 94 | /* | |
| 95 | * (non-Javadoc) | |
| 96 | * | |
| 97 | * @see org.wsmo.service.choreography.rule.TransitionRule#add(org.wsmo.service.choreography.rule.Rule) | |
| 98 | */ | |
| 99 | public void addRule(ChoreographyRule rule) { | |
| 100 | 0 | if (rule != null) |
| 101 | 0 | rules.add(rule); |
| 102 | 0 | } |
| 103 | ||
| 104 | /* | |
| 105 | * (non-Javadoc) | |
| 106 | * | |
| 107 | * @see org.wsmo.service.choreography.rule.TransitionRule#add(java.util.Set) | |
| 108 | */ | |
| 109 | public void addRules(Set<ChoreographyRule> rules) { | |
| 110 | 0 | if (rules != null) |
| 111 | 0 | rules.addAll(rules); |
| 112 | 0 | } |
| 113 | ||
| 114 | /* | |
| 115 | * (non-Javadoc) | |
| 116 | * | |
| 117 | * @see org.wsmo.service.choreography.rule.TransitionRule#removeRule(org.wsmo.service.choreography.rule.Rule) | |
| 118 | */ | |
| 119 | public void removeRule(ChoreographyRule rule) { | |
| 120 | 0 | rules.remove(rule); |
| 121 | 0 | } |
| 122 | ||
| 123 | /* (non-Javadoc) | |
| 124 | * @see org.wsmo.service.choreography.rule.TransitionRule#setRules(java.util.Set) | |
| 125 | */ | |
| 126 | public void setRules(Set<ChoreographyRule> rules) { | |
| 127 | 0 | this.rules = rules; |
| 128 | 0 | } |
| 129 | ||
| 130 | protected String stringInnerRules() { | |
| 131 | 0 | String s = ""; |
| 132 | ChoreographyRule r; | |
| 133 | 0 | Iterator<ChoreographyRule> i = this.rules.iterator(); |
| 134 | 0 | while (i.hasNext()) { |
| 135 | 0 | r = i.next(); |
| 136 | 0 | s += r.toString() + "\n"; |
| 137 | } | |
| 138 | 0 | return s; |
| 139 | } | |
| 140 | } |