Coverage report

  %line %branch
org.apache.jetspeed.om.impl.DescriptionSetImpl
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.Iterator;
 23  
 import java.util.Locale;
 24  
 
 25  
 import org.apache.jetspeed.om.common.MutableDescriptionSet;
 26  
 import org.apache.jetspeed.util.JetspeedLocale;
 27  
 import org.apache.pluto.om.common.Description;
 28  
 
 29  
 /**
 30  
  * BaseDescriptionSet
 31  
  * 
 32  
  * Supports 
 33  
  * 
 34  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
 35  
  * @version $Id: DescriptionSetImpl.java 516448 2007-03-09 16:25:47Z ate $
 36  
  *
 37  
  */
 38  
 public class DescriptionSetImpl  implements MutableDescriptionSet, Serializable
 39  
 {
 40  
     /** Specifies the type Description we are storing */
 41  
     protected String descriptionType;
 42  
     protected Collection innerCollection;
 43  
 
 44  
     /**
 45  
      * 
 46  
      */
 47  
     public DescriptionSetImpl()
 48  
     {
 49  0
         super();
 50  0
 		this.innerCollection = new ArrayList();        
 51  0
     }
 52  
 
 53  
     /**
 54  
      * @param c
 55  
      */
 56  
     public DescriptionSetImpl(Collection c)
 57  0
     {
 58  0
         this.innerCollection = c;  
 59  0
     }
 60  
 
 61  
 
 62  
 
 63  
 
 64  
     public DescriptionSetImpl(String descriptionType)
 65  
     {
 66  0
         super();
 67  0
         this.descriptionType = descriptionType;
 68  0
         this.innerCollection = new ArrayList();
 69  0
     }
 70  
 
 71  
     /**
 72  
      * @see org.apache.pluto.om.common.DescriptionSet#get(java.util.Locale)
 73  
      */
 74  
     public Description get(Locale arg0)
 75  
     {
 76  0
         if (arg0 == null)
 77  
         {
 78  0
             throw new IllegalArgumentException("The Locale argument cannot be null");
 79  
         }
 80  
 
 81  
         // TODO: This may cause concurrent modification exceptions
 82  0
         Iterator itr = iterator();
 83  0
         Description fallBack = null;
 84  0
         while (itr.hasNext())
 85  
         {
 86  0
             Description desc = (Description) itr.next();
 87  0
             if (desc.getLocale().equals(arg0))
 88  
             {
 89  0
                 return desc;
 90  
             }
 91  
             // set fall back if we have a Locale that only has
 92  
             // language set.
 93  0
             else if (desc.getLocale().getLanguage().equals(arg0.getLanguage()))
 94  
             {
 95  0
                 fallBack = desc;
 96  
             }
 97  0
             else if (fallBack == null && desc.getLocale().equals(JetspeedLocale.getDefaultLocale()))
 98  
             {
 99  0
                 fallBack = desc;
 100  
             }
 101  0
         }
 102  0
         return fallBack;
 103  
     }
 104  
 
 105  
     /**
 106  
      * @see org.apache.jetspeed.om.common.MutableDescriptionSet#addDescription(java.lang.String)
 107  
      */
 108  
     public void addDescription(Description description)
 109  
     {        
 110  0
         innerCollection.add(description);
 111  0
     }
 112  
 
 113  
     /**
 114  
      * @see org.apache.pluto.om.common.DescriptionSet#iterator()
 115  
      */
 116  
     public Iterator iterator()
 117  
     {        
 118  0
         return innerCollection.iterator();
 119  
     }
 120  
 
 121  
     /**
 122  
      * @return
 123  
      */
 124  
     public Collection getInnerCollection()
 125  
     {
 126  0
         return innerCollection;
 127  
     }
 128  
 
 129  
     /**
 130  
      * @param collection
 131  
      */
 132  
     public void setInnerCollection(Collection collection)
 133  
     {
 134  0
         innerCollection = collection;
 135  0
     }
 136  
 
 137  
 }

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