Package org.bouncycastle.i18n
Class LocalizedMessage
- java.lang.Object
-
- org.bouncycastle.i18n.LocalizedMessage
-
- Direct Known Subclasses:
LocaleString,TextBundle
public class LocalizedMessage extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLocalizedMessage.FilteredArguments
-
Field Summary
Fields Modifier and Type Field Description protected LocalizedMessage.FilteredArgumentsargumentsstatic java.lang.StringDEFAULT_ENCODINGprotected java.lang.Stringencodingprotected LocalizedMessage.FilteredArgumentsextraArgsprotected Filterfilterprotected java.lang.Stringidprotected java.lang.ClassLoaderloaderprotected java.lang.Stringresource
-
Constructor Summary
Constructors Constructor Description LocalizedMessage(java.lang.String resource, java.lang.String id)Constructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.Object[] arguments)Constructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.String encoding)Constructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.String encoding, java.lang.Object[] arguments)Constructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringaddExtraArgs(java.lang.String msg, java.util.Locale locale)protected java.lang.StringformatWithTimeZone(java.lang.String template, java.lang.Object[] arguments, java.util.Locale locale, java.util.TimeZone timezone)java.lang.Object[]getArguments()Returns an Object[] containing the message arguments.java.lang.ClassLoadergetClassLoader()Returns theClassLoaderwhich loads the resource files or null if the default ClassLoader is used.java.lang.StringgetEntry(java.lang.String key, java.util.Locale loc, java.util.TimeZone timezone)Reads the entry id + "." + key from the resource file and returns a formated message for the given Locale and TimeZone.java.lang.Object[]getExtraArgs()FiltergetFilter()Returns the current filter.java.lang.StringgetId()Returns the id of the message in the resource bundle.java.lang.StringgetResource()Returns the name of the resource bundle for this messagevoidsetClassLoader(java.lang.ClassLoader loader)Set theClassLoaderwhich loads the resource files.voidsetExtraArgument(java.lang.Object extraArg)voidsetExtraArguments(java.lang.Object[] extraArgs)voidsetFilter(Filter filter)Sets theFilterthat is used to filter the arguments of this messagejava.lang.StringtoString()
-
-
-
Field Detail
-
id
protected final java.lang.String id
-
resource
protected final java.lang.String resource
-
DEFAULT_ENCODING
public static final java.lang.String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
encoding
protected java.lang.String encoding
-
arguments
protected LocalizedMessage.FilteredArguments arguments
-
extraArgs
protected LocalizedMessage.FilteredArguments extraArgs
-
filter
protected Filter filter
-
loader
protected java.lang.ClassLoader loader
-
-
Constructor Detail
-
LocalizedMessage
public LocalizedMessage(java.lang.String resource, java.lang.String id) throws java.lang.NullPointerExceptionConstructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.- Parameters:
resource- base name of the resource fileid- the id of the corresponding bundle in the resource file- Throws:
java.lang.NullPointerException- if resource or id is null
-
LocalizedMessage
public LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.String encoding) throws java.lang.NullPointerException, java.io.UnsupportedEncodingExceptionConstructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.- Parameters:
resource- base name of the resource fileid- the id of the corresponding bundle in the resource fileencoding- the encoding of the resource file- Throws:
java.lang.NullPointerException- if resource or id is nulljava.io.UnsupportedEncodingException- if the encoding is not supported
-
LocalizedMessage
public LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.Object[] arguments) throws java.lang.NullPointerExceptionConstructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.- Parameters:
resource- base name of the resource fileid- the id of the corresponding bundle in the resource filearguments- an array containing the arguments for the message- Throws:
java.lang.NullPointerException- if resource or id is null
-
LocalizedMessage
public LocalizedMessage(java.lang.String resource, java.lang.String id, java.lang.String encoding, java.lang.Object[] arguments) throws java.lang.NullPointerException, java.io.UnsupportedEncodingExceptionConstructs a new LocalizedMessage using resource as the base name for the RessourceBundle and id as the message bundle id the resource file.- Parameters:
resource- base name of the resource fileid- the id of the corresponding bundle in the resource fileencoding- the encoding of the resource filearguments- an array containing the arguments for the message- Throws:
java.lang.NullPointerException- if resource or id is nulljava.io.UnsupportedEncodingException- if the encoding is not supported
-
-
Method Detail
-
getEntry
public java.lang.String getEntry(java.lang.String key, java.util.Locale loc, java.util.TimeZone timezone) throws MissingEntryExceptionReads the entry id + "." + key from the resource file and returns a formated message for the given Locale and TimeZone.- Parameters:
key- second part of the entry idloc- the usedLocaletimezone- the usedTimeZone- Returns:
- a Strng containing the localized message
- Throws:
MissingEntryException- if the resource file is not available or the entry does not exist.
-
formatWithTimeZone
protected java.lang.String formatWithTimeZone(java.lang.String template, java.lang.Object[] arguments, java.util.Locale locale, java.util.TimeZone timezone)
-
addExtraArgs
protected java.lang.String addExtraArgs(java.lang.String msg, java.util.Locale locale)
-
setFilter
public void setFilter(Filter filter)
Sets theFilterthat is used to filter the arguments of this message- Parameters:
filter- theFilterto use. null to disable filtering.
-
getFilter
public Filter getFilter()
Returns the current filter.- Returns:
- the current filter
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader loader)
Set theClassLoaderwhich loads the resource files. If it is set to null then the defaultClassLoaderis used.- Parameters:
loader- theClassLoaderwhich loads the resource files
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Returns theClassLoaderwhich loads the resource files or null if the default ClassLoader is used.- Returns:
- the
ClassLoaderwhich loads the resource files
-
getId
public java.lang.String getId()
Returns the id of the message in the resource bundle.- Returns:
- the id of the message
-
getResource
public java.lang.String getResource()
Returns the name of the resource bundle for this message- Returns:
- name of the resource file
-
getArguments
public java.lang.Object[] getArguments()
Returns an Object[] containing the message arguments.- Returns:
- the message arguments
-
setExtraArgument
public void setExtraArgument(java.lang.Object extraArg)
- Parameters:
extraArg-
-
setExtraArguments
public void setExtraArguments(java.lang.Object[] extraArgs)
- Parameters:
extraArgs-
-
getExtraArgs
public java.lang.Object[] getExtraArgs()
- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-