001package Torello.JSON;
002
003import static javax.json.JsonValue.ValueType.*;
004
005import Torello.JavaDoc.Annotations.IntoHTMLTable;
006import static Torello.JavaDoc.Annotations.IntoHTMLTable.Background.BlueDither;
007import static Torello.JavaDoc.Annotations.IntoHTMLTable.Background.GreenDither;
008
009import javax.json.JsonArray;
010import javax.json.JsonObject;
011import javax.json.JsonValue;
012
013// Used in JavaDoc references only
014import javax.json.JsonString;
015import javax.json.JsonNumber;
016
017import java.util.function.Function;
018
019
020/**
021 * Utilities for parsing &amp; converting <B><I>{@link JsonString}'s</I>
022 * <SPAN STYLE='color: red;'>or</SPAN> <I>{@link JsonNumber}'s</I></B> into Java
023 * Boxed-Primitive Types.
024 * 
025 * <EMBED CLASS='external-html' DATA-FILE-ID=ALL_CLASSES_NOTE>
026 * <EMBED CLASS='external-html' DATA-FILE-ID=RORP_BOXED_JSON>
027 * <EMBED CLASS='external-html' DATA-FILE-ID=RORP_BOXED_PTABLE>
028 * <EMBED CLASS='external-html' DATA-CH='java.lang.Character' DATA-FILE-ID=JAVA_LANG_CHAR>
029 * 
030 * @see JsonObject
031 * @see JsonArray
032 */
033@Torello.JavaDoc.Annotations.StaticFunctional
034public class RorPBoxedJSON
035{
036    private RorPBoxedJSON() { }
037
038
039    // ****************************************************************************************
040    // ****************************************************************************************
041    // JsonArray index location to Boxed Primitive, ACCEPTS USER FLAGS
042    // ****************************************************************************************
043    // ****************************************************************************************
044
045
046    /**
047     * <EMBED CLASS='external-html' DATA-TYPE=Integer DATA-FILE-ID=RORP_BOXED_WF_JA>
048     * @see ReadBoxedJSON#getInteger(JsonArray, int, int, int)
049     * @see ParseBoxedJSON#parseInteger(JsonArray, int, int, int, Function)
050     */
051    @IntoHTMLTable(
052        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
053                "and translate to a Boxed Integer",
054        background=BlueDither
055    )
056    public static Integer getInteger(
057            final JsonArray                 ja,
058            final int                       i,
059            final int                       FLAGS,
060            final int                       defaultValue,
061            final Function<String, Integer> optionalParser
062        )
063    {
064        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
065            ? ReadBoxedJSON.getInteger(ja, i, FLAGS, defaultValue)
066            : ParseBoxedJSON.parseInteger(ja, i, FLAGS, defaultValue, optionalParser);
067    }
068
069    /**
070     * <EMBED CLASS='external-html' DATA-TYPE=Long DATA-FILE-ID=RORP_BOXED_WF_JA>
071     * @see ReadBoxedJSON#getLong(JsonArray, int, int, long)
072     * @see ParseBoxedJSON#parseLong(JsonArray, int, int, long, Function)
073     */
074    @IntoHTMLTable(
075        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
076                "and translate to a Boxed Long Integer",
077        background=GreenDither
078    )
079    public static Long getLong(
080            final JsonArray                 ja,
081            final int                       i,
082            final int                       FLAGS,
083            final long                      defaultValue,
084            final Function<String, Long>    optionalParser
085        )
086    {
087        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
088            ? ReadBoxedJSON.getLong(ja, i, FLAGS, defaultValue)
089            : ParseBoxedJSON.parseLong(ja, i, FLAGS, defaultValue, optionalParser);
090    }
091
092    /**
093     * <EMBED CLASS='external-html' DATA-TYPE=Short DATA-FILE-ID=RORP_BOXED_WF_JA>
094     * @see ReadBoxedJSON#getShort(JsonArray, int, int, short)
095     * @see ParseBoxedJSON#parseShort(JsonArray, int, int, short, Function)
096     */
097    @IntoHTMLTable(
098        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
099                "and translate to a Boxed Short Integer",
100        background=BlueDither
101    )
102    public static Short getShort(
103            final JsonArray                 ja,
104            final int                       i,
105            final int                       FLAGS,
106            final short                     defaultValue,
107            final Function<String, Short>   optionalParser
108        )
109    {
110        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
111            ? ReadBoxedJSON.getShort(ja, i, FLAGS, defaultValue)
112            : ParseBoxedJSON.parseShort(ja, i, FLAGS, defaultValue, optionalParser);
113    }
114
115    /**
116     * <EMBED CLASS='external-html' DATA-TYPE=Byte DATA-FILE-ID=RORP_BOXED_WF_JA>
117     * @see ReadBoxedJSON#getByte(JsonArray, int, int, byte)
118     * @see ParseBoxedJSON#parseByte(JsonArray, int, int, byte, Function)
119     */
120    @IntoHTMLTable(
121        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
122                "and translate to a Boxed Byte",
123        background=GreenDither
124    )
125    public static Byte getByte(
126            final JsonArray                 ja,
127            final int                       i,
128            final int                       FLAGS,
129            final byte                      defaultValue,
130            final Function<String, Byte>    optionalParser
131        )
132    {
133        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
134            ? ReadBoxedJSON.getByte(ja, i, FLAGS, defaultValue)
135            : ParseBoxedJSON.parseByte(ja, i, FLAGS, defaultValue, optionalParser);
136    }
137
138    /**
139     * <EMBED CLASS='external-html' DATA-TYPE=Double DATA-FILE-ID=RORP_BOXED_WF_JA>
140     * @see ReadBoxedJSON#getDouble(JsonArray, int, int, double)
141     * @see ParseBoxedJSON#parseDouble(JsonArray, int, int, double, Function)
142     */
143    @IntoHTMLTable(
144        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
145                "and translate to a Boxed Double",
146        background=BlueDither
147    )
148    public static Double getDouble(
149            final JsonArray                 ja,
150            final int                       i,
151            final int                       FLAGS,
152            final double                    defaultValue,
153            final Function<String, Double>  optionalParser
154        )
155    {
156        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
157            ? ReadBoxedJSON.getDouble(ja, i, FLAGS, defaultValue)
158            : ParseBoxedJSON.parseDouble(ja, i, FLAGS, defaultValue, optionalParser);
159    }
160
161    /**
162     * <EMBED CLASS='external-html' DATA-TYPE=Float DATA-FILE-ID=RORP_BOXED_WF_JA>
163     * @see ReadBoxedJSON#getFloat(JsonArray, int, int, float)
164     * @see ParseBoxedJSON#parseFloat(JsonArray, int, int, float, Function)
165     */
166    @IntoHTMLTable(
167        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
168                "and translate to a Boxed Float",
169        background=GreenDither
170    )
171    public static Float getFloat(
172            final JsonArray                 ja,
173            final int                       i,
174            final int                       FLAGS,
175            final float                     defaultValue,
176            final Function<String, Float>   optionalParser
177        )
178    {
179        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
180            ? ReadBoxedJSON.getFloat(ja, i, FLAGS, defaultValue)
181            : ParseBoxedJSON.parseFloat(ja, i, FLAGS, defaultValue, optionalParser);
182    }
183
184    /**
185     * <EMBED CLASS='external-html' DATA-TYPE=Boolean DATA-FILE-ID=RORP_BOXED_WF_JA>
186     * @see ReadBoxedJSON#getBoolean(JsonArray, int, int, boolean)
187     * @see ParseBoxedJSON#parseBoolean(JsonArray, int, int, boolean, Function)
188     */
189    @IntoHTMLTable(
190        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
191                "and translate to a Boxed Boolean",
192        background=BlueDither
193    )
194    public static Boolean getBoolean(
195            final JsonArray                 ja,
196            final int                       i,
197            final int                       FLAGS,
198            final boolean                   defaultValue,
199            final Function<String, Boolean> optionalParser
200        )
201    {
202        return ((i >= ja.size()) ||  (ja.get(i).getValueType() != STRING))
203            ? ReadBoxedJSON.getBoolean(ja, i, FLAGS, defaultValue)
204            : ParseBoxedJSON.parseBoolean(ja, i, FLAGS, defaultValue, optionalParser);
205    }
206
207
208    // ****************************************************************************************
209    // ****************************************************************************************
210    // JsonObject Property to Boxed Primitive, ACCEPTS USER FLAGS
211    // ****************************************************************************************
212    // ****************************************************************************************
213
214
215    /**
216     * <EMBED CLASS='external-html' DATA-TYPE=Integer DATA-FILE-ID=RORP_BOXED_WF_JO>
217     * @see ReadBoxedJSON#getInteger(JsonObject, String, int, int)
218     * @see ParseBoxedJSON#parseInteger(JsonObject, String, int, int, Function)
219     */
220    @IntoHTMLTable(
221        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
222                "and translate to a Boxed Integer",
223        background=GreenDither
224    )
225    public static Integer getInteger(
226            final JsonObject                jo,
227            final String                    propertyName,
228            final int                       FLAGS,
229            final int                       defaultValue,
230            final Function<String, Integer> optionalParser
231        )
232    {
233        final JsonValue jv = jo.get(propertyName);
234
235        return ((jv == null) || (jv.getValueType() != STRING))
236            ? ReadBoxedJSON.getInteger(jo, propertyName, FLAGS, defaultValue)
237            : ParseBoxedJSON.parseInteger(jo, propertyName, FLAGS, defaultValue, optionalParser);
238    }
239
240    /**
241     * <EMBED CLASS='external-html' DATA-TYPE=Long DATA-FILE-ID=RORP_BOXED_WF_JO>
242     * @see ReadBoxedJSON#getLong(JsonObject, String, int, long)
243     * @see ParseBoxedJSON#parseLong(JsonObject, String, int, long, Function)
244     */
245    @IntoHTMLTable(
246        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
247                "and translate to a Boxed Long Integer",
248        background=BlueDither
249    )
250    public static Long getLong(
251            final JsonObject                jo,
252            final String                    propertyName,
253            final int                       FLAGS,
254            final long                      defaultValue,
255            final Function<String, Long>    optionalParser
256        )
257    {
258        final JsonValue jv = jo.get(propertyName);
259
260        return ((jv == null) || (jv.getValueType() != STRING))
261            ? ReadBoxedJSON.getLong(jo, propertyName, FLAGS, defaultValue)
262            : ParseBoxedJSON.parseLong(jo, propertyName, FLAGS, defaultValue, optionalParser);
263    }
264
265    /**
266     * <EMBED CLASS='external-html' DATA-TYPE=Short DATA-FILE-ID=RORP_BOXED_WF_JO>
267     * @see ReadBoxedJSON#getShort(JsonObject, String, int, short)
268     * @see ParseBoxedJSON#parseShort(JsonObject, String, int, short, Function)
269     */
270    @IntoHTMLTable(
271        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
272                "and translate to a Boxed Short Integer",
273        background=GreenDither
274    )
275    public static Short getShort(
276            final JsonObject                jo,
277            final String                    propertyName,
278            final int                       FLAGS,
279            final short                     defaultValue,
280            final Function<String, Short>   optionalParser
281        )
282    {
283        final JsonValue jv = jo.get(propertyName);
284
285        return ((jv == null) || (jv.getValueType() != STRING))
286            ? ReadBoxedJSON.getShort(jo, propertyName, FLAGS, defaultValue)
287            : ParseBoxedJSON.parseShort(jo, propertyName, FLAGS, defaultValue, optionalParser);
288    }
289
290    /**
291     * <EMBED CLASS='external-html' DATA-TYPE=Byte DATA-FILE-ID=RORP_BOXED_WF_JO>
292     * @see ReadBoxedJSON#getByte(JsonObject, String, int, byte)
293     * @see ParseBoxedJSON#parseByte(JsonObject, String, int, byte, Function)
294     */
295    @IntoHTMLTable(
296        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
297                "and translate to a Boxed Byte",
298        background=BlueDither
299    )
300    public static Byte getByte(
301            final JsonObject                jo,
302            final String                    propertyName,
303            final int                       FLAGS,
304            final byte                      defaultValue,
305            final Function<String, Byte>    optionalParser
306        )
307    {
308        final JsonValue jv = jo.get(propertyName);
309
310        return ((jv == null) || (jv.getValueType() != STRING))
311            ? ReadBoxedJSON.getByte(jo, propertyName, FLAGS, defaultValue)
312            : ParseBoxedJSON.parseByte(jo, propertyName, FLAGS, defaultValue, optionalParser);
313    }
314
315    /**
316     * <EMBED CLASS='external-html' DATA-TYPE=Double DATA-FILE-ID=RORP_BOXED_WF_JO>
317     * @see ReadBoxedJSON#getDouble(JsonObject, String, int, double)
318     * @see ParseBoxedJSON#parseDouble(JsonObject, String, int, double, Function)
319     */
320    @IntoHTMLTable(
321        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
322                "and translate to a Boxed Double",
323        background=GreenDither
324    )
325    public static Double getDouble(
326            final JsonObject                jo,
327            final String                    propertyName,
328            final int                       FLAGS,
329            final double                    defaultValue,
330            final Function<String, Double>  optionalParser
331        )
332    {
333        final JsonValue jv = jo.get(propertyName);
334
335        return ((jv == null) || (jv.getValueType() != STRING))
336            ? ReadBoxedJSON.getDouble(jo, propertyName, FLAGS, defaultValue)
337            : ParseBoxedJSON.parseDouble(jo, propertyName, FLAGS, defaultValue, optionalParser);
338    }
339
340    /**
341     * <EMBED CLASS='external-html' DATA-TYPE=Float DATA-FILE-ID=RORP_BOXED_WF_JO>
342     * @see ReadBoxedJSON#getFloat(JsonObject, String, int, float)
343     * @see ParseBoxedJSON#parseFloat(JsonObject, String, int, float, Function)
344     */
345    @IntoHTMLTable(
346        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
347                "and translate to a Boxed Float",
348        background=BlueDither
349    )
350    public static Float getFloat(
351            final JsonObject                jo,
352            final String                    propertyName,
353            final int                       FLAGS,
354            final float                     defaultValue,
355            final Function<String, Float>   optionalParser
356        )
357    {
358        final JsonValue jv = jo.get(propertyName);
359
360        return ((jv == null) || (jv.getValueType() != STRING))
361            ? ReadBoxedJSON.getFloat(jo, propertyName, FLAGS, defaultValue)
362            : ParseBoxedJSON.parseFloat(jo, propertyName, FLAGS, defaultValue, optionalParser);
363    }
364
365    /**
366     * <EMBED CLASS='external-html' DATA-TYPE=Boolean DATA-FILE-ID=RORP_BOXED_WF_JO>
367     * @see ReadBoxedJSON#getBoolean(JsonObject, String, int, boolean)
368     * @see ParseBoxedJSON#parseBoolean(JsonObject, String, int, boolean, Function)
369     */
370    @IntoHTMLTable(
371        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
372                "and translate to a Boxed Boolean",
373        background=GreenDither
374    )
375    public static Boolean getBoolean(
376            final JsonObject                jo,
377            final String                    propertyName,
378            final int                       FLAGS,
379            final boolean                   defaultValue,
380            final Function<String, Boolean> optionalParser
381        )
382    {
383        final JsonValue jv = jo.get(propertyName);
384
385        return ((jv == null) || (jv.getValueType() != STRING))
386            ? ReadBoxedJSON.getBoolean(jo, propertyName, FLAGS, defaultValue)
387            : ParseBoxedJSON.parseBoolean(jo, propertyName, FLAGS, defaultValue, optionalParser);
388    }
389
390
391    // ****************************************************************************************
392    // ****************************************************************************************
393    // JsonArray index location to Boxed Primitive, NO USER FLAGS
394    // ****************************************************************************************
395    // ****************************************************************************************
396
397
398    /**
399     * <EMBED CLASS='external-html' DATA-TYPE=Integer DATA-FILE-ID=RORP_BOXED_NF_JA>
400     * @see ReadBoxedJSON#getInteger(JsonArray, int)
401     * @see ParseBoxedJSON#parseInteger(JsonArray, int)
402     */
403    @IntoHTMLTable(
404        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
405                "and translate to a Boxed Integer",
406        background=BlueDither
407    )
408    public static Integer getInteger(final JsonArray ja, final int i)
409    {
410        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
411            ? ReadBoxedJSON.getInteger(ja, i)
412            : ParseBoxedJSON.parseInteger(ja, i);
413    }
414
415    /**
416     * <EMBED CLASS='external-html' DATA-TYPE=Long DATA-FILE-ID=RORP_BOXED_NF_JA>
417     * @see ReadBoxedJSON#getLong(JsonArray, int)
418     * @see ParseBoxedJSON#parseLong(JsonArray, int)
419     */
420    @IntoHTMLTable(
421        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
422                "and translate to a Boxed Long Integer",
423        background=GreenDither
424    )
425    public static Long getLong(final JsonArray ja, final int i)
426    {
427        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
428            ? ReadBoxedJSON.getLong(ja, i)
429            : ParseBoxedJSON.parseLong(ja, i);
430    }
431
432    /**
433     * <EMBED CLASS='external-html' DATA-TYPE=Short DATA-FILE-ID=RORP_BOXED_NF_JA>
434     * @see ReadBoxedJSON#getShort(JsonArray, int)
435     * @see ParseBoxedJSON#parseShort(JsonArray, int)
436     */
437    @IntoHTMLTable(
438        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
439                "and translate to a Boxed Short Integer",
440        background=BlueDither
441    )
442    public static Short getShort(final JsonArray ja, final int i)
443    {
444        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
445            ? ReadBoxedJSON.getShort(ja, i)
446            : ParseBoxedJSON.parseShort(ja, i);
447    }
448
449    /**
450     * <EMBED CLASS='external-html' DATA-TYPE=Byte DATA-FILE-ID=RORP_BOXED_NF_JA>
451     * @see ReadBoxedJSON#getByte(JsonArray, int)
452     * @see ParseBoxedJSON#parseByte(JsonArray, int)
453     */
454    @IntoHTMLTable(
455        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
456                "and translate to a Boxed Byte",
457        background=GreenDither
458    )
459    public static Byte getByte(final JsonArray ja, final int i)
460    {
461        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
462            ? ReadBoxedJSON.getByte(ja, i)
463            : ParseBoxedJSON.parseByte(ja, i);
464    }
465
466    /**
467     * <EMBED CLASS='external-html' DATA-TYPE=Double DATA-FILE-ID=RORP_BOXED_NF_JA>
468     * @see ReadBoxedJSON#getDouble(JsonArray, int)
469     * @see ParseBoxedJSON#parseDouble(JsonArray, int)
470     */
471    @IntoHTMLTable(
472        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
473                "and translate to a Boxed Double",
474        background=BlueDither
475    )
476    public static Double getDouble(final JsonArray ja, final int i)
477    {
478        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
479            ? ReadBoxedJSON.getDouble(ja, i)
480            : ParseBoxedJSON.parseDouble(ja, i);
481    }
482
483    /**
484     * <EMBED CLASS='external-html' DATA-TYPE=Float DATA-FILE-ID=RORP_BOXED_NF_JA>
485     * @see ReadBoxedJSON#getFloat(JsonArray, int)
486     * @see ParseBoxedJSON#parseFloat(JsonArray, int)
487     */
488    @IntoHTMLTable(
489        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
490                "and translate to a Boxed Float",
491        background=GreenDither
492    )
493    public static Float getFloat(final JsonArray ja, final int i)
494    {
495        return ((i >= ja.size()) || (ja.get(i).getValueType() != STRING))
496            ? ReadBoxedJSON.getFloat(ja, i)
497            : ParseBoxedJSON.parseFloat(ja, i);
498    }
499
500    /**
501     * <EMBED CLASS='external-html' DATA-TYPE=Boolean DATA-FILE-ID=RORP_BOXED_NF_JA>
502     * @see ReadBoxedJSON#getBoolean(JsonArray, int)
503     * @see ParseBoxedJSON#parseBoolean(JsonArray, int)
504     */
505    @IntoHTMLTable(
506        title=  "Read either a JsonNumber or a JsonString from a JsonArray, "+
507                "and translate to a Boxed Boolean",
508        background=BlueDither
509    )
510    public static Boolean getBoolean(final JsonArray ja, final int i)
511    {
512        return ((i >= ja.size()) ||  (ja.get(i).getValueType() != STRING))
513            ? ReadBoxedJSON.getBoolean(ja, i)
514            : ParseBoxedJSON.parseBoolean(ja, i);
515    }
516
517
518    // ****************************************************************************************
519    // ****************************************************************************************
520    // JsonObject Property to Boxed Primitive, NO USER FLAGS
521    // ****************************************************************************************
522    // ****************************************************************************************
523
524
525    /**
526     * <EMBED CLASS='external-html' DATA-TYPE=Integer DATA-FILE-ID=RORP_BOXED_NF_JO>
527     * @see ReadBoxedJSON#getInteger(JsonObject, String, boolean)
528     * @see ParseBoxedJSON#parseInteger(JsonObject, String, boolean)
529     */
530    @IntoHTMLTable(
531        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
532                "and translate to a Boxed Integer",
533        background=GreenDither
534    )
535    public static Integer getInteger
536        (final JsonObject jo, final String propertyName, final boolean isOptional)
537    {
538        final JsonValue jv = jo.get(propertyName);
539
540        return ((jv == null) || (jv.getValueType() != STRING))
541            ? ReadBoxedJSON.getInteger(jo, propertyName, isOptional)
542            : ParseBoxedJSON.parseInteger(jo, propertyName, isOptional);
543    }
544
545    /**
546     * <EMBED CLASS='external-html' DATA-TYPE=Long DATA-FILE-ID=RORP_BOXED_NF_JO>
547     * @see ReadBoxedJSON#getLong(JsonObject, String, boolean)
548     * @see ParseBoxedJSON#parseLong(JsonObject, String, boolean)
549     */
550    @IntoHTMLTable(
551        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
552                "and translate to a Boxed Long Integer",
553        background=BlueDither
554    )
555    public static Long getLong
556        (final JsonObject jo, final String propertyName, final boolean isOptional)
557    {
558        final JsonValue jv = jo.get(propertyName);
559
560        return ((jv == null) || (jv.getValueType() != STRING))
561            ? ReadBoxedJSON.getLong(jo, propertyName, isOptional)
562            : ParseBoxedJSON.parseLong(jo, propertyName, isOptional);
563    }
564
565    /**
566     * <EMBED CLASS='external-html' DATA-TYPE=Short DATA-FILE-ID=RORP_BOXED_NF_JO>
567     * @see ReadBoxedJSON#getShort(JsonObject, String, boolean)
568     * @see ParseBoxedJSON#parseShort(JsonObject, String, boolean)
569     */
570    @IntoHTMLTable(
571        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
572                "and translate to a Boxed Short Integer",
573        background=GreenDither
574    )
575    public static Short getShort
576        (final JsonObject jo, final String propertyName, final boolean isOptional)
577    {
578        final JsonValue jv = jo.get(propertyName);
579
580        return ((jv == null) || (jv.getValueType() != STRING))
581            ? ReadBoxedJSON.getShort(jo, propertyName, isOptional)
582            : ParseBoxedJSON.parseShort(jo, propertyName, isOptional);
583    }
584
585    /**
586     * <EMBED CLASS='external-html' DATA-TYPE=Byte DATA-FILE-ID=RORP_BOXED_NF_JO>
587     * @see ReadBoxedJSON#getByte(JsonObject, String, boolean)
588     * @see ParseBoxedJSON#parseByte(JsonObject, String, boolean)
589     */
590    @IntoHTMLTable(
591        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
592                "and translate to a Boxed Byte",
593        background=BlueDither
594    )
595    public static Byte getByte
596        (final JsonObject jo, final String propertyName, final boolean isOptional)
597    {
598        final JsonValue jv = jo.get(propertyName);
599
600        return ((jv == null) || (jv.getValueType() != STRING))
601            ? ReadBoxedJSON.getByte(jo, propertyName, isOptional)
602            : ParseBoxedJSON.parseByte(jo, propertyName, isOptional);
603    }
604
605    /**
606     * <EMBED CLASS='external-html' DATA-TYPE=Double DATA-FILE-ID=RORP_BOXED_NF_JO>
607     * @see ReadBoxedJSON#getDouble(JsonObject, String, boolean)
608     * @see ParseBoxedJSON#parseDouble(JsonObject, String, boolean)
609     */
610    @IntoHTMLTable(
611        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
612                "and translate to a Boxed Double",
613        background=GreenDither
614    )
615    public static Double getDouble
616        (final JsonObject jo, final String propertyName, final boolean isOptional)
617    {
618        final JsonValue jv = jo.get(propertyName);
619
620        return ((jv == null) || (jv.getValueType() != STRING))
621            ? ReadBoxedJSON.getDouble(jo, propertyName, isOptional)
622            : ParseBoxedJSON.parseDouble(jo, propertyName, isOptional);
623    }
624
625    /**
626     * <EMBED CLASS='external-html' DATA-TYPE=Float DATA-FILE-ID=RORP_BOXED_NF_JO>
627     * @see ReadBoxedJSON#getFloat(JsonObject, String, boolean)
628     * @see ParseBoxedJSON#parseFloat(JsonObject, String, boolean)
629     */
630    @IntoHTMLTable(
631        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
632                "and translate to a Boxed Float",
633        background=BlueDither
634    )
635    public static Float getFloat
636        (final JsonObject jo, final String propertyName, final boolean isOptional)
637    {
638        final JsonValue jv = jo.get(propertyName);
639
640        return ((jv == null) || (jv.getValueType() != STRING))
641            ? ReadBoxedJSON.getFloat(jo, propertyName, isOptional)
642            : ParseBoxedJSON.parseFloat(jo, propertyName, isOptional);
643    }
644
645    /**
646     * <EMBED CLASS='external-html' DATA-TYPE=Boolean DATA-FILE-ID=RORP_BOXED_NF_JO>
647     * @see ReadBoxedJSON#getBoolean(JsonObject, String, boolean)
648     * @see ParseBoxedJSON#parseBoolean(JsonObject, String, boolean)
649     */
650    @IntoHTMLTable(
651        title=  "Read either a JsonNumber or a JsonString from a JsonObject, "+
652                "and translate to a Boxed Boolean",
653        background=GreenDither
654    )
655    public static Boolean getBoolean
656        (final JsonObject jo, final String propertyName, final boolean isOptional)
657    {
658        final JsonValue jv = jo.get(propertyName);
659
660        return ((jv == null) || (jv.getValueType() != STRING))
661            ? ReadBoxedJSON.getBoolean(jo, propertyName, isOptional)
662            : ParseBoxedJSON.parseBoolean(jo, propertyName, isOptional);
663    }
664
665}