Package org.apache.calcite.linq4j.tree
Enum Primitive
- All Implemented Interfaces:
Serializable
,Comparable<Primitive>
,Constable
Enumeration of Java's primitive types.
There are fields for the native class (e.g. int
, also
known as Integer.TYPE
) and the boxing class
(e.g. Integer
).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Whether a type is primitive (e.g.static interface
A place to send a value.static interface
A place from which to read a value.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Field Summary
Modifier and TypeFieldDescriptionfinal @Nullable Class
final @Nullable String
final @Nullable Object
The default value of this primitive class.final @Nullable Object
The maximum value of this primitive class.final @Nullable Object
The largest value that is less than zero.final @Nullable Object
The minimum value of this primitive class.final @Nullable Object
The smallest value that is greater than zero.final @Nullable Class
final @Nullable String
final int
The size of a value of this type, in bits. -
Method Summary
Modifier and TypeMethodDescription@Nullable Object
Gets an item from an array.void
arrayItem
(Object dataSet, int ordinal, Primitive.Sink sink) Sends to a sink an from an array.void
arrayItem
(Primitive.Source source, Object dataSet, int ordinal) Reads value from a source into an array.arrayToString
(Object array) Converts an array to a string.asList
(boolean[] elements) asList
(byte[] elements) asList
(char[] elements) asList
(double[] elements) asList
(float[] elements) asList
(int[] elements) asList
(long[] elements) asList
(short[] elements) static List<?>
Adapts a primitive array into aList
.boolean
assignableFrom
(Primitive primitive) static Class
Converts a primitive class to a boxed class; returns other classes unchanged.static Type
Converts a primitive type to a boxed type; returns other types unchanged.static @Nullable Object
charToDecimalCast
(@Nullable String value, int precision, int scale) Called from BuiltInMethod.CHAR_DECIMAL_CASTstatic @Nullable Object
charToDecimalCast
(@Nullable String value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.CHAR_DECIMAL_CAST_ROUNDING_MODEstatic @Nullable Object
decimalDecimalCast
(@Nullable BigDecimal value, int precision, int scale) Called from BuiltInMethod.DECIMAL_DECIMAL_CASTstatic @Nullable Object
decimalDecimalCast
(@Nullable BigDecimal value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.DECIMAL_DECIMAL_CAST_ROUNDING_MODEstatic Primitive.Flavor
Returns whether this type is a primitive, box or other type.static @Nullable Object
fpDecimalCast
(@Nullable Number value, int precision, int scale) Called from BuiltInMethod.FP_DECIMAL_CASTstatic @Nullable Object
fpDecimalCast
(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.FP_DECIMAL_CAST_ROUNDING_MODEClass<?>
Class<?>
static @Nullable Object
integerCast
(Primitive primitive, Object value) Called from BuiltInMethod.INTEGER_CASTstatic @Nullable Object
integerCast
(Primitive primitive, Object value, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_CAST_ROUNDING_MODEstatic @Nullable Object
integerDecimalCast
(@Nullable Number value, int precision, int scale) Called from BuiltInMethod.INTEGER_DECIMAL_CASTstatic @Nullable Object
integerDecimalCast
(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_DECIMAL_CAST_ROUNDING_MODEstatic boolean
Returns whether a given type is primitive.static boolean
Returns whether a given type is a box type (e.g.boolean
Returns whether this Primitive is a fixed-point numeric type.boolean
Returns whether this Primitive is a numeric type.void
jdbc
(ResultSet resultSet, int i, Primitive.Sink sink) Sends to a sink a value from a given column in a JDBC result set.@Nullable Object
Gets a value from a given column in a JDBC result set.static @Nullable Object
longIntervalToDecimalCast
(@Nullable Integer value, int precision, int scale, BigDecimal unitScale) Convert a long time interval to a decimal value.static @Nullable Object
longIntervalToDecimalCast
(@Nullable Integer value, int precision, int scale, BigDecimal unitScale, RoundingMode roundingMode) Convert a long time interval to a decimal value.Creates a number value of this primitive's box type.@Nullable Object
numberValue
(Number value, RoundingMode roundingMode) Converts a number into a value of the type specified by this primitive using the SQL CAST rules.@Nullable Object
numberValueRoundDown
(Number value) static @Nullable Primitive
Returns the Primitive object for a given primitive class.static @Nullable Primitive
Returns the Primitive object for a given boxing class.static @Nullable Primitive
Returns the Primitive object for a given primitive or boxing class.Calls the appropriatevalueOf(String)
method.Permutes an array.void
send
(Field field, 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.static @Nullable Object
shortIntervalToDecimalCast
(@Nullable Long value, int precision, int scale, BigDecimal unitScale) Convert a short time interval to a decimal value.static @Nullable Object
shortIntervalToDecimalCast
(@Nullable Long value, int precision, int scale, BigDecimal unitScale, RoundingMode roundingMode) Convert a short time interval to a decimal value.void
Sorts an array of this primitive type.void
Sorts a specified range of an array of this primitive type.toArray
(Collection collection) Converts a collection of boxed primitives into an array of primitives.toArray2
(Collection<Number> collection) Converts a collection ofNumber
to a primitive array.static Class
Converts a boxed class to a primitive class; returns other types unchanged.static Type
Converts a boxed type to a primitive type; returns other types unchanged.static Primitive
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 Details
-
BOOLEAN
-
BYTE
-
CHAR
-
SHORT
-
INT
-
LONG
-
FLOAT
-
DOUBLE
-
VOID
-
OTHER
-
-
Field Details
-
primitiveClass
-
boxClass
-
primitiveName
-
boxName
-
defaultValue
The default value of this primitive class. This is the value taken by uninitialized fields, for instance; 0 forint
, false forboolean
, etc. -
min
The minimum value of this primitive class. -
maxNegative
The largest value that is less than zero. Null if not applicable for this type. -
minPositive
The smallest value that is greater than zero. Null if not applicable for this type. -
max
The maximum value of this primitive class. -
size
public final int sizeThe size of a value of this type, in bits. Null if not applicable for this type.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
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
Returns the Primitive object for a given boxing class.For example,
ofBox(java.util.Long.class)
returnsLONG
. -
ofBoxOr
Returns the Primitive object for a given primitive or boxing class.For example,
ofBoxOr(Long.class)
andofBoxOr(long.class)
both returnLONG
. -
is
Returns whether a given type is primitive. -
isBox
Returns whether a given type is a box type (e.g.Integer
). -
flavor
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
Converts a primitive type to a boxed type; returns other types unchanged. -
box
Converts a primitive class to a boxed class; returns other classes unchanged. -
unbox
Converts a boxed type to a primitive type; returns other types unchanged. -
unbox
Converts a boxed class to a primitive class; returns other types unchanged. -
getPrimitiveClass
-
getBoxClass
-
getPrimitiveName
-
getBoxName
-
asList
-
asList
-
asList
-
asList
-
asList
-
asList
-
asList
-
asList
-
asList
-
integerCast
Called from BuiltInMethod.INTEGER_CAST -
integerCast
public static @Nullable Object integerCast(Primitive primitive, Object value, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_CAST_ROUNDING_MODE -
charToDecimalCast
Called from BuiltInMethod.CHAR_DECIMAL_CAST -
charToDecimalCast
public static @Nullable Object charToDecimalCast(@Nullable String value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.CHAR_DECIMAL_CAST_ROUNDING_MODE -
shortIntervalToDecimalCast
public static @Nullable Object shortIntervalToDecimalCast(@Nullable Long value, int precision, int scale, BigDecimal unitScale) Convert a short time interval to a decimal value. Called from BuiltInMethod.SHORT_INTERVAL_DECIMAL_CAST.- Parameters:
unitScale
- Scale describing source interval type
-
shortIntervalToDecimalCast
public static @Nullable Object shortIntervalToDecimalCast(@Nullable Long value, int precision, int scale, BigDecimal unitScale, RoundingMode roundingMode) Convert a short time interval to a decimal value. Called from BuiltInMethod.SHORT_INTERVAL_DECIMAL_CAST_ROUNDING_MODE.- Parameters:
unitScale
- Scale describing source interval type
-
longIntervalToDecimalCast
public static @Nullable Object longIntervalToDecimalCast(@Nullable Integer value, int precision, int scale, BigDecimal unitScale) Convert a long time interval to a decimal value. Called from BuiltInMethod.LONG_INTERVAL_DECIMAL_CAST.- Parameters:
unitScale
- Scale describing source interval type
-
longIntervalToDecimalCast
public static @Nullable Object longIntervalToDecimalCast(@Nullable Integer value, int precision, int scale, BigDecimal unitScale, RoundingMode roundingMode) Convert a long time interval to a decimal value. Called from BuiltInMethod.LONG_INTERVAL_DECIMAL_CAST_ROUNDING_MODE.- Parameters:
unitScale
- Scale describing source interval type
-
decimalDecimalCast
public static @Nullable Object decimalDecimalCast(@Nullable BigDecimal value, int precision, int scale) Called from BuiltInMethod.DECIMAL_DECIMAL_CAST -
decimalDecimalCast
public static @Nullable Object decimalDecimalCast(@Nullable BigDecimal value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.DECIMAL_DECIMAL_CAST_ROUNDING_MODE -
integerDecimalCast
Called from BuiltInMethod.INTEGER_DECIMAL_CAST -
integerDecimalCast
public static @Nullable Object integerDecimalCast(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_DECIMAL_CAST_ROUNDING_MODE -
fpDecimalCast
Called from BuiltInMethod.FP_DECIMAL_CAST -
fpDecimalCast
public static @Nullable Object fpDecimalCast(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.FP_DECIMAL_CAST_ROUNDING_MODE -
numberValueRoundDown
-
numberValue
Converts a number into a value of the type specified by this primitive using the SQL CAST rules. If the value conversion causes loss of significant digits, an exception is thrown.- Parameters:
value
- Value to convert.roundingMode
- Rounding behavior.- Returns:
- The converted value, or null if the type of the result is not a number.
-
toArray
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
Converts a collection ofNumber
to a primitive array. -
permute
Permutes an array. -
arrayToString
Converts an array to a string.- Parameters:
array
- Array of this primitive type- Returns:
- String representation of array
-
sortArray
Sorts an array of this primitive type.- Parameters:
array
- Array of this primitive type
-
sortArray
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
-
send
Sends a field value to a sink.- Throws:
IllegalAccessException
-
arrayItem
Gets an item from an array. -
arrayItem
Reads value from a source into an array. -
arrayItem
Sends to a sink an from an array. -
jdbcGet
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
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
Sends a value from a source to a sink. -
parse
Calls the appropriatevalueOf(String)
method. -
assignableFrom
-
number
Creates a number value of this primitive's box type. For example,SHORT.number(Integer(0))
will returnShort(0)
.
-