This project has retired. For details please refer to its Attic page.
SlotImpl xref
View Javadoc
1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
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 at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  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 and
15   *  limitations under the License.
16   */
17  package org.apache.ws.scout.registry.infomodel;
18  
19  import java.util.Collection;
20  import java.util.Collections;
21  import java.util.HashSet;
22  
23  import javax.xml.registry.JAXRException;
24  import javax.xml.registry.infomodel.Slot;
25  
26  /**
27   * Implements Jaxr API
28   *
29   * @author <mailto:anil@apache.org>Anil Saldhana
30   * @since Nov 20, 2004
31   */
32  public class SlotImpl implements Slot
33  {
34      private String slotType;
35      private String name;
36      private Collection<String> values;
37  
38      @SuppressWarnings("unchecked")
39      public SlotImpl()
40      {
41          values = Collections.EMPTY_SET;
42      }
43  
44      public String getName() throws JAXRException
45      {
46          return name;
47      }
48  
49      public String getSlotType() throws JAXRException
50      {
51          return slotType;
52      }
53  
54      public Collection<String> getValues() throws JAXRException
55      {
56          return values;
57      }
58  
59      public void setName(String s) throws JAXRException
60      {
61          name = s;
62      }
63  
64      public void setSlotType(String s) throws JAXRException
65      {
66          slotType = s;
67      }
68  
69      public void setValues(Collection collection) throws JAXRException
70      {
71          if (collection == null)
72          {
73              throw new 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 Set
77          values = new HashSet<String>(collection);
78      }
79  
80      /**
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 says
83       * name is unique within the scope of the RegistryObject.
84       */
85      public boolean equals(Object o)
86      {
87          if (this == o) return true;
88          if (!(o instanceof SlotImpl)) return false;
89  
90          final SlotImpl../../../../../../org/apache/ws/scout/registry/infomodel/SlotImpl.html#SlotImpl">SlotImpl slot = (SlotImpl) o;
91  
92          if (name != null ? !name.equals(slot.name) : slot.name != null) return false;
93  
94          return true;
95      }
96  
97      public int hashCode()
98      {
99          return (name != null ? name.hashCode() : 0);
100     }
101 }
102 
103