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

public final class LocalizedParseException extends ParseException implements LocalizedException
A ParseException in which getLocalizedMessage() returns the message in the parser locale. This exception contains the error message in two languages: This locale given to the constructor is usually the Format locale, which is presumed to be the end-user locale.
Since:
0.3
Version:
0.8
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • key

      private final transient short key
      The resources key as one of the Errors.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 on super.getMessage().

    • parameters

      private final transient Object[] parameters
      The parameters for the localization message.
  • Constructor Details

    • LocalizedParseException

      public LocalizedParseException(Locale locale, short key, Object[] parameters, int errorOffset)
      Constructs a ParseException with a message formatted from the given resource key and message parameters. This is the most generic constructor.
      Parameters:
      locale - the locale for getLocalizedMessage(), or null for the default.
      key - the resource key as one of the Errors.Keys constant.
      parameters - the values to be given to IndexedResourceBundle.getString(short, Object).
      errorOffset - the position where the error is found while parsing.
    • LocalizedParseException

      public LocalizedParseException(Locale locale, Class<?> type, CharSequence text, ParsePosition pos)
      Creates a ParseException 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 for getLocalizedMessage(), or null for the default.
      type - the type of objects parsed by the Format.
      text - the full text that Format failed to parse.
      pos - index of the first parsed character, together with the error index. Can be null 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 the Format.
      text - the text that Format failed to parse.
      offset - index of the first character to parse in text.
      errorOffset - the position where the error is found while parsing.
      Returns:
      the parameters value to give to the constructor.
    • key

      @Workaround(library="JDK", version="1.8") private static short key(Object[] parameters)
      Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").
    • getMessage

      public String getMessage()
      Returns the exception message in the default locale, typically for system administrator.
      Specified by:
      getMessage in interface LocalizedException
      Overrides:
      getMessage in class Throwable
      Returns:
      the message of this exception.
    • getLocalizedMessage

      public String getLocalizedMessage()
      Returns a localized version of the exception message, typically for final user.
      Specified by:
      getLocalizedMessage in interface LocalizedException
      Overrides:
      getLocalizedMessage in class Throwable
      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 returns null.
      Specified by:
      getInternationalMessage in interface LocalizedException
      Returns:
      the exception message, or null if this exception cannot produce international message.
    • initCause

      public LocalizedParseException initCause(Throwable cause)
      Initializes the cause of this throwable to the specified value.
      Overrides:
      initCause in class Throwable
      Parameters:
      cause - the cause saved for later retrieval by the Throwable.getCause() method.
      Returns:
      a reference to this LocalizedParseException instance.