Coverage report

  %line %branch
org.apache.commons.jelly.tags.fmt.Config
0% 
0% 

 1  
 /*
 2  
  * Copyright 1999,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.jelly.tags.fmt;
 18  
 
 19  
 import org.apache.commons.jelly.JellyContext;
 20  
 
 21  
 
 22  
 /**
 23  
  * Class supporting access to configuration data.
 24  
  * @author <a href="mailto:willievu@yahoo.com">Willie Vu</a>
 25  
  * @version 1.1
 26  
  */
 27  0
 public class Config {
 28  
 
 29  
     /*
 30  
      * I18N/Formatting actions related configuration data
 31  
      */
 32  
 
 33  
     /**
 34  
      * Name of configuration setting for application- (as opposed to browser-)
 35  
      * based preferred locale
 36  
      */
 37  
     public static final String FMT_LOCALE
 38  
     = "org.apache.commons.jelly.tags.fmt.locale";
 39  
 
 40  
     /**
 41  
      * Name of configuration setting for fallback locale
 42  
      */
 43  
     public static final String FMT_FALLBACK_LOCALE
 44  
     = "org.apache.commons.jelly.tags.fmt.fallbackLocale";
 45  
 
 46  
     /**
 47  
      * Name of configuration setting for i18n localization context
 48  
      */
 49  
     public static final String FMT_LOCALIZATION_CONTEXT
 50  
     = "org.apache.commons.jelly.tags.fmt.localizationContext";
 51  
 
 52  
     /**
 53  
      * Name of localization setting for time zone
 54  
      */
 55  
     public static final String FMT_TIME_ZONE
 56  
     = "org.apache.commons.jelly.tags.fmt.timeZone";
 57  
 
 58  
 
 59  
     /**
 60  
      * Looks up a configuration variable in the given scope.
 61  
      *
 62  
      * <p> The lookup of configuration variables is performed as if each scope
 63  
      * had its own name space, that is, the same configuration variable name
 64  
      * in one scope does not replace one stored in a different scope.
 65  
      *
 66  
      * @param jc Page context in which the configuration variable is to be
 67  
      * looked up
 68  
      * @param name Configuration variable name
 69  
      * @param scope Scope in which the configuration variable is to be looked
 70  
      * up
 71  
      *
 72  
      * @return The <tt>java.lang.Object</tt> associated with the configuration
 73  
      * variable, or null if it is not defined.
 74  
      */
 75  
 //    public static Object get(JellyContext jc, String name, int scope) {
 76  
 //        switch (scope) {
 77  
 //            case JellyContext.PAGE_SCOPE:
 78  
 //                return jc.getAttribute(name + PAGE_SCOPE_SUFFIX, scope);
 79  
 //            case JellyContext.REQUEST_SCOPE:
 80  
 //                return jc.getAttribute(name + REQUEST_SCOPE_SUFFIX, scope);
 81  
 //            case JellyContext.SESSION_SCOPE:
 82  
 //                return jc.getAttribute(name + SESSION_SCOPE_SUFFIX, scope);
 83  
 //            case JellyContext.APPLICATION_SCOPE:
 84  
 //                return jc.getAttribute(name + APPLICATION_SCOPE_SUFFIX, scope);
 85  
 //            default:
 86  
 //                throw new IllegalArgumentException("unknown scope");
 87  
 //        }
 88  
 //    }
 89  
 
 90  
     /**
 91  
      * Looks up a configuration variable in the "request" scope.
 92  
      *
 93  
      * <p> The lookup of configuration variables is performed as if each scope
 94  
      * had its own name space, that is, the same configuration variable name
 95  
      * in one scope does not replace one stored in a different scope.
 96  
      *
 97  
      * @param request Request object in which the configuration variable is to
 98  
      * be looked up
 99  
      * @param name Configuration variable name
 100  
      *
 101  
      * @return The <tt>java.lang.Object</tt> associated with the configuration
 102  
      * variable, or null if it is not defined.
 103  
      */
 104  
 //    public static Object get(ServletRequest request, String name) {
 105  
 //        return request.getAttribute(name + REQUEST_SCOPE_SUFFIX);
 106  
 //    }
 107  
 
 108  
     /**
 109  
      * Looks up a configuration variable in the "session" scope.
 110  
      *
 111  
      * <p> The lookup of configuration variables is performed as if each scope
 112  
      * had its own name space, that is, the same configuration variable name
 113  
      * in one scope does not replace one stored in a different scope.
 114  
      *
 115  
      * @param session Session object in which the configuration variable is to
 116  
      * be looked up
 117  
      * @param name Configuration variable name
 118  
      *
 119  
      * @return The <tt>java.lang.Object</tt> associated with the configuration
 120  
      * variable, or null if it is not defined.
 121  
      */
 122  
 //    public static Object get(HttpSession session, String name) {
 123  
 //        return session.getAttribute(name + SESSION_SCOPE_SUFFIX);
 124  
 //    }
 125  
 
 126  
     /**
 127  
      * Looks up a configuration variable in the "application" scope.
 128  
      *
 129  
      * <p> The lookup of configuration variables is performed as if each scope
 130  
      * had its own name space, that is, the same configuration variable name
 131  
      * in one scope does not replace one stored in a different scope.
 132  
      *
 133  
      * @param context Servlet context in which the configuration variable is
 134  
      * to be looked up
 135  
      * @param name Configuration variable name
 136  
      *
 137  
      * @return The <tt>java.lang.Object</tt> associated with the configuration
 138  
      * variable, or null if it is not defined.
 139  
      */
 140  
 //    public static Object get(ServletContext context, String name) {
 141  
 //        return context.getAttribute(name + APPLICATION_SCOPE_SUFFIX);
 142  
 //    }
 143  
 
 144  
     /**
 145  
      * Sets the value of a configuration variable in the given scope.
 146  
      *
 147  
      * <p> Setting the value of a configuration variable is performed as if
 148  
      * each scope had its own namespace, that is, the same configuration
 149  
      * variable name in one scope does not replace one stored in a different
 150  
      * scope.
 151  
      *
 152  
      * @param jc Page context in which the configuration variable is to be set
 153  
      * @param name Configuration variable name
 154  
      * @param value Configuration variable value
 155  
      * @param scope Scope in which the configuration variable is to be set
 156  
      */
 157  
 //    public static void set(JellyContext jc, String name, Object value,
 158  
 //    int scope) {
 159  
 //        switch (scope) {
 160  
 //            case JellyContext.PAGE_SCOPE:
 161  
 //                jc.setAttribute(name + PAGE_SCOPE_SUFFIX, value, scope);
 162  
 //                break;
 163  
 //            case JellyContext.REQUEST_SCOPE:
 164  
 //                jc.setAttribute(name + REQUEST_SCOPE_SUFFIX, value, scope);
 165  
 //                break;
 166  
 //            case JellyContext.SESSION_SCOPE:
 167  
 //                jc.setAttribute(name + SESSION_SCOPE_SUFFIX, value, scope);
 168  
 //                break;
 169  
 //            case JellyContext.APPLICATION_SCOPE:
 170  
 //                jc.setAttribute(name + APPLICATION_SCOPE_SUFFIX, value, scope);
 171  
 //                break;
 172  
 //            default:
 173  
 //                throw new IllegalArgumentException("unknown scope");
 174  
 //        }
 175  
 //    }
 176  
 
 177  
     /**
 178  
      * Sets the value of a configuration variable in the "request" scope.
 179  
      *
 180  
      * <p> Setting the value of a configuration variable is performed as if
 181  
      * each scope had its own namespace, that is, the same configuration
 182  
      * variable name in one scope does not replace one stored in a different
 183  
      * scope.
 184  
      *
 185  
      * @param request Request object in which the configuration variable is to
 186  
      * be set
 187  
      * @param name Configuration variable name
 188  
      * @param value Configuration variable value
 189  
      */
 190  
 //    public static void set(ServletRequest request, String name, Object value) {
 191  
 //        request.setAttribute(name + REQUEST_SCOPE_SUFFIX, value);
 192  
 //    }
 193  
 
 194  
     /**
 195  
      * Sets the value of a configuration variable in the "session" scope.
 196  
      *
 197  
      * <p> Setting the value of a configuration variable is performed as if
 198  
      * each scope had its own namespace, that is, the same configuration
 199  
      * variable name in one scope does not replace one stored in a different
 200  
      * scope.
 201  
      *
 202  
      * @param session Session object in which the configuration variable is to
 203  
      * be set
 204  
      * @param name Configuration variable name
 205  
      * @param value Configuration variable value
 206  
      */
 207  
 //    public static void set(HttpSession session, String name, Object value) {
 208  
 //        session.setAttribute(name + SESSION_SCOPE_SUFFIX, value);
 209  
 //    }
 210  
 
 211  
     /**
 212  
      * Sets the value of a configuration variable in the "application" scope.
 213  
      *
 214  
      * <p> Setting the value of a configuration variable is performed as if
 215  
      * each scope had its own namespace, that is, the same configuration
 216  
      * variable name in one scope does not replace one stored in a different
 217  
      * scope.
 218  
      *
 219  
      * @param context Servlet context in which the configuration variable is to
 220  
      * be set
 221  
      * @param name Configuration variable name
 222  
      * @param value Configuration variable value
 223  
      */
 224  
 //    public static void set(ServletContext context, String name, Object value) {
 225  
 //        context.setAttribute(name + APPLICATION_SCOPE_SUFFIX, value);
 226  
 //    }
 227  
 
 228  
     /**
 229  
      * Removes a configuration variable from the given scope.
 230  
      *
 231  
      * <p> Removing a configuration variable is performed as if each scope had
 232  
      * its own namespace, that is, the same configuration variable name in one
 233  
      * scope does not impact one stored in a different scope.
 234  
      *
 235  
      * @param jc Page context from which the configuration variable is to be
 236  
      * removed
 237  
      * @param name Configuration variable name
 238  
      * @param scope Scope from which the configuration variable is to be
 239  
      * removed
 240  
      */
 241  
 //    public static void remove(JellyContext jc, String name, int scope) {
 242  
 //        switch (scope) {
 243  
 //            case JellyContext.PAGE_SCOPE:
 244  
 //                jc.removeAttribute(name + PAGE_SCOPE_SUFFIX, scope);
 245  
 //                break;
 246  
 //            case JellyContext.REQUEST_SCOPE:
 247  
 //                jc.removeAttribute(name + REQUEST_SCOPE_SUFFIX, scope);
 248  
 //                break;
 249  
 //            case JellyContext.SESSION_SCOPE:
 250  
 //                jc.removeAttribute(name + SESSION_SCOPE_SUFFIX, scope);
 251  
 //                break;
 252  
 //            case JellyContext.APPLICATION_SCOPE:
 253  
 //                jc.removeAttribute(name + APPLICATION_SCOPE_SUFFIX, scope);
 254  
 //                break;
 255  
 //            default:
 256  
 //                throw new IllegalArgumentException("unknown scope");
 257  
 //        }
 258  
 //    }
 259  
 
 260  
     /**
 261  
      * Removes a configuration variable from the "request" scope.
 262  
      *
 263  
      * <p> Removing a configuration variable is performed as if each scope had
 264  
      * its own namespace, that is, the same configuration variable name in one
 265  
      * scope does not impact one stored in a different scope.
 266  
      *
 267  
      * @param request Request object from which the configuration variable is
 268  
      * to be removed
 269  
      * @param name Configuration variable name
 270  
      */
 271  
 //    public static void remove(ServletRequest request, String name) {
 272  
 //        request.removeAttribute(name + REQUEST_SCOPE_SUFFIX);
 273  
 //    }
 274  
 
 275  
     /**
 276  
      * Removes a configuration variable from the "session" scope.
 277  
      *
 278  
      * <p> Removing a configuration variable is performed as if each scope had
 279  
      * its own namespace, that is, the same configuration variable name in one
 280  
      * scope does not impact one stored in a different scope.
 281  
      *
 282  
      * @param session Session object from which the configuration variable is
 283  
      * to be removed
 284  
      * @param name Configuration variable name
 285  
      */
 286  
 //    public static void remove(HttpSession session, String name) {
 287  
 //        session.removeAttribute(name + SESSION_SCOPE_SUFFIX);
 288  
 //    }
 289  
 
 290  
     /**
 291  
      * Removes a configuration variable from the "application" scope.
 292  
      *
 293  
      * <p> Removing a configuration variable is performed as if each scope had
 294  
      * its own namespace, that is, the same configuration variable name in one
 295  
      * scope does not impact one stored in a different scope.
 296  
      *
 297  
      * @param context Servlet context from which the configuration variable is
 298  
      * to be removed
 299  
      * @param name Configuration variable name
 300  
      */
 301  
 //    public static void remove(ServletContext context, String name) {
 302  
 //        context.removeAttribute(name + APPLICATION_SCOPE_SUFFIX);
 303  
 //    }
 304  
 
 305  
     /**
 306  
      * Finds the value associated with a specific configuration setting
 307  
      * identified by its context initialization parameter name.
 308  
      *
 309  
      * <p> For each of the JSP scopes (page, request, session, application),
 310  
      * get the value of the configuration variable identified by <tt>name</tt>
 311  
      * using method <tt>get()</tt>. Return as soon as a non-null value is
 312  
      * found. If no value is found, get the value of the context initialization
 313  
      * parameter identified by <tt>name</tt>.
 314  
      *
 315  
      * @param jc Page context in which the configuration setting is to be
 316  
      * searched
 317  
      * @param name Context initialization parameter name of the configuration
 318  
      * setting
 319  
      *
 320  
      * @return The <tt>java.lang.Object</tt> associated with the configuration
 321  
      * setting identified by <tt>name</tt>, or null if it is not defined.
 322  
      */
 323  
 //    public static Object find(JellyContext jc, String name) {
 324  
 //        Object ret = jc.getVariable(name, JellyContext.PAGE_SCOPE);
 325  
 //        if (ret == null) {
 326  
 //            ret = get(jc, name, JellyContext.REQUEST_SCOPE);
 327  
 //            if (ret == null) {
 328  
 //                if (jc.getSession() != null) {
 329  
 //                    // check session only if a session is present
 330  
 //                    ret = get(jc, name, JellyContext.SESSION_SCOPE);
 331  
 //                }
 332  
 //                if (ret == null) {
 333  
 //                    ret = get(jc, name, JellyContext.APPLICATION_SCOPE);
 334  
 //                    if (ret == null) {
 335  
 //                        ret = jc.getServletContext().getInitParameter(name);
 336  
 //                    }
 337  
 //                }
 338  
 //            }
 339  
 //        }
 340  
 //
 341  
 //        return ret;
 342  
 //    }
 343  
 }

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