org.pm4j.core.pm.impl
Class PmLocalizeApiHandler

java.lang.Object
  extended by org.pm4j.core.pm.impl.PmLocalizeApiHandler

public class PmLocalizeApiHandler
extends java.lang.Object


Constructor Summary
PmLocalizeApiHandler()
           
 
Method Summary
 java.lang.String findLocalization(PmObjectBase pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
protected  java.util.Locale getLocale(PmObject pm)
           
 java.lang.String localize(PmObjectBase pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
protected  java.lang.String messageFormat(java.util.Locale locale, java.lang.String placeHolderString, java.lang.Object... placeHolderArgs)
          Uses the MessageFormat for string formatting.
 void setResourceStringProvider(ResourceStringProvider resourceStringProvider)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PmLocalizeApiHandler

public PmLocalizeApiHandler()
Method Detail

findLocalization

public java.lang.String findLocalization(PmObjectBase pm,
                                         java.lang.String key,
                                         java.lang.Object... resStringArgs)
Provides a localization based on a key and option resource string arguments.

The result of that operation strongly depends on the kind of title provider used.

Parameters:
key - A resource key.
resStringArgs - Optional resource string arguments.
Returns:
The localized string or null when no localization is available.

localize

public java.lang.String localize(PmObjectBase pm,
                                 java.lang.String key,
                                 java.lang.Object... resStringArgs)
Provides a localization based on a key and option resource string arguments.

The result of that operation strongly depends on the kind of title provider used.

Parameters:
key - A resource key.
resStringArgs - Optional resource string arguments.
Returns:
The localized string.
Throws:
org.pm4j.core.exception.PmRuntimeException - when no localization for the given key was found.

setResourceStringProvider

public void setResourceStringProvider(ResourceStringProvider resourceStringProvider)

getLocale

protected java.util.Locale getLocale(PmObject pm)

messageFormat

protected java.lang.String messageFormat(java.util.Locale locale,
                                         java.lang.String placeHolderString,
                                         java.lang.Object... placeHolderArgs)
Uses the MessageFormat for string formatting.

Parameters:
locale - The locale used for formatting.
placeHolderString - A template resource string with placeholders as documented in MessageFormat.
placeHolderArgs - Optional placeholder arguments.
Returns:
The formatted string.