Package Torello.JSON
Class JsonBindingArrException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- javax.json.JsonException
-
- Torello.JSON.JsonBindingException
-
- Torello.JSON.JsonBindingArrException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
JsonArithmeticArrException,JsonBuildPOJOArrException,JsonNullArrException,JsonNullPrimitiveArrException,JsonStrParseArrException,JsonTypeArrException
public abstract class JsonBindingArrException extends JsonBindingException
JsonBindingArrException 🠞Json- This exception is thrown by the Json Reader Classes
Binding- This is the super-class of all Json Exceptions that handle errors withJsonArray's
Arr- Since these exceptions contain 'convenience fields' which provide some simple data about the Json that caused the exception throw, and since the 'relevant information' about aJsonObjectproperty and aJsonArrayindex are somewhat different - there are two different exceptions for them! (An Exception forObject'sand an exception forArray's).
Thisabstractclass reports errors that occur when retrieving data fromJsonArray's
Exception- This class inherits classException
The parent class of all Json Binding Exceptions that are used forJsonArrayelement retrieval errors. In order to hopefully continue to make easy-code actually look easy, the following keywords used in this exception's name are broken down below.
NOTE: This class is abstract, and cannot be instantiated.
The following'final'Convenience Fields are exported by this Exception Class:Inherited Field Field Type Inherited From indexintNot Inherited, Class Field errorSourceJsonStructJsonStructureJsonBindingExceptionexpectedJsonTypeJsonValue.ValueTypeJsonBindingExceptionmethodReturnJavaTypejava.lang.ClassJsonBindingExceptionvalueRetrievedJsonValueJsonBindingException- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JSON/JsonBindingArrException.java
- Open New Browser-Tab: Torello/JSON/JsonBindingArrException.java
File Size: 10,154 Bytes Line Count: 225 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static longserialVersionUID'final'Exception Convenience FieldsModifier and Type Field intindex-
Fields inherited from class Torello.JSON.JsonBindingException
errorSourceJsonStruct, expectedJsonType, methodReturnJavaType, valueRetrieved
-
-
Constructor Summary
Constructors Constructor JsonBindingArrException(String message, Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType)JsonBindingArrException(String message, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType)JsonBindingArrException(Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote)JsonBindingArrException(JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method protected static StringBASE_MESSAGE_ARR(JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote, Throwable... causes)-
Methods inherited from class Torello.JSON.JsonBindingException
BASE_MESSAGE
-
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
Note that Java'sjava.lang.Exceptionandjava.lang.Errorclasses implement theSerializable interface, and a warning-free build expects this field be defined here.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final long serialVersionUID = 1;
-
index
public final int index
This field is provided to the user as a matter of convenience. All instances of thisExceptionought to guarantee that when an instance is thrown - any & all "Convenience Fields" have been properly set.
If this package is extended, or if this exception is used elsewhere, try to remember to not to accidentally leave this field null when using this class' constructors.
In Summary:
All this is really trying to explain is that, when debugging your code, if in the analysis of a particularException, that analysis causes another exception throw (NullPointerException) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - you would likely get pretty angry.
This is the array index into the sourceJsonArraywhich contained the element (or lack-there-of) that has caused this exception.- Code:
- Exact Field Declaration Expression:
public final int index;
-
-
Constructor Detail
-
JsonBindingArrException
public JsonBindingArrException(JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType, java.lang.String endingNote)
Constructs aJsonBindingArrExceptionwith no specified detail messsage, and the user-provided convenience-field values.- Parameters:
errorSourceJsonArray- TheJsonArrayfrom which the element is being retrieved / extracted.index- This is theJsonArrayindex from which the element is being retrieved / extracted.expectedJsonType- This is the Json-Type that was expected to be retrieved fromJsonArray.valueRetrieved- This is theJsonValuethat was extracted from theJsonArraywhich caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULLmethodReturnJavaType- ClassReadJSONwill always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.endingNote- The distinct message for the exception sub-class.
-
JsonBindingArrException
public JsonBindingArrException(java.lang.String message, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs aJsonBindingArrExceptionwith the specified detail message, and user-provided convenience-field values.- Parameters:
message- the detail message.errorSourceJsonArray- TheJsonArrayfrom which the element is being retrieved / extracted.index- This is theJsonArrayindex from which the element is being retrieved / extracted.expectedJsonType- This is the Json-Type that was expected to be retrieved fromJsonArray.valueRetrieved- This is theJsonValuethat was extracted from theJsonArraywhich caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULLmethodReturnJavaType- ClassReadJSONwill always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
JsonBindingArrException
public JsonBindingArrException(java.lang.String message, java.lang.Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs a newJsonBindingArrExceptionwith the specified detail message and cause
NOTE:
The detail message associated with cause is not automatically incorporated into this exception's detail message.- Parameters:
message- The detail message (which is saved for later retrieval by theThrowable.getMessage()method).cause- the cause (which is saved for later retrieval by theThrowable.getCause()method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)errorSourceJsonArray- TheJsonArrayfrom which the element is being retrieved / extracted.index- This is theJsonArrayindex from which the element is being retrieved / extracted.expectedJsonType- This is the Json-Type that was expected to be retrieved fromJsonArray.valueRetrieved- This is theJsonValuethat was extracted from theJsonArraywhich caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULLmethodReturnJavaType- ClassReadJSONwill always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
JsonBindingArrException
public JsonBindingArrException(java.lang.Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType, java.lang.String endingNote)
Constructs a newJsonBindingArrExceptionwith the specified cause and a detail message of(cause==null ? null : cause.toString())(which typically contains the class and detail message of cause).
This constructor is useful for exceptions that are little more than wrappers for other throwables.- Parameters:
cause- The cause (which is saved for later retrieval by theThrowable.getCause()method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)errorSourceJsonArray- TheJsonArrayfrom which the element is being retrieved / extracted.index- This is theJsonArrayindex from which the element is being retrieved / extracted.expectedJsonType- This is the Json-Type that was expected to be retrieved fromJsonArray.valueRetrieved- This is theJsonValuethat was extracted from theJsonArraywhich caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULLmethodReturnJavaType- ClassReadJSONwill always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.endingNote- The distinct message for the exception sub-class.
-
-
Method Detail
-
BASE_MESSAGE_ARR
protected static java.lang.String BASE_MESSAGE_ARR (JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType, java.lang.String endingNote, java.lang.Throwable... causes)
A simple helper method for printing a consistent error messge using the input-data convenience fields ofJsonArray's.- Parameters:
errorSourceJsonArray- TheJsonArrayfrom which the element is being retrieved / extracted.index- This is theJsonArrayindex from which the element is being retrieved / extracted.expectedJsonType- This is the Json-Type that was expected to be retrieved fromJsonArray.valueRetrieved- This is theJsonValuethat was extracted from theJsonArraywhich caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULLmethodReturnJavaType- ClassReadJSONwill always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.endingNote- The distinct message for the exception sub-class.causes- Optional Parameter. At most 1 cause is printed.- Returns:
- The error message
String. - Code:
- Exact Method Body:
return ((endingNote != null) ? endingNote : "") +"\n" + CAUSE_MESSAGE(causes) + "\tFound In JsonArray: " + ABBREV_STRUCT(errorSourceJsonArray) + "\n" + // Year 2026. With the addition of "BuildPOJO" JsonBindingException variant, the array // index may not be available. If a bogus array index is passed, it shall be passed // '-1', signifying that that information wasn't available to the builder lambda. // // I'm getting rid of this as we speak, but this is actually a sensible check to keep. // The only way that a negative value couldd be passed here would be due to my failure, // not there's. If, somehow, a negative array index is passed, it is better to say // "unknown". // // Though this hasn't actually happened, it would be an "Exception caused Exception" // (something I used to call very bad) "\tAt Index: " + ((index >= 0) ? ("" + index) : "<unknown>") + "\n" + "\tExpected Json-Type: " + JT_STR(expectedJsonType) + "\n" + "\tContained JsonValue: " + ABBREV_VAL(valueRetrieved) + "\n" + "\tHaving Actual Json-Type: " + JT_STR((valueRetrieved != null) ? valueRetrieved.getValueType() : null ) + "\n" + "\tConverting To Java-Type: " + ((methodReturnJavaType != null) ? methodReturnJavaType.getCanonicalName() : "Java-Type Unknown" );
-
-