com.stratelia.webactiv.util
Class ResourceLocator

java.lang.Object
  extended by com.stratelia.webactiv.util.ResourceLocator
All Implemented Interfaces:
Serializable

public class ResourceLocator
extends Object
implements Serializable

See Also:
Serialized Form

Constructor Summary
ResourceLocator()
          Creates new ResourceLocator
ResourceLocator(String sPropertyFile, Locale sLocale)
          Deprecated.  
ResourceLocator(String propertyFile, String language)
          Create a resource locator with the given property file (Ex: com.stratelia.webactiv.util.util) Use the function getString to get the parameters from this instance
ResourceLocator(String propertyFile, String language, ResourceLocator defaultResource)
           
 
Method Summary
 boolean getBoolean(String sAttribut, boolean defaultValue)
          Return the value of the given attribut in the Property created with the ResourceLocator constructor
 float getFloat(String sAttribute, float defaultValue)
          Gets the value as a float of the specified attributes in the resource bundle located by this ResourceLocator.
 int getInteger(String sAttribute, int defaultValue)
          Gets the value as an integer of the specified attributes in the resource bundle located by this ResourceLocator.
 Enumeration<String> getKeys()
          Return an enumeration of all keys in the property file loaded
 String getLanguage()
           
 long getLong(String sAttribute, long defaultValue)
          Gets the value as a long of the specified attributes in the resource bundle located by this ResourceLocator.
 Properties getProperties()
          Return the properties *
static URL getResource(Object object, Locale loc, String configFile, String extension)
           
static InputStream getResourceAsStream(Object object, Locale loc, String configFile, String extension)
           
 ResourceBundle getResourceBundle()
           
 String getString(String sAttribut)
          Return the value of the given attribut in the Property created with the ResourceLocator constructor
 String getString(String sAttribut, String defaultValue)
          Return the value of the given attribut in the Property created with the ResourceLocator constructor
 String[] getStringArray(String propNamePrefix, String propNameSufix, int max)
          Read a String-List from a Settings-file with indexes from 1 to n If max is -1, the functions reads until the propertie's Id is not found.
 String getStringWithParam(String resName, String param)
           
 String getStringWithParams(String resName, String[] params)
           
static void resetResourceLocator()
           
 void setLanguage(String sLanguage)
          Switchs this resource locator to the specified language for the same refered property file.
 void setPropertyLocation(String sPropertyFile, String sLanguage)
          Set properties of a SilverPeas component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLocator

public ResourceLocator()
Creates new ResourceLocator


ResourceLocator

public ResourceLocator(String propertyFile,
                       String language)
Create a resource locator with the given property file (Ex: com.stratelia.webactiv.util.util) Use the function getString to get the parameters from this instance

Parameters:
propertyFile -
language -

ResourceLocator

public ResourceLocator(String propertyFile,
                       String language,
                       ResourceLocator defaultResource)

ResourceLocator

public ResourceLocator(String sPropertyFile,
                       Locale sLocale)
Deprecated. 

Create a resource locator with the given property file (Ex: com.stratelia.webactiv.util.util) Use the function getString to get the parameters from this instance

Method Detail

setPropertyLocation

public void setPropertyLocation(String sPropertyFile,
                                String sLanguage)
Set properties of a SilverPeas component.

Parameters:
sPropertyFile -
sLanguage -

setLanguage

public void setLanguage(String sLanguage)
Switchs this resource locator to the specified language for the same refered property file.

Parameters:
sLanguage - the language to use for getting property values.

getString

public String getString(String sAttribut)
Return the value of the given attribut in the Property created with the ResourceLocator constructor

Parameters:
sAttribut -
Returns:

getString

public String getString(String sAttribut,
                        String defaultValue)
Return the value of the given attribut in the Property created with the ResourceLocator constructor

Parameters:
sAttribut -
defaultValue -
Returns:

getBoolean

public boolean getBoolean(String sAttribut,
                          boolean defaultValue)
Return the value of the given attribut in the Property created with the ResourceLocator constructor

Parameters:
sAttribut -
defaultValue -
Returns:

getLong

public long getLong(String sAttribute,
                    long defaultValue)
Gets the value as a long of the specified attributes in the resource bundle located by this ResourceLocator. It no such attribute exists or has no value, then returns the specified default value.

Parameters:
sAttribute - the attribute to look up in the resource bundle.
defaultValue - the default value to return wether no such property exists in the resource bundle.
Returns:
the value as a long.

getFloat

public float getFloat(String sAttribute,
                      float defaultValue)
Gets the value as a float of the specified attributes in the resource bundle located by this ResourceLocator. It no such attribute exists or has no value, then returns the specified default value.

Parameters:
sAttribute - the attribute to look up in the resource bundle.
defaultValue - the default value to return wether no such property exists in the resource bundle.
Returns:
the value as a float.

getInteger

public int getInteger(String sAttribute,
                      int defaultValue)
Gets the value as an integer of the specified attributes in the resource bundle located by this ResourceLocator. It no such attribute exists or has no value, then returns the specified default value.

Parameters:
sAttribute - the attribute to look up in the resource bundle.
defaultValue - the default value to return wether no such property exists in the resource bundle.
Returns:
the value as an integer.

getStringWithParam

public String getStringWithParam(String resName,
                                 String param)

getStringWithParams

public String getStringWithParams(String resName,
                                  String[] params)

getStringArray

public String[] getStringArray(String propNamePrefix,
                               String propNameSufix,
                               int max)
Read a String-List from a Settings-file with indexes from 1 to n If max is -1, the functions reads until the propertie's Id is not found. If max >= 1, the functions returns an array of 'max' elements (the elements not found are set to "")

Parameters:
propNamePrefix -
propNameSufix -
max - the maximum index (-1 for no maximum value)
Returns:
See Also:

getKeys

public Enumeration<String> getKeys()
Return an enumeration of all keys in the property file loaded

Returns:

getResourceBundle

public ResourceBundle getResourceBundle()

getProperties

public Properties getProperties()
Return the properties *

Returns:

getLanguage

public String getLanguage()

resetResourceLocator

public static void resetResourceLocator()

getResource

public static URL getResource(Object object,
                              Locale loc,
                              String configFile,
                              String extension)

getResourceAsStream

public static InputStream getResourceAsStream(Object object,
                                              Locale loc,
                                              String configFile,
                                              String extension)


Copyright © 2016 Silverpeas. All Rights Reserved.