Coverage Report - org.deri.wsmo4j.rule.MoleculeFactRI
 
Classes in this File Line Coverage Branch Coverage Complexity
MoleculeFactRI
0%
0/41
0%
0/20
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.rule;
 20  
 
 21  
 import java.util.*;
 22  
 
 23  
 import org.deri.wsmo4j.io.serializer.wsml.VisitorSerializeWSMLTransitionRules;
 24  
 import org.omwg.logicalexpression.*;
 25  
 import org.wsmo.common.TopEntity;
 26  
 import org.wsmo.service.rule.*;
 27  
 
 28  
 /**
 29  
  * Interface or class description
 30  
  *
 31  
  * @author James Scicluna
 32  
  * @author Thomas Haselwanter
 33  
  *
 34  
  * Created on 02-Feb-2006
 35  
  * Committed by $Author: vassil_momtchev $
 36  
  *
 37  
  * $Source$,
 38  
  * @version $Revision: 1844 $ $Date: 2006-10-24 17:11:48 +0300 (Tue, 24 Oct 2006) $
 39  
  */
 40  
 
 41  
 public class MoleculeFactRI implements MoleculeFact {
 42  
 
 43  0
     private Set<MembershipMolecule> memberMolecules = new LinkedHashSet<MembershipMolecule>();
 44  0
     private Set<AttributeValueMolecule> attrValues = new LinkedHashSet<AttributeValueMolecule>();
 45  
 
 46  
     /**
 47  
      * Default constructor for a moleucle fact.
 48  
      */
 49  
     public MoleculeFactRI() {
 50  0
         super();
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Constructor for a Molecule Fact. This method accepts also null
 55  
      * values within its parameters. Null values are interpreted as having
 56  
      * an empty set of molecules.
 57  
      * 
 58  
      * @param memberMolecules Set of MembershipMolecule objects
 59  
      * @param attrValues Set of AttributeValueMolecule objects
 60  
      */
 61  0
     public MoleculeFactRI(Set<MembershipMolecule> memberMolecules, Set<AttributeValueMolecule> attrValues) {
 62  0
         if(memberMolecules != null) this.memberMolecules = memberMolecules;
 63  0
         if(attrValues != null) this.attrValues = attrValues;
 64  0
     }
 65  
     
 66  
     /**
 67  
      * Constructor for a Molecule Fact. Similar to the second constructor,
 68  
      * this method accepts also null values
 69  
      * 
 70  
      * @param memberMolecule A MembershipMolecule object
 71  
      * @param attrValues Set of AttributeValueMolecule objects
 72  
      */
 73  0
     public MoleculeFactRI(MembershipMolecule memberMolecule, Set<AttributeValueMolecule> attrValues){
 74  0
         if(memberMolecule != null){
 75  0
             this.memberMolecules.add(memberMolecule);
 76  
         }
 77  0
         if(attrValues != null) this.attrValues = attrValues;
 78  0
     }
 79  
     
 80  
     /**
 81  
      * Constructor for a Molecule Fact. Similar to the second constructor,
 82  
      * this method accepts also null values
 83  
      * 
 84  
      * @param memberMolecules Set of MembershipMolecule objects
 85  
      * @param attrValue An AttributeValueMolecule object
 86  
      */
 87  0
     public MoleculeFactRI(Set<MembershipMolecule> memberMolecules, AttributeValueMolecule attrValue) {
 88  0
         if(memberMolecules != null) this.memberMolecules = memberMolecules;
 89  0
         if(attrValue != null) this.attrValues.add(attrValue);
 90  0
     }
 91  
     
 92  
     /**
 93  
      * Constructor for a Molecule Fact. Similar to the second constructor,
 94  
      * this method accepts also null values
 95  
      * 
 96  
      * @param memberMolecule A MembershipMolecule object
 97  
      * @param attrValue An AttributeValueMolecule object
 98  
      */
 99  0
     public MoleculeFactRI(MembershipMolecule memberMolecule, AttributeValueMolecule attrValue){
 100  0
         if(memberMolecule != null) this.memberMolecules.add(memberMolecule);
 101  0
         if(attrValue != null) this.attrValues.add(attrValue);
 102  0
     }
 103  
     
 104  
 
 105  
     /* (non-Javadoc)
 106  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#getMembershipMolecule()
 107  
      */
 108  
     public Set<MembershipMolecule> listMembershipMolecules() {
 109  0
         return Collections.unmodifiableSet(this.memberMolecules);
 110  
     }
 111  
 
 112  
     /* (non-Javadoc)
 113  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#getAttributeValueMolecules()
 114  
      */
 115  
     public Set<AttributeValueMolecule> listAttributeValueMolecules() {
 116  0
         return Collections.unmodifiableSet(this.attrValues);
 117  
     }
 118  
 
 119  
     /*
 120  
      * (non-Javadoc)
 121  
      * 
 122  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#setMembershipMolecule(org.omwg.logicalexpression.MembershipMolecule)
 123  
      */
 124  
     public void addMembershipMolecule(MembershipMolecule memberMolecule) {
 125  0
         this.memberMolecules.add(memberMolecule);
 126  0
     }
 127  
     
 128  
     /* (non-Javadoc)
 129  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#removeMembershipMolecule(org.omwg.logicalexpression.MembershipMolecule)
 130  
      */
 131  
     public void removeMembershipMolecule(MembershipMolecule memberMolecule) {
 132  0
         this.memberMolecules.remove(memberMolecule);
 133  0
     }
 134  
 
 135  
     /*
 136  
      * (non-Javadoc)
 137  
      * 
 138  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#setAttributeValueMolecules(java.util.Set)
 139  
      */
 140  
     public void addAttributeValueMolecule(AttributeValueMolecule attrValue) {
 141  0
         this.attrValues.add(attrValue);
 142  0
     }
 143  
     
 144  
     /* (non-Javadoc)
 145  
      * @see org.wsmo.service.choreography.rule.MoleculeFact#removeAttributeValueMolecule(org.omwg.logicalexpression.AttributeValueMolecule)
 146  
      */
 147  
     public void removeAttributeValueMolecule(AttributeValueMolecule attrValue) {
 148  0
         this.attrValues.remove(attrValue);
 149  0
     }
 150  
     
 151  
     /* (non-Javadoc)
 152  
      * @see org.wsmo.service.choreography.rule.CompoundFact#isEmpty()
 153  
      */
 154  
     public boolean isEmpty() {
 155  0
         if (attrValues.size() == 0 && memberMolecules.size() == 0) {
 156  0
             return true;
 157  
         }
 158  0
         return false;
 159  
     }
 160  
 
 161  
     @Override
 162  
     public String toString() {
 163  0
         return toString(null);
 164  
     }
 165  
 
 166  
     public String toString(TopEntity nsHolder) {
 167  0
         VisitorSerializeWSMLTransitionRules serializer = 
 168  
             new VisitorSerializeWSMLTransitionRules(nsHolder);
 169  0
         return serializer.helpCompoundFact(this, null);
 170  
     }
 171  
     
 172  
     public Iterator<AtomicExpression> iterator() {       
 173  0
         LinkedList<AtomicExpression> list = new LinkedList<AtomicExpression>();
 174  0
         list.addAll(attrValues);
 175  0
         list.addAll(memberMolecules);
 176  0
         return list.iterator();
 177  
     }
 178  
 
 179  
 }
 180  
 
 181  
 /*
 182  
  * $Log$
 183  
  * Revision 1.1  2006/10/24 14:11:48  vassil_momtchev
 184  
  * choreography/orchestration rules refactored. different types where appropriate now supported
 185  
  *
 186  
  * Revision 1.6  2006/04/17 07:51:39  vassil_momtchev
 187  
  * public Iterator<AtomicExpression> iterator() method added
 188  
  *
 189  
  * Revision 1.5  2006/02/15 16:44:34  alex_simov
 190  
  * toString(TopEntity) method implemented
 191  
  *
 192  
  * Revision 1.4  2006/02/15 15:55:28  alex_simov
 193  
  * serializer visitor used in toString() to produce valid wsml data
 194  
  *
 195  
  * Revision 1.3  2006/02/10 15:31:03  vassil_momtchev
 196  
  * implementation changed according the api change
 197  
  *
 198  
 */