com.samskivert.text
Class MessageUtil

java.lang.Object
  extended by com.samskivert.text.MessageUtil

public class MessageUtil
extends Object

Utility functions for translation string handling.


Field Summary
static String QUAL_PREFIX
          Used to mark fully qualified message keys.
static String QUAL_SEP
          Used to separate the bundle qualifier from the message key in a fully qualified message key.
static String TAINT_CHAR
          Text prefixed by this character will be considered tainted when doing recursive translations and won't be translated.
 
Constructor Summary
MessageUtil()
           
 
Method Summary
static String compose(String key, Object... args)
          Composes a message key with an array of arguments.
static String compose(String key, String... args)
          Compose a message with String args.
static String[] decompose(String compoundKey)
          Decomposes a compound key into its constituent parts.
static String escape(String message)
          Used to escape single quotes so that they are not interpreted by MessageFormat.
static String getBundle(String qualifiedKey)
          Returns the bundle name from a fully qualified message key.
static String getUnqualifiedKey(String qualifiedKey)
          Returns the unqualified portion of the key from a fully qualified message key.
static String qualify(String bundle, String key)
          Returns a fully qualified message key which, when translated by some other bundle, will know to resolve and utilize the supplied bundle to translate this particular key.
static String taint(Object text)
          Call this to "taint" any string that has been entered by an entity outside the application so that the translation code knows not to attempt to translate this string when doing recursive translations.
static String tcompose(String key, Object... args)
          A convenience method for calling compose(String,Object[]) with an array of arguments that will be automatically tainted (see taint(java.lang.Object)).
static String tcompose(String key, String... args)
          A convenience method for calling compose(String,String[]) with an array of argument that will be automatically tainted.
static String unescape(String value)
          Unescapes characters that are escaped in a call to compose.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAINT_CHAR

public static final String TAINT_CHAR
Text prefixed by this character will be considered tainted when doing recursive translations and won't be translated.

See Also:
Constant Field Values

QUAL_PREFIX

public static final String QUAL_PREFIX
Used to mark fully qualified message keys.

See Also:
Constant Field Values

QUAL_SEP

public static final String QUAL_SEP
Used to separate the bundle qualifier from the message key in a fully qualified message key.

See Also:
Constant Field Values
Constructor Detail

MessageUtil

public MessageUtil()
Method Detail

taint

public static String taint(Object text)
Call this to "taint" any string that has been entered by an entity outside the application so that the translation code knows not to attempt to translate this string when doing recursive translations.


compose

public static String compose(String key,
                             Object... args)
Composes a message key with an array of arguments. The message can subsequently be decomposed and translated without prior knowledge of how many arguments were provided.


compose

public static String compose(String key,
                             String... args)
Compose a message with String args. This is just a convenience so callers do not have to cast their String[] to an Object[].


escape

public static String escape(String message)
Used to escape single quotes so that they are not interpreted by MessageFormat. As we assume all single quotes are to be escaped, we cannot use the characters { and } in our translation strings, but this is a small price to pay to have to differentiate between messages that will and won't eventually be parsed by a MessageFormat instance.


unescape

public static String unescape(String value)
Unescapes characters that are escaped in a call to compose.


tcompose

public static String tcompose(String key,
                              Object... args)
A convenience method for calling compose(String,Object[]) with an array of arguments that will be automatically tainted (see taint(java.lang.Object)).


tcompose

public static String tcompose(String key,
                              String... args)
A convenience method for calling compose(String,String[]) with an array of argument that will be automatically tainted.


decompose

public static String[] decompose(String compoundKey)
Decomposes a compound key into its constituent parts. Arguments that were tainted during composition will remain tainted.


qualify

public static String qualify(String bundle,
                             String key)
Returns a fully qualified message key which, when translated by some other bundle, will know to resolve and utilize the supplied bundle to translate this particular key.


getBundle

public static String getBundle(String qualifiedKey)
Returns the bundle name from a fully qualified message key.

See Also:
qualify(java.lang.String, java.lang.String)

getUnqualifiedKey

public static String getUnqualifiedKey(String qualifiedKey)
Returns the unqualified portion of the key from a fully qualified message key.

See Also:
qualify(java.lang.String, java.lang.String)


Copyright © 2000-2008 Michael Bayne. All Rights Reserved.