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
Nested ClassesModifier and TypeClassDescriptionstatic enumWhether a type is primitive (e.g.static interfaceA place to send a value.static interfaceA 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
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal @Nullable Classfinal @Nullable Stringfinal @Nullable ObjectThe default value of this primitive class.final @Nullable ObjectThe maximum value of this primitive class.final @Nullable ObjectThe largest value that is less than zero.final @Nullable ObjectThe minimum value of this primitive class.final @Nullable ObjectThe smallest value that is greater than zero.final @Nullable Classfinal @Nullable Stringfinal intThe size of a value of this type, in bits. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectGets 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.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.booleanassignableFrom(Primitive primitive) static ClassConverts a primitive class to a boxed class; returns other classes unchanged.static TypeConverts a primitive type to a boxed type; returns other types unchanged.static @Nullable ObjectcharToDecimalCast(@Nullable String value, int precision, int scale) Called from BuiltInMethod.CHAR_DECIMAL_CASTstatic @Nullable ObjectcharToDecimalCast(@Nullable String value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.CHAR_DECIMAL_CAST_ROUNDING_MODEstatic @Nullable ObjectdecimalDecimalCast(@Nullable BigDecimal value, int precision, int scale) Called from BuiltInMethod.DECIMAL_DECIMAL_CASTstatic @Nullable ObjectdecimalDecimalCast(@Nullable BigDecimal value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.DECIMAL_DECIMAL_CAST_ROUNDING_MODEstatic Primitive.FlavorReturns whether this type is a primitive, box or other type.static @Nullable ObjectfpDecimalCast(@Nullable Number value, int precision, int scale) Called from BuiltInMethod.FP_DECIMAL_CASTstatic @Nullable ObjectfpDecimalCast(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.FP_DECIMAL_CAST_ROUNDING_MODEClass<?>Class<?>static @Nullable ObjectintegerCast(Primitive primitive, Object value) Called from BuiltInMethod.INTEGER_CASTstatic @Nullable ObjectintegerCast(Primitive primitive, Object value, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_CAST_ROUNDING_MODEstatic @Nullable ObjectintegerDecimalCast(@Nullable Number value, int precision, int scale) Called from BuiltInMethod.INTEGER_DECIMAL_CASTstatic @Nullable ObjectintegerDecimalCast(@Nullable Number value, int precision, int scale, RoundingMode roundingMode) Called from BuiltInMethod.INTEGER_DECIMAL_CAST_ROUNDING_MODEstatic booleanReturns whether a given type is primitive.static booleanReturns whether a given type is a box type (e.g.booleanReturns whether this Primitive is a fixed-point numeric type.booleanReturns 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.@Nullable ObjectGets a value from a given column in a JDBC result set.static @Nullable ObjectlongIntervalToDecimalCast(@Nullable Integer value, int precision, int scale, BigDecimal unitScale) Convert a long time interval to a decimal value.static @Nullable ObjectlongIntervalToDecimalCast(@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 ObjectnumberValue(Number value, RoundingMode roundingMode) Converts a number into a value of the type specified by this primitive using the SQL CAST rules.@Nullable ObjectnumberValueRoundDown(Number value) static @Nullable PrimitiveReturns the Primitive object for a given primitive class.static @Nullable PrimitiveReturns the Primitive object for a given boxing class.static @Nullable PrimitiveReturns the Primitive object for a given primitive or boxing class.Calls the appropriatevalueOf(String)method.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.static @Nullable ObjectshortIntervalToDecimalCast(@Nullable Long value, int precision, int scale, BigDecimal unitScale) Convert a short time interval to a decimal value.static @Nullable ObjectshortIntervalToDecimalCast(@Nullable Long value, int precision, int scale, BigDecimal unitScale, RoundingMode roundingMode) Convert a short time interval to a decimal value.voidSorts an array of this primitive type.voidSorts 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 ofNumberto a primitive array.static ClassConverts a boxed class to a primitive class; returns other types unchanged.static TypeConverts a boxed type to a primitive type; returns other types unchanged.static PrimitiveReturns 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. Returnsnullwhen 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 ofNumberto 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).
-