Package Torello.Java.JSON
Class JsonTypeObjException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- javax.json.JsonException
-
- Torello.Java.JSON.JsonBindingException
-
- Torello.Java.JSON.JsonBindingObjException
-
- Torello.Java.JSON.JsonTypeObjException
-
- All Implemented Interfaces:
java.io.Serializable
public class JsonTypeObjException extends JsonBindingObjException
JsonTypeObjException 🠞Json
- This exception is thrown by the Json Reader Classes
Type
- AJsonObject
contained an entry that had an unexpected type
Obj
- 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 aJsonObject
property and aJsonArray
index are somewhat different - there are two different exceptions for them! (An Exception forObject's
and an exception forArray's
).
This class reports type-errors that occur when retrieving data fromJsonObject's
Exception
- This class inherits classException
Used to indicate that one of the properties within aJsonObject
contained a different type than was requested / expected by the reader. There are several convenience field-constants provided by the parent-class of this exception, and an additional field provided here too. 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.
The following'final'
Convenience Fields are exported by this Exception Class:Inherited Field Field Type Inherited From propertyName
java.lang.String
JsonBindingObjException
errorSourceJsonStruct
JsonStructure
JsonBindingException
expectedJsonType
JsonValue.ValueType
JsonBindingException
methodReturnJavaType
java.lang.Class
JsonBindingException
valueRetrieved
JsonValue
JsonBindingException
The main benefit of this complicated exception-class inheritance tree are the exception messages generated by this class. If any sub-class ofJsonBindingException
is thrown, it is guaranteed to produce as much detail as possible about which Json-Element has generated the error. Below is an example of what this class exception messages look like:
Terminal Output:
Exception in thread "main" Torello.Java.Additional.JsonTypeObjException: A JsonObject property contained an unexpected Json-Type Found In JsonObject: {"yearPurchased":"Year 1999"} Property-Name: yearPurchased Expected Json-Type: JsonValue.ValueType.NUMBER Contained JsonValue: "Year 1999" Having Actual Json-Type: JsonValue.ValueType.STRING Converting To Java-Type: int ... [followed by stack-trace]- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Java/JSON/JsonTypeObjException.java
- Open New Browser-Tab: Torello/Java/JSON/JsonTypeObjException.java
File Size: 3,325 Bytes Line Count: 73 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
-
Fields inherited from class Torello.Java.JSON.JsonBindingObjException
propertyName
-
Fields inherited from class Torello.Java.JSON.JsonBindingException
errorSourceJsonStruct, expectedJsonType, methodReturnJavaType, valueRetrieved
-
-
Constructor Summary
Constructors Constructor Description JsonTypeObjException(String message, JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
Constructs aJsonTypeObjException
with the specified detail message, and user-provided convenience-field values.JsonTypeObjException(JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
Constructs aJsonTypeObjException
with no specified detail messsage, and the user-provided convenience-field values.
-
Method Summary
-
Methods inherited from class Torello.Java.JSON.JsonBindingObjException
BASE_MESSAGE_OBJ
-
Methods inherited from class Torello.Java.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 theSerializable
Implementation 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.Exception
andjava.lang.Error
classes 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;
-
-
Constructor Detail
-
JsonTypeObjException
public JsonTypeObjException(JsonObject errorSourceJsonObject, java.lang.String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs aJsonTypeObjException
with no specified detail messsage, and the user-provided convenience-field values.- Parameters:
errorSourceJsonObject
- TheJsonObject
from which the property is being retrieved / extracted.propertyName
- This is the property-name into theJsonObject
from which the property is being retrieved / extracted.expectedJsonType
- This is the Json-Type that was expected to be retrieved fromJsonObject
.valueRetrieved
- This is theJsonValue
that was extracted from theJsonObject
which 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.NULL
methodReturnJavaType
- ClassReadJSON
will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
JsonTypeObjException
public JsonTypeObjException(java.lang.String message, JsonObject errorSourceJsonObject, java.lang.String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs aJsonTypeObjException
with the specified detail message, and user-provided convenience-field values.- Parameters:
message
- the detail message.errorSourceJsonObject
- TheJsonObject
from which the property is being retrieved / extracted.propertyName
- This is the property-name into theJsonObject
from which the property is being retrieved / extracted.expectedJsonType
- This is the Json-Type that was expected to be retrieved fromJsonObject
.valueRetrieved
- This is theJsonValue
that was extracted from theJsonObject
which 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.NULL
methodReturnJavaType
- ClassReadJSON
will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
-