Package org.apache.calcite.linq4j.tree
Enum Primitive
- java.lang.Object
-
- java.lang.Enum<Primitive>
-
- org.apache.calcite.linq4j.tree.Primitive
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Primitive.Flavor
What kind of type?static interface
Primitive.Sink
A place to send a value.static interface
Primitive.Source
A place from which to read a value.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Class,Primitive>
BOX_MAP
java.lang.Class
boxClass
java.lang.Object
defaultValue
The default value of this primitive class.private int
family
java.lang.Object
max
The maximum value of this primitive class.java.lang.Object
maxNegative
The largest value that is less than zero.java.lang.Object
min
The minimum value of this primitive class.java.lang.Object
minPositive
The smallest value that is greater than zero.private static java.util.Map<java.lang.Class,Primitive>
PRIMITIVE_MAP
java.lang.Class
primitiveClass
java.lang.String
primitiveName
int
size
The size of a value of this type, in bits.
-
Constructor Summary
Constructors Modifier Constructor Description private
Primitive(java.lang.Class primitiveClass, java.lang.Class boxClass, int family, java.lang.Object defaultValue, java.lang.Object min, java.lang.Object maxNegative, java.lang.Object minPositive, java.lang.Object max, int size)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
arrayItem(java.lang.Object dataSet, int ordinal)
Gets an item from an array.void
arrayItem(java.lang.Object dataSet, int ordinal, Primitive.Sink sink)
Sends to a sink an from an array.void
arrayItem(Primitive.Source source, java.lang.Object dataSet, int ordinal)
Reads value from a source into an array.java.lang.String
arrayToString(java.lang.Object array)
Converts an array to a string.static java.util.List<java.lang.Boolean>
asList(boolean[] elements)
Adapts an array ofboolean
into aList
ofBoolean
.static java.util.List<java.lang.Byte>
asList(byte[] elements)
Adapts an array ofbyte
into aList
ofByte
.static java.util.List<java.lang.Character>
asList(char[] elements)
Adapts an array ofchar
into aList
ofCharacter
.static java.util.List<java.lang.Double>
asList(double[] elements)
Adapts an array ofdouble
into aList
ofDouble
.static java.util.List<java.lang.Float>
asList(float[] elements)
Adapts an array offloat
into aList
ofFloat
.static java.util.List<java.lang.Integer>
asList(int[] elements)
Adapts an array ofint
into aList
ofInteger
.static java.util.List<java.lang.Long>
asList(long[] elements)
Adapts an array oflong
into aList
ofLong
.static java.util.List<java.lang.Short>
asList(short[] elements)
Adapts an array ofshort
into aList
ofShort
.static java.util.List<?>
asList(java.lang.Object array)
Adapts a primitive array into aList
.boolean
assignableFrom(Primitive primitive)
static java.lang.Class
box(java.lang.Class type)
Converts a primitive class to a boxed class; returns other classes unchanged.static java.lang.reflect.Type
box(java.lang.reflect.Type type)
Converts a primitive type to a boxed type; returns other types unchanged.static Primitive.Flavor
flavor(java.lang.reflect.Type type)
Returns whether this type is a primitive, box or other type.static boolean
is(java.lang.reflect.Type type)
Returns whether a given type is primitive.static boolean
isBox(java.lang.reflect.Type type)
Returns whether a given type is a box type (e.g.boolean
isFixedNumeric()
Returns whether this Primitive is a fixed-point numeric type.boolean
isNumeric()
Returns whether this Primitive is a numeric type.void
jdbc(java.sql.ResultSet resultSet, int i, Primitive.Sink sink)
Sends to a sink a value from a given column in a JDBC result set.java.lang.Object
jdbcGet(java.sql.ResultSet resultSet, int i)
Gets a value from a given column in a JDBC result set.java.lang.Number
number(java.lang.Number value)
Creates a number value of this primitive's box type.static Primitive
of(java.lang.reflect.Type type)
Returns the Primitive object for a given primitive class.static Primitive
ofBox(java.lang.reflect.Type type)
Returns the Primitive object for a given boxing class.static Primitive
ofBoxOr(java.lang.reflect.Type type)
Returns the Primitive object for a given primitive or boxing class.java.lang.Object
parse(java.lang.String stringValue)
Calls the appropriatevalueOf(String)
method.java.lang.Object
permute(java.lang.Object array, int[] sources)
Permutes an array.void
send(java.lang.reflect.Field field, java.lang.Object o, Primitive.Sink sink)
Sends a field value to a sink.void
send(Primitive.Source source, Primitive.Sink sink)
Sends a value from a source to a sink.void
sortArray(java.lang.Object array)
Sorts an array of this primitive type.void
sortArray(java.lang.Object array, int fromIndex, int toIndex)
Sorts a specified range of an array of this primitive type.private static void
sortBooleanArray(boolean[] booleans, int fromIndex, int toIndex)
java.lang.Object
toArray(java.util.Collection collection)
Converts a collection of boxed primitives into an array of primitives.java.lang.Object
toArray2(java.util.Collection<java.lang.Number> collection)
Converts a collection ofNumber
to a primitive array.static java.lang.Class
unbox(java.lang.Class type)
Converts a boxed class to a primitive class; returns other types unchanged.static java.lang.reflect.Type
unbox(java.lang.reflect.Type type)
Converts a boxed type to a primitive type; returns other types unchanged.static Primitive
valueOf(java.lang.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 java.lang.Class primitiveClass
-
boxClass
public final java.lang.Class boxClass
-
primitiveName
public final java.lang.String primitiveName
-
family
private final int family
-
defaultValue
public final java.lang.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 java.lang.Object min
The minimum value of this primitive class.
-
maxNegative
public final java.lang.Object maxNegative
The largest value that is less than zero. Null if not applicable for this type.
-
minPositive
public final java.lang.Object minPositive
The smallest value that is greater than zero. Null if not applicable for this type.
-
max
public final java.lang.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.
-
PRIMITIVE_MAP
private static final java.util.Map<java.lang.Class,Primitive> PRIMITIVE_MAP
-
BOX_MAP
private static final java.util.Map<java.lang.Class,Primitive> BOX_MAP
-
-
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(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
of
public static Primitive of(java.lang.reflect.Type type)
Returns the Primitive object for a given primitive class.For example,
of(long.class)
returnsLONG
. Returnsnull
when applied to a boxing or other class; for exampleof(Long.class)
andof(String.class)
returnnull
.
-
ofBox
public static Primitive ofBox(java.lang.reflect.Type type)
Returns the Primitive object for a given boxing class.For example,
ofBox(java.util.Long.class)
returnsLONG
.
-
ofBoxOr
public static Primitive ofBoxOr(java.lang.reflect.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(java.lang.reflect.Type type)
Returns whether a given type is primitive.
-
isBox
public static boolean isBox(java.lang.reflect.Type type)
Returns whether a given type is a box type (e.g.Integer
).
-
flavor
public static Primitive.Flavor flavor(java.lang.reflect.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 java.lang.reflect.Type box(java.lang.reflect.Type type)
Converts a primitive type to a boxed type; returns other types unchanged.
-
box
public static java.lang.Class box(java.lang.Class type)
Converts a primitive class to a boxed class; returns other classes unchanged.
-
unbox
public static java.lang.reflect.Type unbox(java.lang.reflect.Type type)
Converts a boxed type to a primitive type; returns other types unchanged.
-
unbox
public static java.lang.Class unbox(java.lang.Class type)
Converts a boxed class to a primitive class; returns other types unchanged.
-
asList
public static java.util.List<?> asList(java.lang.Object array)
Adapts a primitive array into aList
. For example,asList(new double[2])
returns aList<Double>
.
-
asList
public static java.util.List<java.lang.Boolean> asList(boolean[] elements)
Adapts an array ofboolean
into aList
ofBoolean
.
-
asList
public static java.util.List<java.lang.Byte> asList(byte[] elements)
Adapts an array ofbyte
into aList
ofByte
.
-
asList
public static java.util.List<java.lang.Character> asList(char[] elements)
Adapts an array ofchar
into aList
ofCharacter
.
-
asList
public static java.util.List<java.lang.Short> asList(short[] elements)
Adapts an array ofshort
into aList
ofShort
.
-
asList
public static java.util.List<java.lang.Integer> asList(int[] elements)
Adapts an array ofint
into aList
ofInteger
.
-
asList
public static java.util.List<java.lang.Long> asList(long[] elements)
Adapts an array oflong
into aList
ofLong
.
-
asList
public static java.util.List<java.lang.Float> asList(float[] elements)
Adapts an array offloat
into aList
ofFloat
.
-
asList
public static java.util.List<java.lang.Double> asList(double[] elements)
Adapts an array ofdouble
into aList
ofDouble
.
-
toArray
public java.lang.Object toArray(java.util.Collection collection)
Converts a collection of boxed primitives into an array of primitives.- Parameters:
collection
- Collection of boxed primitives- Returns:
- array of primitives
- Throws:
java.lang.ClassCastException
- if any element is not of the box typejava.lang.NullPointerException
- if any element is null
-
toArray2
public java.lang.Object toArray2(java.util.Collection<java.lang.Number> collection)
Converts a collection ofNumber
to a primitive array.
-
permute
public java.lang.Object permute(java.lang.Object array, int[] sources)
Permutes an array.
-
arrayToString
public java.lang.String arrayToString(java.lang.Object array)
Converts an array to a string.- Parameters:
array
- Array of this primitive type- Returns:
- String representation of array
-
sortArray
public void sortArray(java.lang.Object array)
Sorts an array of this primitive type.- Parameters:
array
- Array of this primitive type
-
sortArray
public void sortArray(java.lang.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(java.lang.reflect.Field field, java.lang.Object o, Primitive.Sink sink) throws java.lang.IllegalAccessException
Sends a field value to a sink.- Throws:
java.lang.IllegalAccessException
-
arrayItem
public java.lang.Object arrayItem(java.lang.Object dataSet, int ordinal)
Gets an item from an array.
-
arrayItem
public void arrayItem(Primitive.Source source, java.lang.Object dataSet, int ordinal)
Reads value from a source into an array.
-
arrayItem
public void arrayItem(java.lang.Object dataSet, int ordinal, Primitive.Sink sink)
Sends to a sink an from an array.
-
jdbcGet
public java.lang.Object jdbcGet(java.sql.ResultSet resultSet, int i) throws java.sql.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:
java.sql.SQLException
-
jdbc
public void jdbc(java.sql.ResultSet resultSet, int i, Primitive.Sink sink) throws java.sql.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:
java.sql.SQLException
-
send
public void send(Primitive.Source source, Primitive.Sink sink)
Sends a value from a source to a sink.
-
parse
public java.lang.Object parse(java.lang.String stringValue)
Calls the appropriatevalueOf(String)
method.
-
assignableFrom
public boolean assignableFrom(Primitive primitive)
-
number
public java.lang.Number number(java.lang.Number value)
Creates a number value of this primitive's box type. For example,SHORT.number(Integer(0))
will returnShort(0)
.
-
-