Coverage report

  %line %branch
org.apache.jetspeed.om.impl.SecurityRoleRefImpl
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  
 package org.apache.jetspeed.om.impl;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.util.ArrayList;
 21  
 import java.util.Collection;
 22  
 import java.util.Locale;
 23  
 
 24  
 import org.apache.jetspeed.om.common.MutableDescription;
 25  
 import org.apache.jetspeed.om.common.SecurityRoleRefComposite;
 26  
 import org.apache.jetspeed.util.HashCodeBuilder;
 27  
 import org.apache.jetspeed.util.JetspeedLocale;
 28  
 import org.apache.pluto.om.common.Description;
 29  
 import org.apache.pluto.om.common.DescriptionSet;
 30  
 import org.apache.pluto.om.common.SecurityRoleRef;
 31  
 
 32  
 /**
 33  
  * 
 34  
  * SecurityRoleRefImpl
 35  
  * 
 36  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
 37  
  * @version $Id: SecurityRoleRefImpl.java 517124 2007-03-12 08:10:25Z ate $
 38  
  *
 39  
  */
 40  0
 public class SecurityRoleRefImpl implements SecurityRoleRefComposite, Serializable
 41  
 {
 42  
 
 43  
     protected long id;
 44  
     protected long portletId;
 45  
     private String link;
 46  
     private String name;
 47  
     private Collection descriptions;
 48  0
     private DescriptionSetImpl descCollWrapper = new DescriptionSetImpl(DescriptionImpl.TYPE_SEC_ROLE_REF);
 49  
 
 50  
     /**
 51  
      * @see org.apache.pluto.om.common.SecurityRoleRef#getRoleLink()
 52  
      */
 53  
     public String getRoleLink()
 54  
     {
 55  0
         return link;
 56  
     }
 57  
 
 58  
     /**
 59  
      * @see org.apache.pluto.om.common.SecurityRoleRef#getRoleName()
 60  
      */
 61  
     public String getRoleName()
 62  
     {
 63  0
         return name;
 64  
     }
 65  
 
 66  
     /**
 67  
      * @see org.apache.pluto.om.common.SecurityRoleRefCtrl#setRoleLink(java.lang.String)
 68  
      */
 69  
     public void setRoleLink(String value)
 70  
     {
 71  0
         this.link = value;
 72  0
     }
 73  
 
 74  
     /**
 75  
      * @see org.apache.pluto.om.common.SecurityRoleRefCtrl#setRoleName(java.lang.String)
 76  
      */
 77  
     public void setRoleName(String name)
 78  
     {
 79  0
         this.name = name;
 80  0
     }
 81  
 
 82  
     /**
 83  
      * @see java.lang.Object#equals(java.lang.Object)
 84  
      */
 85  
     public boolean equals(Object obj)
 86  
     {
 87  0
         if (obj != null && obj instanceof SecurityRoleRef)
 88  
         {
 89  0
             SecurityRoleRef aRef = (SecurityRoleRef) obj;
 90  
             //TODO: Because of a bug in OJB 1.0.rc4 fields seems not have been set
 91  
             //      before this object is put into a HashMap.
 92  
             //      Therefore, for the time being, check against null values is
 93  
             //      required.
 94  
             //      Once 1.0rc5 or higher can be used the following line should be
 95  
             //      used again.
 96  
             //return this.getRoleName().equals(aRef.getRoleName());
 97  0
             return getRoleName() != null && getRoleName().equals(aRef.getRoleName());
 98  
         }
 99  
 
 100  0
         return false;
 101  
     }
 102  
 
 103  
     /**
 104  
      * @see java.lang.Object#hashCode()
 105  
      */
 106  
     public int hashCode()
 107  
     {
 108  
 
 109  0
         HashCodeBuilder hasher = new HashCodeBuilder(21, 81);
 110  0
         hasher.append(name);
 111  0
         return hasher.toHashCode();
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see org.apache.pluto.om.common.SecurityRoleRef#getDescription(java.util.Locale)
 116  
      */
 117  
     public Description getDescription(Locale arg0)
 118  
     {
 119  0
         if (descriptions != null)
 120  
         {
 121  0
             descCollWrapper.setInnerCollection(descriptions);
 122  0
             return descCollWrapper.get(arg0);
 123  
         }
 124  0
         return null;
 125  
     }
 126  
 
 127  
     /**
 128  
      * @see org.apache.jetspeed.om.common.SecurityRoleRefComposite#addDescription(org.apache.pluto.om.common.Description)
 129  
      */
 130  
     public void addDescription(Description description)
 131  
     {
 132  0
         if (descriptions == null)
 133  
         {
 134  0
             descriptions = new ArrayList();
 135  
         }
 136  0
         descCollWrapper.setInnerCollection(descriptions);
 137  0
         descCollWrapper.addDescription(description);
 138  0
     }
 139  
     
 140  
     /**
 141  
      * @see org.apache.jetspeed.om.common.MutableDescriptionSet#addDescription(java.util.Locale, java.lang.String)
 142  
      */
 143  
     public void addDescription(Locale locale, String description)
 144  
     {
 145  0
         SecurityRoleRefDescriptionImpl descImpl = new SecurityRoleRefDescriptionImpl();
 146  0
         descImpl.setDescription(description);
 147  0
         descImpl.setLocale(locale);
 148  
         
 149  0
         addDescription(descImpl);
 150  0
     }
 151  
 
 152  
     /**
 153  
      * @see org.apache.jetspeed.om.common.SecurityRoleRefComposite#setDescriptionSet(org.apache.pluto.om.common.DescriptionSet)
 154  
      */
 155  
     public void setDescriptionSet(DescriptionSet descriptions)
 156  
     {
 157  0
         this.descriptions = ((DescriptionSetImpl) descriptions).getInnerCollection();
 158  
 
 159  0
     }
 160  
 
 161  
     /**
 162  
      * We should be using one of the more locale-specific methods.
 163  
      * 
 164  
      * 
 165  
      * @see org.apache.pluto.om.common.SecurityRoleRefCtrl#setDescription(java.lang.String)
 166  
      * @param arg0
 167  
      */
 168  
     public void setDescription(String arg0)
 169  
     {
 170  0
         MutableDescription descObj =new SecurityRoleRefDescriptionImpl();
 171  
             
 172  
         
 173  0
         descObj.setLocale(JetspeedLocale.getDefaultLocale());
 174  0
         descObj.setDescription(arg0);
 175  0
         addDescription(descObj);
 176  0
     }
 177  
 
 178  
     /**
 179  
      * @see org.apache.jetspeed.om.common.SecurityRoleRefComposite#getDescriptionSet()
 180  
      */
 181  
     public DescriptionSet getDescriptionSet()
 182  
     {
 183  0
         if (descriptions != null)
 184  
         {
 185  0
             descCollWrapper.setInnerCollection(descriptions);
 186  
         }         
 187  0
         return descCollWrapper;
 188  
     }
 189  
 }

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