Class ArrayBuilder
java.lang.Object
org.apache.commons.jexl3.internal.ArrayBuilder
- All Implemented Interfaces:
JexlArithmetic.ArrayBuilder
Helper class to create typed arrays.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intNumber of added items.The boxing types to primitive conversion map.protected Class<?> The intended class array.protected final booleanExtended?protected booleanWhether the array stores numbers.private static final intThe number of primitive types.protected booleanWhether we can try unboxing.protected final Object[]The untyped list of items being added. -
Constructor Summary
ConstructorsConstructorDescriptionArrayBuilder(int size) Creates a new builder.ArrayBuilder(int size, boolean extended) Creates a new builder. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a literal to the array.create(boolean e) Creates the actual "array" instance.protected Class<?> getCommonSuperClass(Class<?> baseClass, Class<?> other) Computes the best super class/super interface.protected <T> List<T> Creates a new list (aka extended array)/protected static Class<?> unboxingClass(Class<?> parm) Gets the primitive type of given class (when it exists).
-
Field Details
-
PRIMITIVE_SIZE
private static final int PRIMITIVE_SIZEThe number of primitive types.- See Also:
-
BOXING_CLASSES
The boxing types to primitive conversion map. -
commonClass
The intended class array. -
isNumber
protected boolean isNumberWhether the array stores numbers. -
unboxing
protected boolean unboxingWhether we can try unboxing. -
untyped
The untyped list of items being added. -
added
protected int addedNumber of added items. -
extended
protected final boolean extendedExtended?
-
-
Constructor Details
-
ArrayBuilder
public ArrayBuilder(int size) Creates a new builder.- Parameters:
size- the exact array size
-
ArrayBuilder
public ArrayBuilder(int size, boolean extended) Creates a new builder.- Parameters:
size- the exact array sizeextended- whether the array is extended
-
-
Method Details
-
unboxingClass
Gets the primitive type of given class (when it exists).- Parameters:
parm- a class- Returns:
- the primitive type or null it the argument is not unboxable
-
add
Description copied from interface:JexlArithmetic.ArrayBuilderAdds a literal to the array.- Specified by:
addin interfaceJexlArithmetic.ArrayBuilder- Parameters:
value- the item to add
-
create
Description copied from interface:JexlArithmetic.ArrayBuilderCreates the actual "array" instance.- Specified by:
createin interfaceJexlArithmetic.ArrayBuilder- Parameters:
e- true when the last argument is ', ...'- Returns:
- the array
-
getCommonSuperClass
Computes the best super class/super interface.Used to try and maintain type safe arrays.
- Parameters:
baseClass- the baseClassother- another class- Returns:
- a common ancestor, class or interface, worst case being class Object
-
newList
Creates a new list (aka extended array)/- Type Parameters:
T- the type- Parameters:
clazz- the classsize- the size- Returns:
- the instance
-