This project has retired. For details please refer to its Attic page.
Coverage Report
Coverage Report - org.apache.ws.scout.registry.infomodel.SlotImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
SlotImpl
95%
19/20
71%
10/14
2.111
 
 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  20
     {
 41  20
         values = Collections.EMPTY_SET;
 42  20
     }
 43  
 
 44  
     public String getName() throws JAXRException
 45  
     {
 46  4
         return name;
 47  
     }
 48  
 
 49  
     public String getSlotType() throws JAXRException
 50  
     {
 51  4
         return slotType;
 52  
     }
 53  
 
 54  
     public Collection<String> getValues() throws JAXRException
 55  
     {
 56  6
         return values;
 57  
     }
 58  
 
 59  
     public void setName(String s) throws JAXRException
 60  
     {
 61  8
         name = s;
 62  8
     }
 63  
 
 64  
     public void setSlotType(String s) throws JAXRException
 65  
     {
 66  2
         slotType = s;
 67  2
     }
 68  
 
 69  
     public void setValues(Collection collection) throws JAXRException
 70  
     {
 71  4
         if (collection == null)
 72  
         {
 73  2
             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  2
         values = new HashSet<String>(collection);
 78  2
     }
 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  8
         if (this == o) return true;
 88  8
         if (!(o instanceof SlotImpl)) return false;
 89  
 
 90  8
         final SlotImpl slot = (SlotImpl) o;
 91  
 
 92  8
         if (name != null ? !name.equals(slot.name) : slot.name != null) return false;
 93  
 
 94  4
         return true;
 95  
     }
 96  
 
 97  
     public int hashCode()
 98  
     {
 99  0
         return (name != null ? name.hashCode() : 0);
 100  
     }
 101  
 }
 102  
 
 103