Widening, removal of MessageFormat import just for the javadoc since that
breaks GWT. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2380 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -20,30 +20,26 @@
|
|||||||
|
|
||||||
package com.samskivert.text;
|
package com.samskivert.text;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility functions for translation string handling.
|
* Utility functions for translation string handling.
|
||||||
*/
|
*/
|
||||||
public class MessageUtil
|
public class MessageUtil
|
||||||
{
|
{
|
||||||
/** Text prefixed by this character will be considered tainted when
|
/** Text prefixed by this character will be considered tainted when doing recursive
|
||||||
* doing recursive translations and won't be translated. */
|
* translations and won't be translated. */
|
||||||
public static final String TAINT_CHAR = "~";
|
public static final String TAINT_CHAR = "~";
|
||||||
|
|
||||||
/** Used to mark fully qualified message keys. */
|
/** Used to mark fully qualified message keys. */
|
||||||
public static final String QUAL_PREFIX = "%";
|
public static final String QUAL_PREFIX = "%";
|
||||||
|
|
||||||
/** Used to separate the bundle qualifier from the message key in a
|
/** Used to separate the bundle qualifier from the message key in a fully qualified message
|
||||||
* fully qualified message key. */
|
* key. */
|
||||||
public static final String QUAL_SEP = ":";
|
public static final String QUAL_SEP = ":";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this to "taint" any string that has been entered by an entity
|
* Call this to "taint" any string that has been entered by an entity outside the application
|
||||||
* outside the application so that the translation code knows not to
|
* so that the translation code knows not to attempt to translate this string when doing
|
||||||
* attempt to translate this string when doing recursive translations.
|
* recursive translations.
|
||||||
*/
|
*/
|
||||||
public static String taint (Object text)
|
public static String taint (Object text)
|
||||||
{
|
{
|
||||||
@@ -51,9 +47,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composes a message key with an array of arguments. The message can
|
* Composes a message key with an array of arguments. The message can subsequently be
|
||||||
* subsequently be decomposed and translated without prior knowledge
|
* decomposed and translated without prior knowledge of how many arguments were provided.
|
||||||
* of how many arguments were provided.
|
|
||||||
*/
|
*/
|
||||||
public static String compose (String key, Object... args)
|
public static String compose (String key, Object... args)
|
||||||
{
|
{
|
||||||
@@ -82,8 +77,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compose a message with String args. This is just a convenience so
|
* Compose a message with String args. This is just a convenience so callers do not have to
|
||||||
* callers do not have to cast their String[] to an Object[].
|
* cast their String[] to an Object[].
|
||||||
*/
|
*/
|
||||||
public static String compose (String key, String... args)
|
public static String compose (String key, String... args)
|
||||||
{
|
{
|
||||||
@@ -91,12 +86,11 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to escape single quotes so that they are not interpreted by
|
* Used to escape single quotes so that they are not interpreted by <code>MessageFormat</code>.
|
||||||
* {@link MessageFormat}. As we assume all single quotes are to be
|
* As we assume all single quotes are to be escaped, we cannot use the characters
|
||||||
* escaped, we cannot use the characters <code>{</code> and
|
* <code>{</code> and <code>}</code> in our translation strings, but this is a small price to
|
||||||
* <code>}</code> in our translation strings, but this is a small
|
* pay to have to differentiate between messages that will and won't eventually be parsed by a
|
||||||
* price to pay to have to differentiate between messages that will
|
* <code>MessageFormat</code> instance.
|
||||||
* and won't eventually be parsed by a {@link MessageFormat} instance.
|
|
||||||
*/
|
*/
|
||||||
public static String escape (String message)
|
public static String escape (String message)
|
||||||
{
|
{
|
||||||
@@ -130,9 +124,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method for calling {@link #compose(String,Object[])}
|
* A convenience method for calling {@link #compose(String,Object[])} with an array of
|
||||||
* with an array of arguments that will be automatically tainted (see
|
* arguments that will be automatically tainted (see {@link #taint}).
|
||||||
* {@link #taint}).
|
|
||||||
*/
|
*/
|
||||||
public static String tcompose (String key, Object... args)
|
public static String tcompose (String key, Object... args)
|
||||||
{
|
{
|
||||||
@@ -145,8 +138,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method for calling {@link #compose(String,String[])}
|
* A convenience method for calling {@link #compose(String,String[])} with an array of argument
|
||||||
* with an array of argument that will be automatically tainted.
|
* that will be automatically tainted.
|
||||||
*/
|
*/
|
||||||
public static String tcompose (String key, String... args)
|
public static String tcompose (String key, String... args)
|
||||||
{
|
{
|
||||||
@@ -157,8 +150,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decomposes a compound key into its constituent parts. Arguments
|
* Decomposes a compound key into its constituent parts. Arguments that were tainted during
|
||||||
* that were tainted during composition will remain tainted.
|
* composition will remain tainted.
|
||||||
*/
|
*/
|
||||||
public static String[] decompose (String compoundKey)
|
public static String[] decompose (String compoundKey)
|
||||||
{
|
{
|
||||||
@@ -170,9 +163,8 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a fully qualified message key which, when translated by
|
* Returns a fully qualified message key which, when translated by some other bundle, will know
|
||||||
* some other bundle, will know to resolve and utilize the supplied
|
* to resolve and utilize the supplied bundle to translate this particular key.
|
||||||
* bundle to translate this particular key.
|
|
||||||
*/
|
*/
|
||||||
public static String qualify (String bundle, String key)
|
public static String qualify (String bundle, String key)
|
||||||
{
|
{
|
||||||
@@ -209,8 +201,7 @@ public class MessageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unqualified portion of the key from a fully qualified
|
* Returns the unqualified portion of the key from a fully qualified message key.
|
||||||
* message key.
|
|
||||||
*
|
*
|
||||||
* @see #qualify
|
* @see #qualify
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user