Coverage report

  %line %branch
org.apache.jetspeed.om.impl.ParameterImpl
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  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  
 
 18  
 package org.apache.jetspeed.om.impl;
 19  
 
 20  
 import java.io.Serializable;
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collection;
 23  
 import java.util.Locale;
 24  
 
 25  
 import org.apache.commons.logging.Log;
 26  
 import org.apache.commons.logging.LogFactory;
 27  
 import org.apache.jetspeed.om.common.MutableDescription;
 28  
 import org.apache.jetspeed.om.common.ParameterComposite;
 29  
 import org.apache.jetspeed.util.HashCodeBuilder;
 30  
 import org.apache.jetspeed.util.JetspeedLocale;
 31  
 import org.apache.pluto.om.common.Description;
 32  
 import org.apache.pluto.om.common.DescriptionSet;
 33  
 
 34  
 
 35  
 /**
 36  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
 37  
  */
 38  0
 public class ParameterImpl implements ParameterComposite, Serializable
 39  
 {
 40  
 
 41  
     private String name;
 42  
     private String value;
 43  
     private String description;
 44  
 
 45  
     protected long parameterId;
 46  
 
 47  
     protected long parentId;
 48  
 
 49  
     private Collection descriptions;
 50  0
     private DescriptionSetImpl descCollWrapper = new DescriptionSetImpl(DescriptionImpl.TYPE_PARAMETER);
 51  
     
 52  0
     private static final Log log = LogFactory.getLog(ParameterImpl.class);
 53  
 
 54  
     /**
 55  
      * @see org.apache.pluto.om.common.Parameter#getName()
 56  
      */
 57  
     public String getName()
 58  
     {
 59  0
         return name;
 60  
     }
 61  
 
 62  
     /**
 63  
      * @see org.apache.pluto.om.common.Parameter#getValue()
 64  
      */
 65  
     public String getValue()
 66  
     {
 67  0
         return value;
 68  
     }
 69  
 
 70  
     /**
 71  
      * @see org.apache.pluto.om.common.ParameterCtrl#setName(java.lang.String)
 72  
      */
 73  
     public void setName(String name)
 74  
     {
 75  0
         this.name = name;
 76  
 
 77  0
     }
 78  
 
 79  
     /**
 80  
      * @see org.apache.pluto.om.common.ParameterCtrl#setValue(java.lang.String)
 81  
      */
 82  
     public void setValue(String value)
 83  
     {
 84  0
         this.value = value;
 85  
 
 86  0
     }
 87  
 
 88  
     /**
 89  
      * @see java.lang.Object#equals(java.lang.Object)
 90  
      */
 91  
     public boolean equals(Object obj)
 92  
     {
 93  0
         if (obj != null && obj.getClass().equals(getClass()))
 94  
         {
 95  0
             ParameterImpl p = (ParameterImpl) obj;            
 96  0
             boolean sameParent = (p.parentId == parentId);
 97  0
             boolean sameName  = (name != null && p.getName() != class="keyword">null && name.equals(p.getName()));
 98  0
             return sameParent && sameName;            
 99  
         }
 100  
 
 101  0
         return false;
 102  
 
 103  
     }
 104  
 
 105  
     /**
 106  
      * @see java.lang.Object#hashCode()
 107  
      */
 108  
     public int hashCode()
 109  
     {
 110  0
         HashCodeBuilder hash = new HashCodeBuilder(17, 77);
 111  0
         return hash.append(name).toHashCode();
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see org.apache.pluto.om.common.Parameter#getDescription(java.util.Locale)
 116  
      */
 117  
     public Description getDescription(Locale arg0)
 118  
     {
 119  0
         if (descriptions != null)
 120  
         {
 121  0
             return new DescriptionSetImpl(descriptions).get(arg0);
 122  
         }
 123  0
         return null;
 124  
 
 125  
     }
 126  
 
 127  
     /**
 128  
      * @see org.apache.pluto.om.common.ParameterCtrl#setDescriptionSet(org.apache.pluto.om.common.DescriptionSet)
 129  
      */
 130  
     public void setDescriptionSet(DescriptionSet arg0)
 131  
     {
 132  0
         this.descriptions = ((DescriptionSetImpl) arg0).getInnerCollection();
 133  0
     }
 134  
 
 135  
     /**
 136  
      * @see org.apache.jetspeed.om.common.ParameterComposite#addDescription(java.util.Locale, java.lang.String)
 137  
      */
 138  
     public void addDescription(Locale locale, String desc)
 139  
     {
 140  0
         if (descriptions == null)
 141  
         {
 142  0
 			descriptions = new ArrayList();
 143  
         }
 144  0
         descCollWrapper.setInnerCollection(descriptions);
 145  
         try
 146  
         {
 147  0
             MutableDescription descObj = new ParameterDescriptionImpl();
 148  
                 
 149  0
 			descObj.setLocale(locale);
 150  0
 			descObj.setDescription(desc);
 151  0
 			descCollWrapper.addDescription(descObj);
 152  
         }
 153  0
         catch (Exception e)
 154  
         {
 155  0
             String msg = "Unable to instantiate Description implementor, " + e.toString();
 156  0
             log.error(msg, e);
 157  0
             throw new IllegalStateException(msg);
 158  0
         }
 159  
 
 160  0
     }
 161  
 
 162  
     public void addDescription(Description desc)
 163  
     {
 164  0
         if (descriptions == null)
 165  
         {
 166  0
             descriptions = new ArrayList();
 167  
         }
 168  
 
 169  0
         descCollWrapper.setInnerCollection(descriptions);
 170  0
         descCollWrapper.addDescription(desc);
 171  0
     }
 172  
 
 173  
     /**
 174  
      * Remove when Castor is mapped correctly
 175  
      * 
 176  
      * @deprecated
 177  
      * @param desc
 178  
      */
 179  
     public void setDescription(String desc)
 180  
     {
 181  
 //        System.out.println("Setting description..." + desc);
 182  0
         addDescription(JetspeedLocale.getDefaultLocale(), desc);
 183  
 //        System.out.println("Description Set " + desc);
 184  0
     }
 185  
 
 186  
     /**
 187  
      *  Remove when Castor is mapped correctly
 188  
      * @deprecated
 189  
      * @return
 190  
      */
 191  
     public String getDescription()
 192  
     {
 193  
 
 194  0
         Description desc = getDescription(JetspeedLocale.getDefaultLocale());
 195  
 
 196  0
         if (desc != null)
 197  
         {
 198  0
             return desc.getDescription();
 199  
         }
 200  
 
 201  0
         return null;
 202  
     }
 203  
 
 204  
     /**
 205  
      * @see org.apache.jetspeed.om.common.ParameterComposite#getDescriptionSet()
 206  
      */
 207  
     public DescriptionSet getDescriptionSet()
 208  
     {
 209  0
         if (descriptions != null)
 210  
         {
 211  0
             descCollWrapper.setInnerCollection(descriptions);
 212  
         }        
 213  0
         return descCollWrapper;
 214  
     }
 215  
 
 216  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.