Package Torello.JSON
Class RJInternal
- java.lang.Object
-
- Torello.JSON.RJInternal
-
public class RJInternal extends java.lang.Object
Class which provides a series of helper functions for all JSON Type-Binding Reader Classes.100% of the helper-methods that appear here are protected, and cannot be accessed outside of this package. They are included in the documentation solely for the purposes of (if you happen to be interested) letting you know how the JSON-Tools work. It is not intended that programmers would ever need to invoke, directly, any of the methods in this class!
Hi-Lited Source-Code:- View Here: Torello/JSON/RJInternal.java
- Open New Browser-Tab: Torello/JSON/RJInternal.java
File Size: 18,151 Bytes Line Count: 443 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 17 Method(s), 17 declared static
- 0 Field(s)
-
-
Method Summary
FLAG Methods: Flag-Checking Helper-Methods Modifier and Type Method protected static <T> TIOOBEX(JsonArray ja, int index, T defaultValue, int FLAGS)protected static <T> TJNAEX(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)protected static <T> TJNOEX(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)protected static <T> TJPMEX(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, Class<T> returnClass)protected static <T> TJSPAEX(Exception e, JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue retrievedValue, Class<T> returnClass)protected static <T> TJSPOEX(Exception e, JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue retrievedValue, Class<T> returnClass)protected static <T> TJTAEX(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, Class<T> returnClass)protected static <T> TJTOEX(JsonObject jo, String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, Class<T> returnClass)HELPER Methods: Assorted Extras Modifier and Type Method protected static byteBYTE_FROM_LONG(long l)protected static doubleDOUBLE_WITH_CHECK(BigDecimal bd)protected static doubleDOUBLE_WITH_CHECK(JsonNumber jn)protected static floatFLOAT_WITH_CHECK(BigDecimal bd)protected static floatFLOAT_WITH_CHECK(JsonNumber jn)protected static shortSHORT_FROM_LONG(long l)
-
-
-
Method Detail
-
DOUBLE_WITH_CHECK
protected static double DOUBLE_WITH_CHECK(JsonNumber jn)
- Code:
- Exact Method Body:
return DOUBLE_WITH_CHECK(jn.bigDecimalValue());
-
DOUBLE_WITH_CHECK
protected static double DOUBLE_WITH_CHECK(java.math.BigDecimal bd)
Converts aBigDecimalinto a Javadouble- Parameters:
bd- AnyBigDecimal- Returns:
- Java
doubleprimitive - Throws:
java.lang.ArithmeticException- If infinity is returned from the call tocode BigDecimal.doubleValue()- Code:
- Exact Method Body:
double ret = bd.doubleValue(); if (Double.isInfinite(ret)) throwAE_INFINITY(bd, "double"); if (BigDecimal.valueOf(ret).compareTo(bd) != 0) throwAE_PRECISION(bd, "double"); return ret;
-
FLOAT_WITH_CHECK
protected static float FLOAT_WITH_CHECK(JsonNumber jn)
Converts aJsonNumberinto a Javafloat- Parameters:
jn- AnyJsonNumber- Returns:
- java
floatprimitive - Throws:
java.lang.ArithmeticException- If infinity is returned from the call toBigDecimal.floatValue()- See Also:
JsonNumber.bigDecimalValue()- Code:
- Exact Method Body:
return FLOAT_WITH_CHECK(jn.bigDecimalValue());
-
FLOAT_WITH_CHECK
protected static float FLOAT_WITH_CHECK(java.math.BigDecimal bd)
Converts aBigDecimalinto a Javafloat- Parameters:
bd- AnyBigDecimal- Returns:
- Java
floatprimitive - Throws:
java.lang.ArithmeticException- If infinity is returned from the call tocode BigDecimal.floatValue()- Code:
- Exact Method Body:
float ret = bd.floatValue(); if (Float.isInfinite(ret)) throwAE_INFINITY(bd, "float"); if (BigDecimal.valueOf(ret).compareTo(bd) != 0) throwAE_PRECISION(bd, "float"); return ret;
-
BYTE_FROM_LONG
protected static byte BYTE_FROM_LONG(long l)
Converts alonginto a Javabyte- Parameters:
l- A long that has been produced byJsonNumber.longValueExact()- Returns:
- A valid
byteprimitive - Throws:
java.lang.ArithmeticException- If thelongdoesn't fit into abyte- Code:
- Exact Method Body:
if ((l < Byte.MIN_VALUE) || (l > Byte.MAX_VALUE)) throw new ArithmeticException("byte out of range: " + l); return (byte) l;
-
SHORT_FROM_LONG
protected static short SHORT_FROM_LONG(long l)
Converts alonginto a Javashort- Parameters:
l- A long that has been produced byJsonNumber.longValueExact()- Returns:
- A valid
shortprimitive - Throws:
java.lang.ArithmeticException- If thelongdoesn't fit into ashort- Code:
- Exact Method Body:
if ((l < Short.MIN_VALUE) || (l > Short.MAX_VALUE)) throw new ArithmeticException("short out of range: " + l); return (short) l;
-
IOOBEX
protected static <T> T IOOBEX(JsonArray ja, int index, T defaultValue, int FLAGS)
Flag Checker forIndexOutOfBoundsException.
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsIndexOutOfBoundsException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
java.lang.IndexOutOfBoundsException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_IOB,JFlag.RETURN_DEFVAL_ON_IOB,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_IOB) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_IOB) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; ja.get(index); // Throws an IndexOutOfBoundsException // If you have reached this statment, this method was not applied properly throw new Torello.Java.UnreachableError();
-
JPMEX
protected static <T> T JPMEX(JsonObject jo, java.lang.String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, java.lang.Class<T> returnClass)
Flag Checker forJsonPropMissingException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonPropMissingException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonPropMissingException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_MISSING,JFlag.RETURN_DEFVAL_ON_MISSING,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_MISSING) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_MISSING) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonPropMissingException(jo, propertyName, expectedType, returnClass);
-
JNAEX
protected static <T> T JNAEX(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, java.lang.Class<T> returnClass)
Flag Checker forJsonNullArrException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonNullArrException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonNullArrException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_NULL,JFlag.RETURN_DEFVAL_ON_NULL,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_NULL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_NULL) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonNullArrException(ja, index, expectedType, returnClass);
-
JNOEX
protected static <T> T JNOEX(JsonObject jo, java.lang.String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, java.lang.Class<T> returnClass)
Flag Checker forJsonNullObjException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonNullObjException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonNullObjException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_NULL,JFlag.RETURN_DEFVAL_ON_NULL,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_NULL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_NULL) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonNullObjException(jo, propertyName, expectedType, returnClass);
-
JTAEX
protected static <T> T JTAEX(JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, java.lang.Class<T> returnClass)
Flag Checker forJsonTypeArrException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonTypeArrException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonTypeArrException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_WRONG_JSONTYPE,JFlag.RETURN_DEFVAL_ON_WRONG_JSONTYPE,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_WRONG_JSONTYPE) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_WRONG_JSONTYPE) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonTypeArrException(ja, index, expectedType, retrievedValue, returnClass);
-
JTOEX
protected static <T> T JTOEX(JsonObject jo, java.lang.String propertyName, T defaultValue, int FLAGS, JsonValue.ValueType expectedType, JsonValue retrievedValue, java.lang.Class<T> returnClass)
Flag Checker forJsonTypeObjException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonNullObjException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonNullObjException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_WRONG_JSONTYPE,JFlag.RETURN_DEFVAL_ON_WRONG_JSONTYPE,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_WRONG_JSONTYPE) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_WRONG_JSONTYPE) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonTypeObjException (jo, propertyName, expectedType, retrievedValue, returnClass);
-
JSPAEX
protected static <T> T JSPAEX(java.lang.Exception e, JsonArray ja, int index, T defaultValue, int FLAGS, JsonValue retrievedValue, java.lang.Class<T> returnClass)
Flag Checker forJsonStrParseArrException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonStrParseArrException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonStrParseArrException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_SPEX,JFlag.RETURN_DEFVAL_ON_SPEX,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_SPEX) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_SPEX) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonStrParseArrException(e, ja, index, retrievedValue, returnClass);
-
JSPOEX
protected static <T> T JSPOEX(java.lang.Exception e, JsonObject jo, java.lang.String propertyName, T defaultValue, int FLAGS, JsonValue retrievedValue, java.lang.Class<T> returnClass)
Flag Checker forJsonStrParseObjException
Checks whether the relevant flags were set in the usersFLAGSparameter, and either returns the appropriate value accordingly, or throwsJsonStrParseObjException.
FLAG PRECEDENCE:
A curosry inspection of the code in this method, below, should explain clearly the rules for the precedence of the flags. For instance, null-return flags always have higher precedence than default-value flags.- Type Parameters:
T- If requested, the default-value is returned, and this is its type.- Returns:
- Can return either the user-provided default-value, or null depending on whether a
match was found in the user's request settings (
'FLAGS'). - Throws:
JsonStrParseObjException- If no flag was set specifying one of the two return-value options.- See Also:
JFlag.RETURN_NULL_ON_SPEX,JFlag.RETURN_DEFVAL_ON_SPEX,JFlag.RETURN_NULL_ON_ANY_ALL,JFlag.RETURN_DEFVAL_ON_ANY_ALL- Code:
- Exact Method Body:
if ((FLAGS & RETURN_NULL_ON_SPEX) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_SPEX) != 0) return defaultValue; if ((FLAGS & RETURN_NULL_ON_ANY_ALL) != 0) return null; if ((FLAGS & RETURN_DEFVAL_ON_ANY_ALL) != 0) return defaultValue; throw new JsonStrParseObjException(e, jo, propertyName, retrievedValue, returnClass);
-
-