|
Oracle® OLAP Java API Reference 11g Release 2 (11.2) E10794-03 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface HasLocalizedMessage
An interface for an Exception that can provide its
message in a language that is appropriate to a specified
Locale.
This interface is implemented by Exception classes
that are generated by the OLAP API client software, not by those
generated by the server-side software.
To find out if an Exception implements this interface,
use the instanceof operator.
Exception implements this interface,
then you can call its getLocalizedMessage method
and provide a Locale as a input parameter.
Exception does not implement this
interface, then you can still call its getLocalizedMessage
method, which it inherits from the Throwable class,
but without specifying a Locale.
The message is returned in the language of the default
Locale for the Java Virtual Machine in which
the OLAP API application is running.
getLocalizedMessage method.
The example creates a Locale object, and then tries
to create an MdmValueHierarchy.
The mdmDim object is an MdmPrimaryDimension
that has mdmLevelHier as one of its
MdmLevelHierarchy components.
If mdmLevelHier is mapped to a solved level hierarchy, then
the operation succeeds.
If it is mapped to an unsolved level hierarchy, then the
createValueHierarchy method throws a
MetadataFactoryException.
// Specify a Locale.
Locale myLocale = new Locale("fr", "CA");
try
{
MdmValueHierarchy mdmValHier = mdmDim.createValueHierarchy("ValueHier",
mdmLevelHier);
}
catch (Exception e)
{
String msg = null;
if (e instanceof HasLocalizedMessage)
{
// Get the localized message.
msg = ((HasLocalizedMessage) e).getLocalizedMessage(myLocale);
}
else
{
// Use the default Locale.
msg = e.getLocalizedMessage();
}
// Handle the exception.
}
You can also use the toString method, instead of the
getLocalizedMessage method, to get the message from an
Exception in the language of the default Locale
for the Java Virtual Machine in which the OLAP API application is running,
as in the following.
System.err.println(e.toString());
| Method Summary | |
|---|---|
java.lang.String |
getLocalizedMessage(java.util.Locale locale)
Gets a message in the language of the specified Locale. |
| Method Detail |
|---|
java.lang.String getLocalizedMessage(java.util.Locale locale)
Locale.
locale - A Locale object, which indicates the
language in which the message should be rendered.
String that contains the message for this
Exception. The message is in the language
of the specified Locale.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||