Package org.bouncycastle.i18n
Class LocalizedMessage
- java.lang.Object
-
- org.bouncycastle.i18n.LocalizedMessage
-
- Direct Known Subclasses:
LocaleString
,TextBundle
public class LocalizedMessage extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
LocalizedMessage.FilteredArguments
-
Field Summary
Fields Modifier and Type Field Description protected LocalizedMessage.FilteredArguments
arguments
static String
DEFAULT_ENCODING
protected String
encoding
protected LocalizedMessage.FilteredArguments
extraArgs
protected Filter
filter
protected String
id
protected ClassLoader
loader
protected String
resource
-
Constructor Summary
Constructors Constructor Description LocalizedMessage(String resource, String id)
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
as the message bundle id the resource file.LocalizedMessage(String resource, String id, Object[] arguments)
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
as the message bundle id the resource file.LocalizedMessage(String resource, String id, String encoding)
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
as the message bundle id the resource file.LocalizedMessage(String resource, String id, String encoding, Object[] arguments)
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
as the message bundle id the resource file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
addExtraArgs(String msg, Locale locale)
protected String
formatWithTimeZone(String template, Object[] arguments, Locale locale, TimeZone timezone)
Object[]
getArguments()
Returns anObject[]
containing the message arguments.ClassLoader
getClassLoader()
Returns theClassLoader
which loads the resource files ornull
if the default ClassLoader is used.String
getEntry(String key, Locale loc, TimeZone timezone)
Reads the entryid + "." + key
from the resource file and returns a formated message for the given Locale and TimeZone.Object[]
getExtraArgs()
Filter
getFilter()
Returns the current filter.String
getId()
Returns the id of the message in the resource bundle.String
getResource()
Returns the name of the resource bundle for this messagevoid
setClassLoader(ClassLoader loader)
Set theClassLoader
which loads the resource files.void
setExtraArgument(Object extraArg)
void
setExtraArguments(Object[] extraArgs)
void
setFilter(Filter filter)
Sets theFilter
that is used to filter the arguments of this messageString
toString()
-
-
-
Field Detail
-
id
protected final String id
-
resource
protected final String resource
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
encoding
protected String encoding
-
arguments
protected LocalizedMessage.FilteredArguments arguments
-
extraArgs
protected LocalizedMessage.FilteredArguments extraArgs
-
filter
protected Filter filter
-
loader
protected ClassLoader loader
-
-
Constructor Detail
-
LocalizedMessage
public LocalizedMessage(String resource, String id) throws NullPointerException
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
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:
NullPointerException
- ifresource
orid
isnull
-
LocalizedMessage
public LocalizedMessage(String resource, String id, String encoding) throws NullPointerException, UnsupportedEncodingException
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
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:
NullPointerException
- ifresource
orid
isnull
UnsupportedEncodingException
- if the encoding is not supported
-
LocalizedMessage
public LocalizedMessage(String resource, String id, Object[] arguments) throws NullPointerException
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
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:
NullPointerException
- ifresource
orid
isnull
-
LocalizedMessage
public LocalizedMessage(String resource, String id, String encoding, Object[] arguments) throws NullPointerException, UnsupportedEncodingException
Constructs a new LocalizedMessage usingresource
as the base name for the RessourceBundle andid
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:
NullPointerException
- ifresource
orid
isnull
UnsupportedEncodingException
- if the encoding is not supported
-
-
Method Detail
-
getEntry
public String getEntry(String key, Locale loc, TimeZone timezone) throws MissingEntryException
Reads the entryid + "." + 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 usedLocale
timezone
- 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 String formatWithTimeZone(String template, Object[] arguments, Locale locale, TimeZone timezone)
-
setFilter
public void setFilter(Filter filter)
Sets theFilter
that is used to filter the arguments of this message- Parameters:
filter
- theFilter
to use.null
to disable filtering.
-
getFilter
public Filter getFilter()
Returns the current filter.- Returns:
- the current filter
-
setClassLoader
public void setClassLoader(ClassLoader loader)
Set theClassLoader
which loads the resource files. If it is set tonull
then the defaultClassLoader
is used.- Parameters:
loader
- theClassLoader
which loads the resource files
-
getClassLoader
public ClassLoader getClassLoader()
Returns theClassLoader
which loads the resource files ornull
if the default ClassLoader is used.- Returns:
- the
ClassLoader
which loads the resource files
-
getId
public String getId()
Returns the id of the message in the resource bundle.- Returns:
- the id of the message
-
getResource
public String getResource()
Returns the name of the resource bundle for this message- Returns:
- name of the resource file
-
getArguments
public Object[] getArguments()
Returns anObject[]
containing the message arguments.- Returns:
- the message arguments
-
setExtraArgument
public void setExtraArgument(Object extraArg)
- Parameters:
extraArg
-
-
setExtraArguments
public void setExtraArguments(Object[] extraArgs)
- Parameters:
extraArgs
-
-
getExtraArgs
public Object[] getExtraArgs()
- Returns:
-
-