org.pm4j.core.pm.api
Class PmLocalizeApi

java.lang.Object
  extended by org.pm4j.core.pm.api.PmLocalizeApi

public final class PmLocalizeApi
extends java.lang.Object


Constructor Summary
PmLocalizeApi()
           
 
Method Summary
static java.lang.String findLocalization(PmObject pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
static java.lang.String findLocalizationWithPfx(PmObject pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
static java.lang.String localize(PmObject pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
static java.lang.String localizeEnumValue(PmObject pmCtxt, java.lang.Enum<?> enumValue)
          Finds a localization for the given enum value.
static java.lang.String localizeOneOrMany(PmObject pm, int number, java.lang.Object... resArgs)
          Calls #localizeOneOrMany(String, int, Object...) with the resource key provided by #getPmResKey().
static java.lang.String localizeOneOrMany(PmObject pm, java.lang.String keybase, int number, java.lang.Object... resArgs)
          Provides a localization based on a key and option resource string arguments.
static java.lang.String localizeWithPfx(PmObject pm, java.lang.String key, java.lang.Object... resStringArgs)
          Provides a localization based on a key and option resource string arguments.
static void setResourceStringProvider(ResourceStringProvider resourceStringProvider)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PmLocalizeApi

public PmLocalizeApi()
Method Detail

findLocalization

public static java.lang.String findLocalization(PmObject 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 static java.lang.String localize(PmObject 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.

localizeEnumValue

public static java.lang.String localizeEnumValue(PmObject pmCtxt,
                                                 java.lang.Enum<?> enumValue)
Finds a localization for the given enum value.

The used resource key is a concatenation of the Enum class key generated by ResKeyUtil.shortResKeyForClass(Class), an appended '.' plus the enum value name().

Parameters:
pmCtxt -
enumValue -
Returns:
The corresponding localized string.

localizeOneOrMany

public static java.lang.String localizeOneOrMany(PmObject pm,
                                                 java.lang.String keybase,
                                                 int number,
                                                 java.lang.Object... resArgs)
Provides a localization based on a key and option resource string arguments.

Examples:

Parameters:
keybase - A resource key base that will be concatenated with 'one' or 'many'.
number - depending on the number the postfix '_one', '_many' or '_none' will be added to keybase
resArgs - The arguments for the resource string.
Returns:
The localized string.

localizeOneOrMany

public static java.lang.String localizeOneOrMany(PmObject pm,
                                                 int number,
                                                 java.lang.Object... resArgs)
Calls #localizeOneOrMany(String, int, Object...) with the resource key provided by #getPmResKey().


findLocalizationWithPfx

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

Used localization key: #getPmResKeyBase()+key.

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

localizeWithPfx

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

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

setResourceStringProvider

public static void setResourceStringProvider(ResourceStringProvider resourceStringProvider)
Parameters:
resourceStringProvider - The algorithm that provides resource strings for given resource keys.