View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3   
4    Copyright (c) 2004-2005, OntoText Lab. / SIRMA
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 com.ontotext.wsmo4j.ontology;
20  
21  /**
22   * <p>Title: WSMO4J</p>
23   * <p>Description: WSMO API and a Reference Implementation</p>
24   * <p>Copyright:  Copyright (c) 2004-2005</p>
25   * <p>Company: OntoText Lab. / SIRMA </p>
26   * @author not attributable
27   * @version 1.0
28   *
29   */
30  
31  import java.util.Collections;
32  import java.util.LinkedHashSet;
33  import java.util.Set;
34  
35  import org.omwg.ontology.Parameter;
36  import org.omwg.ontology.Relation;
37  import org.omwg.ontology.Type;
38  import org.wsmo.common.exception.InvalidModelException;
39  import org.wsmo.common.exception.SynchronisationException;
40  
41  
42  public class ParameterImpl implements Parameter {
43  
44      private Relation domain;
45      
46      private LinkedHashSet <Type> ranges;
47      
48      private boolean constraining = false; /* RFE 1249611 */
49  
50      public ParameterImpl(Relation domain) {
51  
52          assert null != domain;
53          this.domain = domain;
54          ranges = new LinkedHashSet <Type>();
55      }
56  
57      public Relation getRelation() throws SynchronisationException {
58          return domain;
59      }
60  
61      public void addType(Type type) throws InvalidModelException {
62          if (type == null) {
63              throw new IllegalArgumentException();
64          }
65          ranges.add(type);
66      }
67  
68      public void removeType(Type type) {
69          if (type == null) {
70              throw new IllegalArgumentException();
71          }
72          ranges.remove(type);
73      }
74  
75      public Set <Type> listTypes() {
76          return Collections.unmodifiableSet(ranges);
77      }
78  
79      public boolean isConstraining() {
80          return constraining;
81      }
82  
83      public void setConstraining(boolean constraining) {
84          this.constraining = constraining;
85      }
86  
87      public boolean equals(Object object) {
88          if (object == this) {
89              return true; // instance match
90          }
91  
92          return false;
93      }
94      
95  }
96  
97  /*
98   * $Log$
99   * Revision 1.22  2007/04/02 12:13:21  morcen
100  * Generics support added to wsmo-api, wsmo4j and wsmo-test
101  *
102  * Revision 1.21  2006/03/23 16:12:13  nathaliest
103  * moving the anon Id check to the validator
104  *
105  * Revision 1.20  2006/02/13 22:49:22  nathaliest
106  * - changed concept.createAttribute() and Parameter.addType to throw InvalidModelException.
107  * - small change at check AnonIds in ConceptImpl
108  *
109  * Revision 1.19  2006/02/13 11:49:58  nathaliest
110  * changed anonId-check error String
111  *
112  * Revision 1.18  2006/02/13 09:21:21  nathaliest
113  * added AnonIds Check
114  *
115  * Revision 1.17  2005/12/06 13:03:03  vassil_momtchev
116  * to be equal two parameters they need to have same relations, same ranges and same position as well. only instance match could be evaluated without to introduce a position method in Parameter interface
117  *
118  * Revision 1.16  2005/08/31 09:17:30  vassil_momtchev
119  * use Type and Value instead of Object where appropriate bug SF[1276677]
120  *
121  * Revision 1.15  2005/08/08 09:26:56  marin_dimitrov
122  * constraining=false by default (RFE 1249611)
123  *
124  * Revision 1.14  2005/06/01 12:09:33  marin_dimitrov
125  * v0.4.0
126  *
127  * Revision 1.2  2005/05/17 12:04:57  alex
128  * Collections.unmodifiableSet() used instead of new set construction
129  *
130  * Revision 1.1  2005/05/12 08:21:03  alex
131  * initial commit
132  *
133  */