Class ArrayBuilder

java.lang.Object
org.apache.commons.jexl3.internal.ArrayBuilder
All Implemented Interfaces:
JexlArithmetic.ArrayBuilder

public class ArrayBuilder extends Object implements JexlArithmetic.ArrayBuilder
Helper class to create typed arrays.
  • Field Details

    • PRIMITIVE_SIZE

      private static final int PRIMITIVE_SIZE
      The number of primitive types.
      See Also:
    • BOXING_CLASSES

      private static final Map<Class<?>,Class<?>> BOXING_CLASSES
      The boxing types to primitive conversion map.
    • commonClass

      protected Class<?> commonClass
      The intended class array.
    • isNumber

      protected boolean isNumber
      Whether the array stores numbers.
    • unboxing

      protected boolean unboxing
      Whether we can try unboxing.
    • untyped

      protected final Object[] untyped
      The untyped list of items being added.
    • added

      protected int added
      Number of added items.
  • Constructor Details

    • ArrayBuilder

      public ArrayBuilder(int size)
      Creates a new builder.
      Parameters:
      size - the exact array size
  • Method Details

    • unboxingClass

      protected static Class<?> unboxingClass(Class<?> parm)
      Gets the primitive type of a given class (when it exists).
      Parameters:
      parm - a class
      Returns:
      the primitive type or null it the argument is not unboxable
    • add

      public void add(Object value)
      Description copied from interface: JexlArithmetic.ArrayBuilder
      Adds a literal to the array.
      Specified by:
      add in interface JexlArithmetic.ArrayBuilder
      Parameters:
      value - the item to add
    • create

      public Object create(boolean extended)
      Description copied from interface: JexlArithmetic.ArrayBuilder
      Creates the actual "array" instance.
      Specified by:
      create in interface JexlArithmetic.ArrayBuilder
      Parameters:
      extended - true when the last argument is ', ...'
      Returns:
      the array