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 207 208 209 210 | package Torello.Java.JSON; import javax.json.*; /** * The parent class of all Json Binding Exceptions that are used for <B>{@link JsonArray}</B> * element 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=JsonArray DATA-TYPE=Array DATA-TYPE_ABBREV=Arr> * <EMBED CLASS='external-html' DATA-FILE-ID=JE_FIELD_B_ARR> */ @Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="JE_B_UL") @Torello.JavaDoc.CSSLinks(FileNames="JSONExceptions.css") public abstract class JsonBindingArrException 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 />This is the array index into the source <B>{@code JsonArray}</B> which contained * the element (or lack-there-of) that has caused this exception. */ public final int index; /** * Constructs a {@code JsonBindingArrException} with no specified detail messsage, * and the user-provided convenience-field values. * * @param errorSourceJsonArray <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA> * @param index <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I> * @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 JsonBindingArrException( JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote ) { super( BASE_MESSAGE_ARR( errorSourceJsonArray, index, expectedJsonType, valueRetrieved, methodReturnJavaType, endingNote ), errorSourceJsonArray, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.index = index; } /** * Constructs a {@code JsonBindingArrException} with the specified detail message, and * user-provided convenience-field values. * * @param message the detail message. * @param errorSourceJsonArray <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA> * @param index <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I> * @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 JsonBindingArrException( String message, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType ) { super( message, errorSourceJsonArray, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.index = index; } /** * Constructs a new {@code JsonBindingArrException} with the specified detail message and cause * * <BR /><BR /><B CLASS=JDDescLabel>NOTE:</B> * * <BR /><BR />The detail message associated with cause is not automatically incorporated into * 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 errorSourceJsonArray <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA> * @param index <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I> * @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 JsonBindingArrException( String message, Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType ) { super( message, cause, errorSourceJsonArray, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.index = index; } /** * Constructs a new {@code JsonBindingArrException} 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). * * <BR /><BR />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 errorSourceJsonArray <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA> * @param index <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I> * @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 JsonBindingArrException( Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote ) { super( BASE_MESSAGE_ARR( errorSourceJsonArray, index, expectedJsonType, valueRetrieved, methodReturnJavaType, endingNote, cause ), cause, errorSourceJsonArray, expectedJsonType, valueRetrieved, methodReturnJavaType ); this.index = index; } /** * A simple helper method for printing a consistent error messge using the input-data * convenience fields of <B>{@code JsonArray's}</B>. * * @param errorSourceJsonArray <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA> * @param index <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I> * @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_ARR( JsonArray errorSourceJsonArray, int index, JsonValue.ValueType expectedJsonType, JsonValue valueRetrieved, Class<?> methodReturnJavaType, String endingNote, Throwable... causes // This is an optional parameter ) { return ((endingNote != null) ? endingNote : "") +"\n" + CAUSE_MESSAGE(causes) + "\tFound In JsonArray: " + ABBREV_STRUCT(errorSourceJsonArray) + "\n" + "\tAt Index: " + index + "\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" ); } } |