1/**2 *3 * Copyright 2004 The Apache Software Foundation4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17package org.apache.ws.scout.registry.infomodel;
1819import java.util.Collection;
20import java.util.Collections;
21import java.util.HashSet;
2223import javax.xml.registry.JAXRException;
24import javax.xml.registry.infomodel.Slot;
2526/**27 * Implements Jaxr API28 *29 * @author <mailto:anil@apache.org>Anil Saldhana30 * @since Nov 20, 200431 */32publicclassSlotImplimplements Slot
33 {
34private String slotType;
35private String name;
36private Collection<String> values;
3738 @SuppressWarnings("unchecked")
39publicSlotImpl()
40 {
41 values = Collections.EMPTY_SET;
42 }
4344public String getName() throws JAXRException
45 {
46return name;
47 }
4849public String getSlotType() throws JAXRException
50 {
51return slotType;
52 }
5354public Collection<String> getValues() throws JAXRException
55 {
56return values;
57 }
5859publicvoid setName(String s) throws JAXRException
60 {
61 name = s;
62 }
6364publicvoid setSlotType(String s) throws JAXRException
65 {
66 slotType = s;
67 }
6869publicvoid setValues(Collection collection) throws JAXRException
70 {
71if (collection == null)
72 {
73thrownew IllegalArgumentException("values cannot be null");
74 }
75// "the value of a Slot is locally unique within a slot instance"76// to enforce this, convert the supplied Collection to a Set77 values = new HashSet<String>(collection);
78 }
7980/**81 * Slots can be used in Collections but the spec does not define equals()82 * We define two slots with the same name as being equal as the spec says83 * name is unique within the scope of the RegistryObject.84 */85publicboolean equals(Object o)
86 {
87if (this == o) returntrue;
88if (!(o instanceof SlotImpl)) return false;
8990finalSlotImpl../../../../../../org/apache/ws/scout/registry/infomodel/SlotImpl.html#SlotImpl">SlotImpl slot = (SlotImpl) o;
9192if (name != null ? !name.equals(slot.name) : slot.name != null) return false;
9394returntrue;
95 }
9697publicint hashCode()
98 {
99return (name != null ? name.hashCode() : 0);
100 }
101 }
102103