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 shortThe resources key as one of theErrors.Keysconstant, or 0 if none.private final Object[]The parameters for the localization message.private static final longFor cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionLocalizedParseException(Locale locale, short key, Object[] parameters, int errorOffset) Constructs aParseExceptionwith a message formatted from the given resource key and message parameters.privateLocalizedParseException(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 aParseExceptionwith a localized message built from the given parsing information.privateLocalizedParseException(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.InternationalStringIf 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 shortWorkaround 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
getErrorOffsetMethods 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.Keysconstant, 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
LocalizedParseExceptionto fallback onsuper.getMessage(). -
parameters
The parameters for the localization message.
-
-
Constructor Details
-
LocalizedParseException
Constructs aParseExceptionwith a message formatted from the given resource key and message parameters. This is the most generic constructor.- Parameters:
locale- the locale forgetLocalizedMessage(), ornullfor the default.key- the resource key as one of theErrors.Keysconstant.parameters- the values to be given toIndexedResourceBundle.getString(short, Object).errorOffset- the position where the error is found while parsing.
-
LocalizedParseException
Creates aParseExceptionwith 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(), ornullfor the default.type- the type of objects parsed by theFormat.text- the full text thatFormatfailed to parse.pos- index of the first parsed character, together with the error index. Can benullif 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 thatFormatfailed to parse.offset- index of the first character to parse intext.errorOffset- the position where the error is found while parsing.- Returns:
- the
parametersvalue 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:
getMessagein interfaceLocalizedException- Overrides:
getMessagein classThrowable- Returns:
- the message of this exception.
-
getLocalizedMessage
Returns a localized version of the exception message, typically for final user.- Specified by:
getLocalizedMessagein interfaceLocalizedException- Overrides:
getLocalizedMessagein 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:
getInternationalMessagein interfaceLocalizedException- Returns:
- the exception message, or
nullif this exception cannot produce international message.
-
initCause
Initializes the cause of this throwable to the specified value.- Overrides:
initCausein classThrowable- Parameters:
cause- the cause saved for later retrieval by theThrowable.getCause()method.- Returns:
- a reference to this
LocalizedParseExceptioninstance.
-