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
Author:
Martin Desruisseaux (Geomatys)
See Also:
  • 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.
  • Method Details

    • 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.