Coverage report

  %line %branch
org.apache.jetspeed.portalsite.menu.StandardBackMenuDefinition
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.portalsite.menu;
 18  
 
 19  
 import java.util.Locale;
 20  
 import java.util.MissingResourceException;
 21  
 import java.util.ResourceBundle;
 22  
 
 23  
 import org.apache.jetspeed.om.folder.Folder;
 24  
 import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
 25  
 import org.apache.jetspeed.portalsite.view.SiteView;
 26  
 
 27  
 /**
 28  
  * This class provides a menu definition for the standard
 29  
  * back menu.
 30  
  * 
 31  
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
 32  
  * @version $Id: StandardBackMenuDefinition.java 516448 2007-03-09 16:25:47Z ate $
 33  
  */
 34  
 public class StandardBackMenuDefinition extends StandardMenuDefinitionImpl
 35  
 {
 36  
     /**
 37  
      * StandardBackMenuDefinition - constructor
 38  
      */
 39  
     public StandardBackMenuDefinition()
 40  
     {
 41  0
         super();
 42  0
     }
 43  
 
 44  
     /**
 45  
      * getName - get menu name
 46  
      *
 47  
      * @return menu name
 48  
      */
 49  
     public String getName()
 50  
     {
 51  0
         return SiteView.STANDARD_BACK_MENU_NAME;
 52  
     }
 53  
 
 54  
     /**
 55  
      * getOptions - get comma separated menu options if not specified as elements
 56  
      *
 57  
      * @return option paths specification
 58  
      */
 59  
     public String getOptions()
 60  
     {
 61  
         // parent folder
 62  0
         return ".." + Folder.PATH_SEPARATOR;
 63  
     }
 64  
 
 65  
     /**
 66  
      * getSkin - get skin name for menu element
 67  
      *
 68  
      * @return skin name
 69  
      */
 70  
     public String getSkin()
 71  
     {
 72  0
         return "breadcrumbs";
 73  
     }
 74  
 
 75  
     /**
 76  
      * getTitle - get default title for menu
 77  
      *
 78  
      * @return title text
 79  
      */
 80  
     public String getTitle()
 81  
     {
 82  
         // use locale defaults
 83  0
         return getMenuTitleText(null, getTitleResourceKey());
 84  
     }
 85  
 
 86  
     /**
 87  
      * getTitle - get locale specific title for menu from metadata
 88  
      *            protocol, with or without falback enabled
 89  
      *
 90  
      * @param locale preferred locale
 91  
      * @param fallback whether to return default title
 92  
      * @return title text
 93  
      */
 94  
     protected String getTitle(Locale locale, boolean fallback)
 95  
     {
 96  
         // use specified locale or fallback if locale specific title not defined
 97  0
         String title = getMenuTitleText(locale, getTitleResourceKey());
 98  0
         if (title != null)
 99  
         {
 100  0
             return title;
 101  
         }
 102  0
         return super.getTitle(locale, fallback);
 103  
     }
 104  
 
 105  
     /**
 106  
      * getTitleResourceKey - get resource key used to lookup menu titles
 107  
      *
 108  
      * @return resource key
 109  
      */
 110  
     protected String getTitleResourceKey()
 111  
     {
 112  0
         return "menu.title.back";
 113  
     }
 114  
 
 115  
     /**
 116  
      * getMenuTitleText - lookup resource bundle based on locale
 117  
      *                    and use to extract menu title text
 118  
      *
 119  
      * @param locale preferred locale
 120  
      * @param key message key for text
 121  
      */
 122  
     protected String getMenuTitleText(Locale locale, String key)
 123  
     {
 124  
         try
 125  
         {
 126  
             // get resource bundle
 127  0
             ResourceBundle bundle = null;
 128  0
             if (locale != null)
 129  
             {
 130  0
                 bundle = ResourceBundle.getBundle("org.apache.jetspeed.portalsite.menu.resources.MenuTitles",locale);
 131  
             }
 132  
             else
 133  
             {
 134  0
                 bundle = ResourceBundle.getBundle("org.apache.jetspeed.portalsite.menu.resources.MenuTitles");
 135  
             }
 136  
             
 137  
             // lookup and return keyed message
 138  0
             return bundle.getString(key);
 139  
         }
 140  0
         catch (MissingResourceException mre)
 141  
         {
 142  
         }
 143  0
         return null;
 144  
     }
 145  
 }

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