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 /**
20 * <p>Title: WSMO4J</p>
21 * <p>Description: WSMO API and a Reference Implementation</p>
22 * <p>Copyright: Copyright (c) 2004-2005</p>
23 * <p>Company: OntoText Lab. / SIRMA </p>
24 */
25
26 package com.ontotext.wsmo4j.service;
27
28
29 import java.util.*;
30 import org.wsmo.common.*;
31 import org.wsmo.service.*;
32 import com.ontotext.wsmo4j.common.*;
33
34
35 /**
36 * An implementation of ServiceDescroption interface representing a service description
37 * (e.g. a Goal or a WebService).
38 *
39 * @author not attributable
40 * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
41 * @since 0.4.0
42 */
43 public abstract class ServiceDescriptionImpl extends TopEntityImpl
44 implements ServiceDescription {
45
46 private Capability capability;
47 private LinkedHashMap <Identifier, Interface> ifaces;
48
49 public ServiceDescriptionImpl(Identifier id) {
50 super(id);
51 ifaces = new LinkedHashMap <Identifier, Interface> ();
52 }
53
54 /**
55 * Adds a new interface to the list of interfaces of this WebService/Goal.
56 * @param iface The new interface to be added to the list.
57 * @throws org.wsmo.common.exception.SynchronisationException
58 * @throws org.wsmo.common.exception.InvalidModelException
59 */
60 public void addInterface(Interface iface) {
61 if (iface == null) {
62 throw new IllegalArgumentException();
63 }
64 ifaces.put(iface.getIdentifier(), iface);
65 }
66
67 /**
68 * Removes the specified interface from the list of iterfaces of this WebService/Goal.
69 * @param iface The interface to be removed from the list of interfacaes.
70 * @throws org.wsmo.common.exception.SynchronisationException
71 * @throws org.wsmo.common.exception.InvalidModelException
72 */
73 public void removeInterface(Interface iface) {
74 if (iface == null) {
75 throw new IllegalArgumentException();
76 }
77 ifaces.remove(iface.getIdentifier());
78 }
79
80 /**
81 * Removes the specified interface from the list of iterfaces of this WebService/Goal.
82 * @param id The ID of the interface to be removed from the list of interfacaes.
83 * @throws org.wsmo.common.exception.SynchronisationException
84 * @throws org.wsmo.common.exception.InvalidModelException
85 */
86 public void removeInterface(Identifier id) {
87 if (id == null) {
88 throw new IllegalArgumentException();
89 }
90 ifaces.remove(id);
91 }
92
93 /**
94 * Lists the interfaces of this WebService/Goal.
95 * @return A set of the interfaces of this WebService/Goal
96 * @throws org.wsmo.common.exception.SynchronisationException
97 */
98 public Set <Interface> listInterfaces() {
99 return new LinkedHashSet <Interface> (ifaces.values());
100 }
101
102 /**
103 * Returns the capability of this WebService/Goal.
104 * @return The capability associated with this WebService/Goal.
105 * @see #setCapability
106 * @throws org.wsmo.common.exception.SynchronisationException
107 */
108 public Capability getCapability() {
109 return this.capability;
110 }
111
112 /**
113 * Sets the capability of this WebService/Goal.
114 * @param cap The new capability to be associated with this WebService/Goal
115 * @see #getCapability
116 * @throws org.wsmo.common.exception.SynchronisationException
117 * @throws org.wsmo.common.exception.InvalidModelException
118 */
119 public void setCapability(Capability cap) {
120 this.capability = cap;
121 }
122
123 public boolean equals(Object object) {
124 if (object == this) {
125 return true;
126 }
127 if (object == null
128 || false == object instanceof ServiceDescription) {
129 return false;
130 }
131 return super.equals(object);
132 }
133 }
134
135 /*
136 * $Log$
137 * Revision 1.3 2007/04/02 12:13:21 morcen
138 * Generics support added to wsmo-api, wsmo4j and wsmo-test
139 *
140 * Revision 1.2 2005/06/22 09:16:06 alex_simov
141 * Simplified equals() method. Identity strongly relies on identifier string
142 *
143 * Revision 1.1 2005/06/01 12:14:05 marin_dimitrov
144 * v0.4.0
145 *
146 * Revision 1.1 2005/05/13 08:33:29 alex
147 * initial commit
148 *
149 */