1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | package Torello.Java.JSON; import javax.json.*; /** * The parent class of all Json Binding Exceptions that are used for <B>{@link JsonObject}</B> * property 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. * * <BR /><BR /><B>NOTE:</B> This class is abstract, and cannot be instantiated. * * <EMBED CLASS=globalDefs DATA-STRUCT=JsonObject DATA-TYPE=Object DATA-TYPE_ABBREV=Obj> * <EMBED CLASS='external-html' DATA-FILE-ID=JE_FIELD_B_OBJ> */ @Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="JE_B_UL") @Torello.JavaDoc.CSSLinks(FileNames="JSONExceptions.css") public abstract class JsonBindingObjException extends JsonBindingException { /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX> */ public static final long serialVersionUID = 1; /** * <EMBED CLASS='external-html' DATA-FILE-ID=EXPF> * * <BR /><BR />The <B>{@link JsonObject}</B> property-name that has caused this exception to * throw. */ public final String propertyName; /** * Constructs a {@code JsonBindingObjException} with no specified detail messsage, * and the user-provided convenience-field values. * * @param errorSourceJsonObject <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJO> * @param propertyName <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_PN> * @param expectedJsonType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EJT> * @param valueRetrieved <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_VR> * @param methodReturnJavaType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT> * @param endingNote <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EN> */ public JsonBindingObjException( JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote ) { super( BASE_MESSAGE_OBJ( errorSourceJsonObject, propertyName, expectedJsonType, valueRetrieved, methodReturnJavaType, endingNote ), errorSourceJsonObject, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.propertyName = propertyName; } /** * Constructs a {@code JsonBindingObjException} with the specified detail message, and * user-provided convenience-field values. * * @param message the detail message. * @param errorSourceJsonObject <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJO> * @param propertyName <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_PN> * @param expectedJsonType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EJT> * @param valueRetrieved <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_VR> * @param methodReturnJavaType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT> */ public JsonBindingObjException( String message, JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType ) { super( message, errorSourceJsonObject, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.propertyName = propertyName; } /** * Constructs a new {@code JsonBindingObjException} with the specified detail message and cause * * <BR /><BR /><B>NOTE:</B> The detail message associated with cause is not automatically * incorporated in this exception's detail message. * * @param message The detail message (which is saved for later retrieval by the * {@code Throwable.getMessage()} method). * * @param cause the cause (which is saved for later retrieval by the * {@code Throwable.getCause()} method). (A null value is permitted, and indicates that the * cause is nonexistent or unknown.) * * @param errorSourceJsonObject <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJO> * @param propertyName <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_PN> * @param expectedJsonType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EJT> * @param valueRetrieved <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_VR> * @param methodReturnJavaType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT> */ public JsonBindingObjException( String message, Throwable cause, JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType ) { super( message, cause, errorSourceJsonObject, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.propertyName = propertyName; } /** * Constructs a new {@code JsonBindingObjException} with the specified cause and a detail * message of {@code (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. * * @param cause The cause (which is saved for later retrieval by the * {@code Throwable.getCause()} method). (A null value is permitted, and indicates that the * cause is nonexistent or unknown.) * * @param errorSourceJsonObject <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJO> * @param propertyName <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_PN> * @param expectedJsonType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EJT> * @param valueRetrieved <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_VR> * @param methodReturnJavaType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT> * @param endingNote <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EN> */ public JsonBindingObjException( Throwable cause, JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote ) { super( BASE_MESSAGE_OBJ( errorSourceJsonObject, propertyName, expectedJsonType, valueRetrieved, methodReturnJavaType, endingNote, cause ), cause, errorSourceJsonObject, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.propertyName = propertyName; } /** * A simple helper method for printing a consistent error messge using the input-data * convenience fields of <B>{@code JsonArray's}</B>. * * @param errorSourceJsonObject <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJO> * @param propertyName <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_PN> * @param expectedJsonType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EJT> * @param valueRetrieved <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_VR> * @param methodReturnJavaType <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT> * @param endingNote <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_EN> * @param causes Optional Parameter. At most 1 cause is printed. * * @return The error message {@code String}. */ protected static String BASE_MESSAGE_OBJ( JsonObject errorSourceJsonObject, String propertyName, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote, Throwable... causes ) { return ((endingNote != null) ? endingNote : "") +"\n" + CAUSE_MESSAGE(causes) + "\tFound In JsonObject: " + ABBREV_STRUCT(errorSourceJsonObject) + "\n" + "\tProperty-Name: " + propertyName + "\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" ); } } |