Package org.apache.sis.internal.util
Class LocalizedParseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.text.ParseException
org.apache.sis.internal.util.LocalizedParseException
- All Implemented Interfaces:
Serializable
,LocalizedException
A
ParseException
in which getLocalizedMessage()
returns the message in the parser locale.
This exception contains the error message in two languages:
Throwable.getMessage()
returns the message in the default locale.Throwable.getLocalizedMessage()
returns the message in the locale given in argument to the constructor.
Format
locale,
which is presumed to be the end-user locale.- Since:
- 0.3
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final short
The resources key as one of theErrors.Keys
constant, or 0 if none.private final Object[]
The parameters for the localization message.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionLocalizedParseException
(Locale locale, short key, Object[] parameters, int errorOffset) Constructs aParseException
with a message formatted from the given resource key and message parameters.private
LocalizedParseException
(Locale locale, Class<?> type, CharSequence text, int offset, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").LocalizedParseException
(Locale locale, Class<?> type, CharSequence text, ParsePosition pos) Creates aParseException
with a localized message built from the given parsing information.private
LocalizedParseException
(Locale locale, Object[] parameters, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors"). -
Method Summary
Modifier and TypeMethodDescriptionorg.opengis.util.InternationalString
If this exception is capable to return the message in various locales, returns that message.Returns a localized version of the exception message, typically for final user.Returns the exception message in the default locale, typically for system administrator.Initializes the cause of this throwable to the specified value.private static short
Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").private static Object[]
parameters
(Class<?> type, CharSequence text, int offset, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").Methods inherited from class java.text.ParseException
getErrorOffset
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
key
private final transient short keyThe resources key as one of theErrors.Keys
constant, or 0 if none.This field is not serialized because key values sometimes change between different SIS versions. The deserialized value will be 0, which will cause this
LocalizedParseException
to fallback onsuper.getMessage()
. -
parameters
The parameters for the localization message.
-
-
Constructor Details
-
LocalizedParseException
Constructs aParseException
with a message formatted from the given resource key and message parameters. This is the most generic constructor.- Parameters:
locale
- the locale forgetLocalizedMessage()
, ornull
for the default.key
- the resource key as one of theErrors.Keys
constant.parameters
- the values to be given toIndexedResourceBundle.getString(short, Object)
.errorOffset
- the position where the error is found while parsing.
-
LocalizedParseException
Creates aParseException
with a localized message built from the given parsing information. This convenience constructor creates a message of the kind "Cannot parse string "text" as an object of type 'type'".- Parameters:
locale
- the locale forgetLocalizedMessage()
, ornull
for the default.type
- the type of objects parsed by theFormat
.text
- the full text thatFormat
failed to parse.pos
- index of the first parsed character, together with the error index. Can benull
if index and error index are zero.
-
LocalizedParseException
@Workaround(library="JDK", version="1.8") private LocalizedParseException(Locale locale, Class<?> type, CharSequence text, int offset, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors"). -
LocalizedParseException
@Workaround(library="JDK", version="1.8") private LocalizedParseException(Locale locale, Object[] parameters, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").
-
-
Method Details
-
parameters
@Workaround(library="JDK", version="1.8") private static Object[] parameters(Class<?> type, CharSequence text, int offset, int errorOffset) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").- Parameters:
type
- the type of objects parsed by theFormat
.text
- the text thatFormat
failed to parse.offset
- index of the first character to parse intext
.errorOffset
- the position where the error is found while parsing.- Returns:
- the
parameters
value to give to the constructor.
-
key
Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors"). -
getMessage
Returns the exception message in the default locale, typically for system administrator.- Specified by:
getMessage
in interfaceLocalizedException
- Overrides:
getMessage
in classThrowable
- Returns:
- the message of this exception.
-
getLocalizedMessage
Returns a localized version of the exception message, typically for final user.- Specified by:
getLocalizedMessage
in interfaceLocalizedException
- Overrides:
getLocalizedMessage
in classThrowable
- Returns:
- the localized message of this exception.
-
getInternationalMessage
public org.opengis.util.InternationalString getInternationalMessage()If this exception is capable to return the message in various locales, returns that message. Otherwise returnsnull
.- Specified by:
getInternationalMessage
in interfaceLocalizedException
- Returns:
- the exception message, or
null
if this exception cannot produce international message.
-
initCause
Initializes the cause of this throwable to the specified value.- Overrides:
initCause
in classThrowable
- Parameters:
cause
- the cause saved for later retrieval by theThrowable.getCause()
method.- Returns:
- a reference to this
LocalizedParseException
instance.
-