Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
$URL: https://source.sakaiproject.org/svn/jsf/tags/sakai-10.0/jsf-widgets/src/java/org/sakaiproject/jsf/util/ConfigurationResource.java $ $Id: ConfigurationResource.java 105077 2012-02-24 22:54:29Z ottenhoff@longsight.com $ Copyright (c) 2005, 2006, 2008 The Sakai Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 
 
 package org.sakaiproject.jsf.util;
 
Thin wrapper for lookup of configuration of resources.

Author(s):
Ed Smiley
Version:
$Id: ConfigurationResource.java 105077 2012-02-24 22:54:29Z ottenhoff@longsight.com $
 
 public class ConfigurationResource
 {
   private final String CONFIG_PACKAGE = "org.sakaiproject.jsf";

  
Get resources for default locale.
 
   public ConfigurationResource()
   {
      = ResourceBundle.getBundle( + "." + "Configuration");
   }

  
Get resources for specific locale.

Parameters:
locale Locale
 
   public ConfigurationResource(Locale locale)
   {
      = ResourceBundle.getBundle( + "." +
       "Configuration"locale);
   }

  
Look up key/value

Parameters:
key String
Returns:
String value for key, or empty string if not found
 
   public String get(String key)
   {
     try
     {
       return .getString(key);
     }
     catch (Exception ex)
     {
       return "";
     }
   }

  
Return true only if this key exists.

Parameters:
key String
Returns:
boolean
 
   public boolean exists(String key)
   {
     try {
       .getString(key);
       return true;
     }
     catch (Exception ex) {
       return false;
     }
   }
 
 
   public static void main(String[] args)
   {
     Enumeration enumeration = cr.configurationBundle.getKeys();
     while (enumeration.hasMoreElements())
     {
       String key = (Stringenumeration.nextElement();
       String value = cr.get(key);
      ..println(key + "=" + value);
    }
    ..println("xxx exists" + "=" + cr.exists("xxx"));
    ..println("xxx" + "=" + cr.get("xxx"));
    ..println("inputRichText_none exists" + "=" + cr.exists("inputRichText_none"));
    ..println("inputRichText_none" + "=" + cr.get("inputRichText_none"));
    ..println("inputRichText_small exists" + "=" + cr.exists("inputRichText_small"));
    ..println("inputRichText_small" + "=" + cr.get("inputRichText_small"));
  }
New to GrepCode? Check out our FAQ X