com.jalios.util
Class LangProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<String,String>
          extended by com.jalios.util.JProperties
              extended by com.jalios.util.LangProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<String,String>

public class LangProperties
extends JProperties

See Also:
Serialized Form

Field Summary
protected  String defaultLangPrefix
           
static String REVISION
           
 
Fields inherited from class com.jalios.util.JProperties
listenerSet, propertyNameAsDefaultValue
 
Constructor Summary
LangProperties()
           
 
Method Summary
 String format(String format, Object[] objects)
          This is a temporary implementation waiting for a more powerful Format.
 String format(String format, Object[] objects, String language)
          This is a temporary implementation waiting for a more powerful Format.
 String getExplicitLangProperty(LangProperty prop, String language)
          Resolve the given property name using the given language.
 String getExplicitLangProperty(String name, String language, Object[] formArgs)
          Resolve the given property name using the given language.
 String getLangProperty(String name, Object... formArgs)
          Resolve the given property name using the default language prefix.
 String[] getLangStringArrayProperty(String name, String[] defaultValue)
           
 JProperties getProperties(String prefix)
          Returns a new property set of properties with key matching a given prefix.
 void setDefaultLangPrefix(String langPrefix)
          Define the default lang prefix to use when looking for a language property.
 
Methods inherited from class com.jalios.util.JProperties
addProperties, addProperties, addPropertiesListener, buildArrayFromString, clearProperties, containsProperty, firePropertiesChange, getBooleanProperty, getDoubleProperty, getFloatProperty, getIntArrayProperty, getIntegerProperty, getListenerSet, getLongProperty, getProperty, getProperty, getStringArrayProperty, getSubProperties, load, load, removePropertiesListener, setProperty, updateAndSave
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

defaultLangPrefix

protected String defaultLangPrefix
Constructor Detail

LangProperties

public LangProperties()
Method Detail

setDefaultLangPrefix

public void setDefaultLangPrefix(String langPrefix)
Define the default lang prefix to use when looking for a language property.

Parameters:
langPrefix - an ISO-639 language code (without any '.')

getLangProperty

public String getLangProperty(String name,
                              Object... formArgs)
Resolve the given property name using the default language prefix.

Parameters:
name - the property name to resolve
formArgs - an array of parameters to use to for the format of property
Returns:
the resolved property

getExplicitLangProperty

public String getExplicitLangProperty(LangProperty prop,
                                      String language)
Resolve the given property name using the given language.

Parameters:
prop - the LangProperty instance corresponding to the property you want to resolve.
language - the ISO-639 code language to use to retrieve this property
Returns:
the resolved property

getExplicitLangProperty

public String getExplicitLangProperty(String name,
                                      String language,
                                      Object[] formArgs)
Resolve the given property name using the given language.

Example :

  String i18nStr = getExplicitLangProperty("ui.com.lbl.byte", "en", 6);
 

Parameters:
name - the property name to resolve
language - the language prefix used before the property name, usually an ISO-639 language code, if null, the default lang prefix is used.
formArgs - an array of parameters to use to for the format of property
Returns:
the resolved property

getLangStringArrayProperty

public String[] getLangStringArrayProperty(String name,
                                           String[] defaultValue)

getProperties

public JProperties getProperties(String prefix)
Returns a new property set of properties with key matching a given prefix.

Overrides:
getProperties in class JProperties
Parameters:
prefix - the prefix the properties must match to be added to the return LangProperties instance, if null, all properties are added.
Returns:
a new property set of properties with key matching a given prefix.

format

public String format(String format,
                     Object[] objects)
This is a temporary implementation waiting for a more powerful Format.
The extensions of format compared to MessageFormat are
- the ability to use context properties {property} - the ability to use more than 10 parameters - '...' is not an escape sequence for the expension

Parameters:
format - the string containing the pattern to be replaced
objects - an array of objects to be formatted and substituted.
Returns:
the formated string

format

public String format(String format,
                     Object[] objects,
                     String language)
This is a temporary implementation waiting for a more powerful Format.
The extensions of format compared to MessageFormat are
- the ability to use context properties {property} - the ability to use more than 10 parameters - '...' is not an escape sequence for the expension

Parameters:
format - the string containing the pattern to be replaced
objects - an array of objects to be formatted and substituted.
language - the language in which the string is being renderrd, used for recursive property such as "Hello {some.other.property}! "
Returns:
the formated string


Copyright © 2001-2010 Jalios SA. All Rights Reserved.