net.sf.ivmaidns.util
Class ParserException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by java.lang.IllegalArgumentException
                  extended by java.lang.NumberFormatException
                      extended by net.sf.ivmaidns.util.ParserException
All Implemented Interfaces:
java.io.Serializable

public class ParserException
extends java.lang.NumberFormatException

Class for custom parser exceptions. This class extends the semantics of NumberFormatException class and is used to signal that a particular error has been reached at a particular index unexpectedly while parsing a string or its region. Important notes: this exception class may be overridden (if needed).

Since:
1.8
Version:
2.0
Author:
Ivan Maidanski
See Also:
UnsignedInt, UnsignedLong, ByteVector, Serialized Form

Field Summary
protected  int error
          The error reason code explaining why this exception is thrown during the string region being parsed.
protected  int index
          The parsed string index at which this exception occurs during the string region being parsed.
protected  java.lang.String str
          The string containing the region being parsed.
 
Constructor Summary
ParserException()
          The default no-argument exception constructor.
ParserException(java.lang.String str, int index, int error)
          The standard parser exception constructor.
 
Method Summary
 int getError()
          Returns the error reason code explaining why parsing has failed.
 int getIndex()
          Returns the string index at which parsing has failed.
 java.lang.String getMessage()
          Returns the detailed message of the exception.
 java.lang.String getStr()
          Returns the string containing the region being parsed.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

str

protected java.lang.String str
The string containing the region being parsed. Important notes: this value may be null.

See Also:
ParserException(), ParserException(java.lang.String, int, int), getStr(), index, error

index

protected int index
The parsed string index at which this exception occurs during the string region being parsed. Important notes: index may be of any integer value; if its value is negative then it should be treated as zero; if its value is too big then it should be treated as length() of str (only if str is not null else it should be treated as zero).

See Also:
ParserException(), ParserException(java.lang.String, int, int), getIndex(), str, error

error

protected int error
The error reason code explaining why this exception is thrown during the string region being parsed. Important notes: error may be of any integer value; if its value is not positive then it should be treated as zero (indicating an unknown error).

See Also:
ParserException(), ParserException(java.lang.String, int, int), getError(), str, index
Constructor Detail

ParserException

public ParserException()
The default no-argument exception constructor. str is set to null, index and error are set to zero.

See Also:
ParserException(java.lang.String, int, int), getMessage()

ParserException

public ParserException(java.lang.String str,
                       int index,
                       int error)
The standard parser exception constructor. The meaning of a particular error code is custom-defined (zero code indicates an unknown/unset error).

Parameters:
str - the string containing the region being parsed (may be null, in fact).
index - the string index (may be of any integer value) at which parsing has failed.
error - the reason code (may be of any integer value) explaining why parsing has failed.
See Also:
ParserException(), getMessage(), getStr(), getIndex(), getError()
Method Detail

getStr

public final java.lang.String getStr()
Returns the string containing the region being parsed.

Returns:
the string (may be null) with the region being parsed.
See Also:
ParserException(java.lang.String, int, int), getIndex(), getError()

getIndex

public final int getIndex()
Returns the string index at which parsing has failed. Important notes: result may be of any integer value; if its value is negative then it should be treated as zero; if its value is too big then it should be treated as length() of getStr() (only if getStr() is not null else it should be treated as zero).

Returns:
the string index (may be of any integer value) at which parsing has failed.
See Also:
ParserException(java.lang.String, int, int), getStr(), getError()

getError

public final int getError()
Returns the error reason code explaining why parsing has failed. The meaning of a particular error code is custom-defined.

Returns:
the reason code (may be of any integer value) explaining why parsing has failed.
See Also:
ParserException(java.lang.String, int, int), getStr(), getIndex()

getMessage

public java.lang.String getMessage()
Returns the detailed message of the exception. This method overrides the default getMessage() one. The resulting string is a concatenation of the following: "Error", error represented as a signed decimal integer, ":", index represented as a signed decimal integer too, ":" and str (if not null).

Overrides:
getMessage in class java.lang.Throwable
Returns:
the message string (may be null) describing this parser exception.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
ParserException(java.lang.String, int, int), getStr(), getIndex(), getError()