public class TokenUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
asString(BinaryValued value)
Formats a binary value as a string suitable for output.
|
static String |
asString(BooleanValued value)
Formats a boolean value as a string suitable for output.
|
static String |
asString(CharValued value)
Formats a character value as a string suitable for output.
|
static String |
asString(DateValued value)
Formats a date value as a string suitable for output.
|
static String |
asString(DoubleValued value)
Formats a double value as a string suitable for output.
|
static String |
asString(DurationValued value)
Formats a duration value as a string suitable for output.
|
static String |
asString(FloatValued value)
Formats a float value as a string suitable for output.
|
static String |
asString(IntValued value)
Formats an integer value as a string suitable for output.
|
static String |
asString(Ip4AddressValued value)
Formats an ipv4 value as a string suitable for output.
|
static String |
asString(Ip6AddressValued value)
Formats an ipv6 value as a string suitable for output.
|
static String |
asString(LongValued value)
Formats a long value as a string suitable for output.
|
static String |
asString(MoneyValued value)
Formats a money value as a string suitable for output.
|
static String |
asString(NumericValued value)
Formats a numeric value as a string suitable for output.
|
static String |
asString(ObjectValued<?> value)
Formats an object value as a string suitable for output.
|
static String |
asString(PeriodValued value)
Formats a period value as a string suitable for output.
|
static String |
asString(StringValued value)
Formats a string value as a string suitable for output.
|
static String |
asString(TimestampValued value)
Formats a timestamp value as a string suitable for output.
|
static String |
asString(TimeValued value)
Formats a time value as a string suitable for output.
|
static String |
asString(TokenValued value)
Formats a token value as a string suitable for output.
|
static DataToken |
asToken(TokenValued value)
Creates an immutable copy of the given token value.
|
static <T extends ScalarSettable> |
castFields(RecordSettable value,
Class<T> clazz,
String[] fieldNames)
Extracts the given list of field names, casting them to
the specified type.
|
static <T extends ScalarValued> |
castFields(RecordValued value,
Class<T> clazz,
String[] fieldNames)
Extracts the given list of field names, casting them to
the specified type.
|
static <T extends ScalarSettable> |
castFields(ScalarSettable[] fields,
Class<T> clazz)
Casts an array of fields to the specified type
|
static <T extends ScalarSettable> |
castFields(ScalarSettable[] fields,
Class<T> clazz,
Integer[] fieldIndices)
Extracts the given list of field indices, casting them to
the specified type.
|
static <T extends ScalarValued> |
castFields(ScalarValued[] fields,
Class<T> clazz)
Casts an array of fields to the specified type
|
static int |
compare(BinaryValued value1,
BinaryValued value2)
Indicates the relative ordering of two binary values
in ascending order.
|
static int |
compare(BinaryValued value1,
byte[] value2)
Indicates the relative ordering of a binary value and a non-null
binary data array in ascending order.
|
static int |
compare(BooleanValued value1,
BooleanValued value2)
Indicates the relative ordering of two boolean values
in ascending order.
|
static int |
compare(CharValued value1,
CharValued value2)
Indicates the relative ordering of two character values
in ascending order.
|
static int |
compare(DateValued value1,
DateValued value2)
Indicates the relative ordering of two date values
in ascending order.
|
static int |
compare(DoubleValued value1,
DoubleValued value2)
Indicates the relative ordering of two double values
in ascending order.
|
static int |
compare(DurationValued value1,
DurationValued value2)
Indicates the relative ordering of two duration values
in ascending order.
|
static int |
compare(FloatValued value1,
FloatValued value2)
Indicates the relative ordering of two float values
in ascending order.
|
static int |
compare(IntValued value1,
IntValued value2)
Indicates the relative ordering of two integer values
in ascending order.
|
static int |
compare(Ip4AddressValued value1,
Ip4AddressValued value2)
Indicates the relative ordering of two ip4address values
in ascending order.
|
static int |
compare(Ip6AddressValued value1,
Ip6AddressValued value2)
Indicates the relative ordering of two ip4address values
in ascending order.
|
static int |
compare(LongValued value1,
LongValued value2)
Indicates the relative ordering of two long values
in ascending order.
|
static int |
compare(MoneyValued value1,
MoneyValued value2)
Indicates the relative ordering of two money values
in ascending order.
|
static int |
compare(NumericValued value1,
BigDecimal value2)
Indicates the relative ordering of a number value and a non-null
java.math.BigDecimal in ascending order. |
static int |
compare(NumericValued value1,
double value2)
Indicates the relative ordering of a number value and a non-null
double in ascending order. |
static int |
compare(NumericValued value1,
long value2)
Indicates the relative ordering of a number value and a non-null
long in ascending order. |
static int |
compare(NumericValued value1,
NumericValued value2)
Indicates the relative ordering of two numeric values
in ascending order.
|
static <O extends Comparable<O>> |
compare(ObjectValued<O> value1,
ObjectValued<O> value2)
Indicates the relative ordering of two object values
in ascending order.
|
static int |
compare(PeriodValued value1,
PeriodValued value2)
Indicates the relative ordering of two period values
in ascending order.
|
static int |
compare(ScalarValued value1,
ScalarValued value2)
Indicates the relative ordering of two scalar values
in ascending order.
|
static int |
compare(StringValued value1,
StringValued value2)
Indicates the relative ordering of two string values
in ascending order.
|
static int |
compare(TimestampValued value1,
TimestampValued value2)
Indicates the relative ordering of two timestamp values
in ascending order.
|
static int |
compare(TimeValued value1,
TimeValued value2)
Indicates the relative ordering of two time values
in ascending order.
|
static int |
compareByCodepoint(String value1,
String value2)
Indicates the relative ordering of two string values by code point
in ascending order.
|
static int |
compareNormalizedPeriod(Period p1,
Period p2)
Indicates the relative ordering of two periods in ascending order.
|
static BigDecimal |
convert(double d)
Converts a double value to a
BigDecimal . |
static BigDecimal |
convert(long l)
Converts a long value to a
BigDecimal . |
static boolean |
equal(BinaryValued value1,
BinaryValued value2)
Indicates whether two binary values are equal.
|
static boolean |
equal(BooleanValued value1,
BooleanValued value2)
Indicates whether two boolean values are equal.
|
static boolean |
equal(CharValued value1,
CharValued value2)
Indicates whether two character values are equal.
|
static boolean |
equal(DateValued value1,
DateValued value2)
Indicates whether two date values are equal.
|
static boolean |
equal(DoubleValued value1,
DoubleValued value2)
Indicates whether two double values are equal.
|
static boolean |
equal(DurationValued value1,
DurationValued value2)
Indicates whether two duration values are equal.
|
static boolean |
equal(FloatValued value1,
FloatValued value2)
Indicates whether two float values are equal.
|
static boolean |
equal(IntValued value1,
IntValued value2)
Indicates whether two integer values are equal.
|
static boolean |
equal(Ip4AddressValued value1,
Ip4AddressValued value2)
Indicates whether two ip4address values are equal.
|
static boolean |
equal(Ip6AddressValued value1,
Ip6AddressValued value2)
Indicates whether two ip6address values are equal.
|
static boolean |
equal(LongValued value1,
LongValued value2)
Indicates whether two long values are equal.
|
static boolean |
equal(MoneyValued value1,
MoneyValued value2)
Indicates whether two money values are equal.
|
static boolean |
equal(NumericValued value1,
NumericValued value2)
Indicates whether two numeric values are equal.
|
static <O> boolean |
equal(ObjectValued<O> value1,
ObjectValued<O> value2)
Indicates whether two object values are equal.
|
static boolean |
equal(PeriodValued value1,
PeriodValued value2)
Indicates whether two period values are equal.
|
static boolean |
equal(StringValued value1,
StringValued value2)
Indicates whether two string values are equal.
|
static boolean |
equal(TimestampValued value1,
TimestampValued value2)
Indicates whether two timestamp values are equal.
|
static boolean |
equal(TimeValued value1,
TimeValued value2)
Indicates whether two time values are equal.
|
static double |
forceDouble(NumericValued value)
Converts a numeric value to a double value,
truncating if necessary.
|
static float |
forceFloat(NumericValued value)
Converts a numeric value to a float value,
truncating if necessary.
|
static int |
forceInt(NumericValued value)
Converts a numeric value to an integer value,
truncating if necessary.
|
static long |
forceLong(NumericValued value)
Converts a numeric value to a long value,
truncating if necessary.
|
static TokenValued |
getNull(TokenType type)
Returns an appropriate null value for the given type.
|
static ScalarTokenType[] |
getTypes(ScalarValued[] values)
Extracts the types of an array of scalar token values.
|
static DataToken |
getZero(TokenType type)
Returns an appropriate zero value for the given type.
|
static int |
hashCode(BinaryValued value)
Computes a hash code for a binary value.
|
static int |
hashCode(BooleanValued value)
Computes a hash code for a boolean value.
|
static int |
hashCode(CharValued value)
Computes a hash code for a char value.
|
static int |
hashCode(DateValued value)
Computes a hash code for a date value.
|
static int |
hashCode(DoubleValued value)
Computes a hash code for a double value.
|
static int |
hashCode(DurationValued value)
Computes a hash code for a duration value.
|
static int |
hashCode(FloatValued value)
Computes a hash code for a float value.
|
static int |
hashCode(IntValued value)
Computes a hash code for an integer value.
|
static int |
hashCode(Ip4AddressValued value)
Computes a hash code for a ip4address value.
|
static int |
hashCode(Ip6AddressValued value)
Computes a hash code for a ip6address value.
|
static int |
hashCode(LongValued value)
Computes a hash code for a long value.
|
static int |
hashCode(MoneyValued value)
Computes a hash code for a money value.
|
static int |
hashCode(NumericValued value)
Computes a hash code for a numeric value.
|
static int |
hashCode(ObjectValued<?> value)
Computes a hash code for an object value.
|
static int |
hashCode(PeriodValued value)
Computes a hash code for a period value.
|
static int |
hashCode(StringValued value)
Computes a hash code for a string value.
|
static int |
hashCode(TimestampValued value)
Computes a hash code for a string value.
|
static int |
hashCode(TimeValued value)
Computes a hash code for a time value.
|
static ScalarToken |
parse(ScalarTokenType type,
String value)
Parses the given string as a value of the specified type.
|
static ScalarSettable[] |
selectFields(RecordSettable value,
String[] fieldNames)
Extracts the given list of field setters from a writeable record buffer.
|
static ScalarValued[] |
selectFields(RecordValued value,
String[] fieldNames)
Extracts the given list of field values from a record value.
|
static void |
transfer(TokenValued[] sources,
TokenSettable[] dest)
Transfers the given array of sources to the array of destinations by-position.
|
public static ScalarTokenType[] getTypes(ScalarValued[] values)
values
- the scalar token values whose types should
be extractedpublic static ScalarValued[] selectFields(RecordValued value, String[] fieldNames)
value
- the record to decomposefieldNames
- the fields to extractpublic static ScalarSettable[] selectFields(RecordSettable value, String[] fieldNames)
value
- the record to decomposefieldNames
- the fields to extractpublic static <T extends ScalarValued> T[] castFields(RecordValued value, Class<T> clazz, String[] fieldNames)
T
- the type to which we are castingvalue
- The record from which we are extracting fieldsclazz
- The type to which we are castingfieldNames
- The list of field names to extractpublic static <T extends ScalarSettable> T[] castFields(RecordSettable value, Class<T> clazz, String[] fieldNames)
T
- the type to which we are castingvalue
- The record from which we are extracting fieldsclazz
- The type to which we are castingfieldNames
- The list of field names to extractpublic static <T extends ScalarSettable> T[] castFields(ScalarSettable[] fields, Class<T> clazz, Integer[] fieldIndices)
T
- the type to which we are castingfields
- The array of fieldsclazz
- The type to which we are castingfieldIndices
- The list of field indices to extractpublic static <T extends ScalarValued> T[] castFields(ScalarValued[] fields, Class<T> clazz)
T
- the type to which we are castingfields
- the array of fieldsclazz
- the type to cast the fields topublic static <T extends ScalarSettable> T[] castFields(ScalarSettable[] fields, Class<T> clazz)
T
- the type to which we are castingfields
- the array of fieldsclazz
- the type to cast the fields topublic static DataToken asToken(TokenValued value)
If a large number of values are to be converted, it is
usually more efficient to use a TokenConverter
instead of repeatedly calling this method.
value
- the value to copypublic static BigDecimal convert(double d)
BigDecimal
.d
- the value to convertBigDecimal
with the given value.public static BigDecimal convert(long l)
BigDecimal
.l
- the value to convertBigDecimal
with the given value.public static double forceDouble(NumericValued value)
double
.value
- the source number valuedouble
.public static float forceFloat(NumericValued value)
float
.value
- the source number valuefloat
.public static long forceLong(NumericValued value)
long
.value
- the source number valuelong
.public static int forceInt(NumericValued value)
int
.value
- the source number valueint
.public static int hashCode(BinaryValued value)
value
- the value to hashpublic static int hashCode(BooleanValued value)
value
- the value to hashpublic static int hashCode(CharValued value)
value
- the value to hashpublic static int hashCode(DurationValued value)
value
- the value to hashpublic static int hashCode(DateValued value)
value
- the value to hashpublic static int hashCode(DoubleValued value)
value
- the value to hashpublic static int hashCode(FloatValued value)
value
- the value to hashpublic static int hashCode(IntValued value)
value
- the value to hashpublic static int hashCode(Ip4AddressValued value)
value
- the value to hashpublic static int hashCode(Ip6AddressValued value)
value
- the value to hashpublic static int hashCode(LongValued value)
value
- the value to hashpublic static int hashCode(MoneyValued value)
value
- the value to hashpublic static int hashCode(NumericValued value)
value
- the value to hashpublic static int hashCode(ObjectValued<?> value)
value
- the value to hashpublic static int hashCode(PeriodValued value)
value
- the value to hashpublic static int hashCode(StringValued value)
value
- the value to hashpublic static int hashCode(TimeValued value)
value
- the value to hashpublic static int hashCode(TimestampValued value)
value
- the value to hashpublic static String asString(TokenValued value)
If a large number of values are to be formatted, it is
usually more efficient to use a TokenConverter
instead of repeatedly calling this method.
value
- the value to formatpublic static String asString(BinaryValued value)
value
- the value to formatpublic static String asString(BooleanValued value)
value
- the value to formatpublic static String asString(CharValued value)
value
- the value to formatpublic static String asString(DurationValued value)
value
- the value to formatpublic static String asString(DateValued value)
value
- the value to formatpublic static String asString(DoubleValued value)
value
- the value to formatpublic static String asString(FloatValued value)
value
- the value to formatpublic static String asString(IntValued value)
value
- i value to formatpublic static String asString(Ip4AddressValued value)
value
- i value to formatpublic static String asString(Ip6AddressValued value)
value
- i value to formatpublic static String asString(LongValued value)
value
- the value to formatpublic static String asString(MoneyValued value)
value
- the value to formatpublic static String asString(NumericValued value)
value
- the value to formatpublic static String asString(ObjectValued<?> value)
value
- the value to formattoString()
on the object. A null value
is represented as the empty string.public static String asString(PeriodValued value)
value
- the value to formatpublic static String asString(StringValued value)
value
- the value to formatpublic static String asString(TimeValued value)
value
- the value to formatpublic static String asString(TimestampValued value)
value
- the value to formatpublic static boolean equal(BinaryValued value1, BinaryValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(BooleanValued value1, BooleanValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(CharValued value1, CharValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(DurationValued value1, DurationValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(DateValued value1, DateValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(DoubleValued value1, DoubleValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(FloatValued value1, FloatValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(IntValued value1, IntValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(Ip4AddressValued value1, Ip4AddressValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(Ip6AddressValued value1, Ip6AddressValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(LongValued value1, LongValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(MoneyValued value1, MoneyValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(NumericValued value1, NumericValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static <O> boolean equal(ObjectValued<O> value1, ObjectValued<O> value2)
O
- the type of the objectsvalue1
- the first valuevalue2
- the second valuetrue
if the two values are equal
(as determined by their equals()
method),
false
otherwisepublic static boolean equal(PeriodValued value1, PeriodValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(StringValued value1, StringValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(TimeValued value1, TimeValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static boolean equal(TimestampValued value1, TimestampValued value2)
value1
- the first valuevalue2
- the second valuetrue
if the two values are equal,
false
otherwisepublic static int compare(BinaryValued value1, BinaryValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(BinaryValued value1, byte[] value2)
value1
- the first valuevalue2
- the second non-null value, as an array of binary datapublic static int compare(BooleanValued value1, BooleanValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(CharValued value1, CharValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(DurationValued value1, DurationValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(DateValued value1, DateValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(DoubleValued value1, DoubleValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(FloatValued value1, FloatValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(IntValued value1, IntValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(Ip4AddressValued value1, Ip4AddressValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(Ip6AddressValued value1, Ip6AddressValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(LongValued value1, LongValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(MoneyValued value1, MoneyValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(NumericValued value1, long value2)
long
in ascending order.
If necessary, the narrower of the two values will be widened.value1
- the first valuevalue2
- the second valuepublic static int compare(NumericValued value1, double value2)
double
in ascending order.
If necessary, the narrower of the two values will be widened.value1
- the first valuevalue2
- the second valuepublic static int compare(NumericValued value1, BigDecimal value2)
java.math.BigDecimal
in ascending order.
If necessary, the narrower of the two values will be widened.value1
- the first valuevalue2
- the second valuepublic static int compare(NumericValued value1, NumericValued value2)
value1
- the first valuevalue2
- the second valuepublic static <O extends Comparable<O>> int compare(ObjectValued<O> value1, ObjectValued<O> value2)
compareTo(Object,Object)
method; thus this is restricted to Java objects implementing
Comparable
.O
- the type of Java objects. This must be a comparable type.value1
- the first valuevalue2
- the second valuepublic static int compare(PeriodValued value1, PeriodValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compareNormalizedPeriod(Period p1, Period p2)
value1
- the first valuevalue2
- the second valuepublic static int compare(StringValued value1, StringValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compareByCodepoint(String value1, String value2)
String.compareTo(String)
, this
method produces an ordering consistent with Unicode code points.
This ordering differs only for characters above Character.MAX_SURROGATE
which have code points before those represented by any
surrogate pair.value1
- the first valuevalue2
- the second valuepublic static int compare(TimeValued value1, TimeValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(TimestampValued value1, TimestampValued value2)
value1
- the first valuevalue2
- the second valuepublic static int compare(ScalarValued value1, ScalarValued value2)
If a large number of comparisons are to be done, it is
more efficient to use a TokenComparator
instead
of repeatedly calling this method.
value1
- the first valuevalue2
- the second valuepublic static TokenValued getNull(TokenType type)
type
- The token type.public static void transfer(TokenValued[] sources, TokenSettable[] dest)
sources
- The sources.dest
- The desrinations. Must be the same length as sourcespublic static DataToken getZero(TokenType type)
type
- The token type.public static ScalarToken parse(ScalarTokenType type, String value)
int
or other datatype), it is more efficient to
directly create a token instead of converting it to a
string and parsing it.type
- the expected type of the value's string representationvalue
- the string representation of a token valueCopyright © 2024 Actian Corporation. All rights reserved.