Package org.apache.calcite.linq4j.tree
Enum Primitive
- java.lang.Object
-
- java.lang.Enum<Primitive>
-
- org.apache.calcite.linq4j.tree.Primitive
-
- All Implemented Interfaces:
Serializable,Comparable<Primitive>
public enum Primitive extends Enum<Primitive>
Enumeration of Java's primitive types.There are fields for the native class (e.g.
int, also known asInteger.TYPE) and the boxing class (e.g.Integer).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPrimitive.FlavorWhat kind of type?static interfacePrimitive.SinkA place to send a value.static interfacePrimitive.SourceA place from which to read a value.
-
Field Summary
Fields Modifier and Type Field Description private static Map<Class,Primitive>BOX_MAPClassboxClassObjectdefaultValueThe default value of this primitive class.private intfamilyObjectmaxThe maximum value of this primitive class.ObjectmaxNegativeThe largest value that is less than zero.ObjectminThe minimum value of this primitive class.ObjectminPositiveThe smallest value that is greater than zero.private static Map<Class,Primitive>PRIMITIVE_MAPClassprimitiveClassStringprimitiveNameintsizeThe size of a value of this type, in bits.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectarrayItem(Object dataSet, int ordinal)Gets an item from an array.voidarrayItem(Object dataSet, int ordinal, Primitive.Sink sink)Sends to a sink an from an array.voidarrayItem(Primitive.Source source, Object dataSet, int ordinal)Reads value from a source into an array.StringarrayToString(Object array)Converts an array to a string.static List<Boolean>asList(boolean[] elements)static List<Byte>asList(byte[] elements)static List<Character>asList(char[] elements)static List<Double>asList(double[] elements)static List<Float>asList(float[] elements)static List<Integer>asList(int[] elements)static List<Long>asList(long[] elements)static List<Short>asList(short[] elements)static List<?>asList(Object array)Adapts a primitive array into aList.booleanassignableFrom(Primitive primitive)static Classbox(Class type)Converts a primitive class to a boxed class; returns other classes unchanged.static Typebox(Type type)Converts a primitive type to a boxed type; returns other types unchanged.static Primitive.Flavorflavor(Type type)Returns whether this type is a primitive, box or other type.static booleanis(Type type)Returns whether a given type is primitive.static booleanisBox(Type type)Returns whether a given type is a box type (e.g.booleanisFixedNumeric()Returns whether this Primitive is a fixed-point numeric type.booleanisNumeric()Returns whether this Primitive is a numeric type.voidjdbc(ResultSet resultSet, int i, Primitive.Sink sink)Sends to a sink a value from a given column in a JDBC result set.ObjectjdbcGet(ResultSet resultSet, int i)Gets a value from a given column in a JDBC result set.Numbernumber(Number value)Creates a number value of this primitive's box type.static Primitiveof(Type type)Returns the Primitive object for a given primitive class.static PrimitiveofBox(Type type)Returns the Primitive object for a given boxing class.static PrimitiveofBoxOr(Type type)Returns the Primitive object for a given primitive or boxing class.Objectparse(String stringValue)Calls the appropriatevalueOf(String)method.Objectpermute(Object array, int[] sources)Permutes an array.voidsend(Field field, Object o, Primitive.Sink sink)Sends a field value to a sink.voidsend(Primitive.Source source, Primitive.Sink sink)Sends a value from a source to a sink.voidsortArray(Object array)Sorts an array of this primitive type.voidsortArray(Object array, int fromIndex, int toIndex)Sorts a specified range of an array of this primitive type.private static voidsortBooleanArray(boolean[] booleans, int fromIndex, int toIndex)ObjecttoArray(Collection collection)Converts a collection of boxed primitives into an array of primitives.ObjecttoArray2(Collection<Number> collection)Converts a collection ofNumberto a primitive array.static Classunbox(Class type)Converts a boxed class to a primitive class; returns other types unchanged.static Typeunbox(Type type)Converts a boxed type to a primitive type; returns other types unchanged.static PrimitivevalueOf(String name)Returns the enum constant of this type with the specified name.static Primitive[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BOOLEAN
public static final Primitive BOOLEAN
-
BYTE
public static final Primitive BYTE
-
CHAR
public static final Primitive CHAR
-
SHORT
public static final Primitive SHORT
-
INT
public static final Primitive INT
-
LONG
public static final Primitive LONG
-
FLOAT
public static final Primitive FLOAT
-
DOUBLE
public static final Primitive DOUBLE
-
VOID
public static final Primitive VOID
-
OTHER
public static final Primitive OTHER
-
-
Field Detail
-
primitiveClass
public final Class primitiveClass
-
boxClass
public final Class boxClass
-
primitiveName
public final String primitiveName
-
family
private final int family
-
defaultValue
public final Object defaultValue
The default value of this primitive class. This is the value taken by uninitialized fields, for instance; 0 forint, false forboolean, etc.
-
min
public final Object min
The minimum value of this primitive class.
-
maxNegative
public final Object maxNegative
The largest value that is less than zero. Null if not applicable for this type.
-
minPositive
public final Object minPositive
The smallest value that is greater than zero. Null if not applicable for this type.
-
max
public final Object max
The maximum value of this primitive class.
-
size
public final int size
The size of a value of this type, in bits. Null if not applicable for this type.
-
-
Method Detail
-
values
public static Primitive[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Primitive c : Primitive.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Primitive valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
of
public static Primitive of(Type type)
Returns the Primitive object for a given primitive class.For example,
of(long.class)returnsLONG. Returnsnullwhen applied to a boxing or other class; for exampleof(Long.class)andof(String.class)returnnull.
-
ofBox
public static Primitive ofBox(Type type)
Returns the Primitive object for a given boxing class.For example,
ofBox(java.util.Long.class)returnsLONG.
-
ofBoxOr
public static Primitive ofBoxOr(Type type)
Returns the Primitive object for a given primitive or boxing class.For example,
ofBoxOr(Long.class)andofBoxOr(long.class)both returnLONG.
-
is
public static boolean is(Type type)
Returns whether a given type is primitive.
-
isBox
public static boolean isBox(Type type)
Returns whether a given type is a box type (e.g.Integer).
-
flavor
public static Primitive.Flavor flavor(Type type)
Returns whether this type is a primitive, box or other type. Useful for switch statements.
-
isNumeric
public boolean isNumeric()
Returns whether this Primitive is a numeric type.
-
isFixedNumeric
public boolean isFixedNumeric()
Returns whether this Primitive is a fixed-point numeric type.
-
box
public static Type box(Type type)
Converts a primitive type to a boxed type; returns other types unchanged.
-
box
public static Class box(Class type)
Converts a primitive class to a boxed class; returns other classes unchanged.
-
unbox
public static Type unbox(Type type)
Converts a boxed type to a primitive type; returns other types unchanged.
-
unbox
public static Class unbox(Class type)
Converts a boxed class to a primitive class; returns other types unchanged.
-
asList
public static List<?> asList(Object array)
Adapts a primitive array into aList. For example,asList(new double[2])returns aList<Double>.
-
toArray
public Object toArray(Collection collection)
Converts a collection of boxed primitives into an array of primitives.- Parameters:
collection- Collection of boxed primitives- Returns:
- array of primitives
- Throws:
ClassCastException- if any element is not of the box typeNullPointerException- if any element is null
-
toArray2
public Object toArray2(Collection<Number> collection)
Converts a collection ofNumberto a primitive array.
-
arrayToString
public String arrayToString(Object array)
Converts an array to a string.- Parameters:
array- Array of this primitive type- Returns:
- String representation of array
-
sortArray
public void sortArray(Object array)
Sorts an array of this primitive type.- Parameters:
array- Array of this primitive type
-
sortArray
public void sortArray(Object array, int fromIndex, int toIndex)
Sorts a specified range of an array of this primitive type.- Parameters:
array- Array of this primitive typefromIndex- the index of the first element, inclusive, to be sortedtoIndex- the index of the last element, exclusive, to be sorted
-
sortBooleanArray
private static void sortBooleanArray(boolean[] booleans, int fromIndex, int toIndex)
-
send
public void send(Field field, Object o, Primitive.Sink sink) throws IllegalAccessException
Sends a field value to a sink.- Throws:
IllegalAccessException
-
arrayItem
public void arrayItem(Primitive.Source source, Object dataSet, int ordinal)
Reads value from a source into an array.
-
arrayItem
public void arrayItem(Object dataSet, int ordinal, Primitive.Sink sink)
Sends to a sink an from an array.
-
jdbcGet
public Object jdbcGet(ResultSet resultSet, int i) throws SQLException
Gets a value from a given column in a JDBC result set.- Parameters:
resultSet- Result seti- Ordinal of column (1-based, per JDBC)- Throws:
SQLException
-
jdbc
public void jdbc(ResultSet resultSet, int i, Primitive.Sink sink) throws SQLException
Sends to a sink a value from a given column in a JDBC result set.- Parameters:
resultSet- Result seti- Ordinal of column (1-based, per JDBC)sink- Sink- Throws:
SQLException
-
send
public void send(Primitive.Source source, Primitive.Sink sink)
Sends a value from a source to a sink.
-
parse
public Object parse(String stringValue)
Calls the appropriatevalueOf(String)method.
-
assignableFrom
public boolean assignableFrom(Primitive primitive)
-
-