Class IndexBoundsException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.IndexOutOfBoundsException
-
- one.microstream.exceptions.IndexBoundsException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArrayCapacityException
public class IndexBoundsException extends IndexOutOfBoundsException
Proper version ofIndexOutOfBoundsException
/ArrayIndexOutOfBoundsException
.As usual, they put programmatic relevant data into contextless plain strings in class
ArrayIndexOutOfBoundsException
. Funny thing is with this class they at least tried to do it right (one parameter index), but still failed hilariously (missing array bound parameter and again stuffing the argument value into a plain string).Also note from an architectual / design / API point of view that (apart from
ArrayCapacityException
beeing a JVM-technical special case), index bounds exceptions should not distinct between comming from an array or another index-based data structure as this is an implementation detail. Especially since Java exceptions are hardcoded classes instead of multiple-inheritance-of-type-viable proper types (interfaces), it even MUST not be differentiated.So again, one has to do everything by oneself properly.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IndexBoundsException(long indexBound)
IndexBoundsException(long indexBound, long index)
IndexBoundsException(long startIndex, long indexBound, long index)
IndexBoundsException(long startIndex, long indexBound, long index, String message)
IndexBoundsException(long indexBound, long index, String message)
IndexBoundsException(long indexBound, String message)
-
Method Summary
Modifier and Type Method Description String
assembleDetailString()
String
assembleOutputString()
String
getMessage()
Returns an assembled output String due to bad method design inThrowable
.long
index()
The index value used in the accessing attempt causing this exception.long
indexBound()
String
message()
Sadly, the Throwable implementation uses #getMessage() directly to print the exception.static String
messageBody()
long
startIndex()
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
IndexBoundsException
public IndexBoundsException(long indexBound)
-
IndexBoundsException
public IndexBoundsException(long indexBound, String message)
-
IndexBoundsException
public IndexBoundsException(long indexBound, long index)
-
IndexBoundsException
public IndexBoundsException(long indexBound, long index, String message)
-
IndexBoundsException
public IndexBoundsException(long startIndex, long indexBound, long index)
-
IndexBoundsException
public IndexBoundsException(long startIndex, long indexBound, long index, String message)
-
-
Method Detail
-
messageBody
public static final String messageBody()
-
startIndex
public final long startIndex()
-
indexBound
public final long indexBound()
-
index
public final long index()
The index value used in the accessing attempt causing this exception.Note that this value might have overflown depending on the reporting logic.
-
message
public final String message()
Sadly, the Throwable implementation uses #getMessage() directly to print the exception. This is a concern conflict: getMessage should actually be the getter for the explicit message. But it is used as the String assembling method as well. So a output method generically assembling the output string must override the getter. As this hides the actual getting functionality, a workaround accessor method has to be provided for potential subclasses.- Returns:
- the explicit message string passed to the constructor when creating this instance.
-
assembleDetailString
public String assembleDetailString()
-
assembleOutputString
public String assembleOutputString()
-
getMessage
public String getMessage()
Returns an assembled output String due to bad method design inThrowable
. Albeit being named "getMessage" by the JDK developers, this method should be seen as "assembleOutputString" as this is its purpose. For the actual message getter, seemessage()
.- Overrides:
getMessage
in classThrowable
- Returns:
- this exception type's generic message plus an explicit message if present.
-
-