- java.lang.Object
-
- com.pervasive.datarush.tokens.TokenUtils
-
public class TokenUtils extends Object
Utilities for working with token values.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringasString(BinaryValued value)Formats a binary value as a string suitable for output.static StringasString(BooleanValued value)Formats a boolean value as a string suitable for output.static StringasString(CharValued value)Formats a character value as a string suitable for output.static StringasString(DateValued value)Formats a date value as a string suitable for output.static StringasString(DoubleValued value)Formats a double value as a string suitable for output.static StringasString(DurationValued value)Formats a duration value as a string suitable for output.static StringasString(FloatValued value)Formats a float value as a string suitable for output.static StringasString(IntValued value)Formats an integer value as a string suitable for output.static StringasString(Ip4AddressValued value)Formats an ipv4 value as a string suitable for output.static StringasString(Ip6AddressValued value)Formats an ipv6 value as a string suitable for output.static StringasString(LongValued value)Formats a long value as a string suitable for output.static StringasString(MoneyValued value)Formats a money value as a string suitable for output.static StringasString(NumericValued value)Formats a numeric value as a string suitable for output.static StringasString(ObjectValued<?> value)Formats an object value as a string suitable for output.static StringasString(PeriodValued value)Formats a period value as a string suitable for output.static StringasString(StringValued value)Formats a string value as a string suitable for output.static StringasString(TimestampValued value)Formats a timestamp value as a string suitable for output.static StringasString(TimeValued value)Formats a time value as a string suitable for output.static StringasString(TokenValued value)Formats a token value as a string suitable for output.static DataTokenasToken(TokenValued value)Creates an immutable copy of the given token value.static <T extends ScalarSettable>
T[]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>
T[]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>
T[]castFields(ScalarSettable[] fields, Class<T> clazz)Casts an array of fields to the specified typestatic <T extends ScalarSettable>
T[]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>
T[]castFields(ScalarValued[] fields, Class<T> clazz)Casts an array of fields to the specified typestatic intcompare(BinaryValued value1, byte[] value2)Indicates the relative ordering of a binary value and a non-null binary data array in ascending order.static intcompare(BinaryValued value1, BinaryValued value2)Indicates the relative ordering of two binary values in ascending order.static intcompare(BooleanValued value1, BooleanValued value2)Indicates the relative ordering of two boolean values in ascending order.static intcompare(CharValued value1, CharValued value2)Indicates the relative ordering of two character values in ascending order.static intcompare(DateValued value1, DateValued value2)Indicates the relative ordering of two date values in ascending order.static intcompare(DoubleValued value1, DoubleValued value2)Indicates the relative ordering of two double values in ascending order.static intcompare(DurationValued value1, DurationValued value2)Indicates the relative ordering of two duration values in ascending order.static intcompare(FloatValued value1, FloatValued value2)Indicates the relative ordering of two float values in ascending order.static intcompare(IntValued value1, IntValued value2)Indicates the relative ordering of two integer values in ascending order.static intcompare(Ip4AddressValued value1, Ip4AddressValued value2)Indicates the relative ordering of two ip4address values in ascending order.static intcompare(Ip6AddressValued value1, Ip6AddressValued value2)Indicates the relative ordering of two ip4address values in ascending order.static intcompare(LongValued value1, LongValued value2)Indicates the relative ordering of two long values in ascending order.static intcompare(MoneyValued value1, MoneyValued value2)Indicates the relative ordering of two money values in ascending order.static intcompare(NumericValued value1, double value2)Indicates the relative ordering of a number value and a non-nulldoublein ascending order.static intcompare(NumericValued value1, long value2)Indicates the relative ordering of a number value and a non-nulllongin ascending order.static intcompare(NumericValued value1, NumericValued value2)Indicates the relative ordering of two numeric values in ascending order.static intcompare(NumericValued value1, BigDecimal value2)Indicates the relative ordering of a number value and a non-nulljava.math.BigDecimalin ascending order.static <O extends Comparable<O>>
intcompare(ObjectValued<O> value1, ObjectValued<O> value2)Indicates the relative ordering of two object values in ascending order.static intcompare(PeriodValued value1, PeriodValued value2)Indicates the relative ordering of two period values in ascending order.static intcompare(ScalarValued value1, ScalarValued value2)Indicates the relative ordering of two scalar values in ascending order.static intcompare(StringValued value1, StringValued value2)Indicates the relative ordering of two string values in ascending order.static intcompare(TimestampValued value1, TimestampValued value2)Indicates the relative ordering of two timestamp values in ascending order.static intcompare(TimeValued value1, TimeValued value2)Indicates the relative ordering of two time values in ascending order.static intcompareByCodepoint(String value1, String value2)Indicates the relative ordering of two string values by code point in ascending order.static intcompareNormalizedPeriod(Period p1, Period p2)Indicates the relative ordering of two periods in ascending order.static BigDecimalconvert(double d)Converts a double value to aBigDecimal.static BigDecimalconvert(long l)Converts a long value to aBigDecimal.static booleanequal(BinaryValued value1, BinaryValued value2)Indicates whether two binary values are equal.static booleanequal(BooleanValued value1, BooleanValued value2)Indicates whether two boolean values are equal.static booleanequal(CharValued value1, CharValued value2)Indicates whether two character values are equal.static booleanequal(DateValued value1, DateValued value2)Indicates whether two date values are equal.static booleanequal(DoubleValued value1, DoubleValued value2)Indicates whether two double values are equal.static booleanequal(DurationValued value1, DurationValued value2)Indicates whether two duration values are equal.static booleanequal(FloatValued value1, FloatValued value2)Indicates whether two float values are equal.static booleanequal(IntValued value1, IntValued value2)Indicates whether two integer values are equal.static booleanequal(Ip4AddressValued value1, Ip4AddressValued value2)Indicates whether two ip4address values are equal.static booleanequal(Ip6AddressValued value1, Ip6AddressValued value2)Indicates whether two ip6address values are equal.static booleanequal(LongValued value1, LongValued value2)Indicates whether two long values are equal.static booleanequal(MoneyValued value1, MoneyValued value2)Indicates whether two money values are equal.static booleanequal(NumericValued value1, NumericValued value2)Indicates whether two numeric values are equal.static <O> booleanequal(ObjectValued<O> value1, ObjectValued<O> value2)Indicates whether two object values are equal.static booleanequal(PeriodValued value1, PeriodValued value2)Indicates whether two period values are equal.static booleanequal(StringValued value1, StringValued value2)Indicates whether two string values are equal.static booleanequal(TimestampValued value1, TimestampValued value2)Indicates whether two timestamp values are equal.static booleanequal(TimeValued value1, TimeValued value2)Indicates whether two time values are equal.static doubleforceDouble(NumericValued value)Converts a numeric value to a double value, truncating if necessary.static floatforceFloat(NumericValued value)Converts a numeric value to a float value, truncating if necessary.static intforceInt(NumericValued value)Converts a numeric value to an integer value, truncating if necessary.static longforceLong(NumericValued value)Converts a numeric value to a long value, truncating if necessary.static Class<?>getJavaClass(ScalarTokenType type)static TokenValuedgetNull(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 DataTokengetZero(TokenType type)Returns an appropriate zero value for the given type.static inthashCode(BinaryValued value)Computes a hash code for a binary value.static inthashCode(BooleanValued value)Computes a hash code for a boolean value.static inthashCode(CharValued value)Computes a hash code for a char value.static inthashCode(DateValued value)Computes a hash code for a date value.static inthashCode(DoubleValued value)Computes a hash code for a double value.static inthashCode(DurationValued value)Computes a hash code for a duration value.static inthashCode(FloatValued value)Computes a hash code for a float value.static inthashCode(IntValued value)Computes a hash code for an integer value.static inthashCode(Ip4AddressValued value)Computes a hash code for a ip4address value.static inthashCode(Ip6AddressValued value)Computes a hash code for a ip6address value.static inthashCode(LongValued value)Computes a hash code for a long value.static inthashCode(MoneyValued value)Computes a hash code for a money value.static inthashCode(NumericValued value)Computes a hash code for a numeric value.static inthashCode(ObjectValued<?> value)Computes a hash code for an object value.static inthashCode(PeriodValued value)Computes a hash code for a period value.static inthashCode(StringValued value)Computes a hash code for a string value.static inthashCode(TimestampValued value)Computes a hash code for a string value.static inthashCode(TimeValued value)Computes a hash code for a time value.static ScalarTokenparse(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 voidtransfer(TokenValued[] sources, TokenSettable[] dest)Transfers the given array of sources to the array of destinations by-position.
-
-
-
Method Detail
-
getTypes
public static ScalarTokenType[] getTypes(ScalarValued[] values)
Extracts the types of an array of scalar token values.- Parameters:
values- the scalar token values whose types should be extracted- Returns:
- an array of the token types, in the same order as the input values
-
selectFields
public static ScalarValued[] selectFields(RecordValued value, String[] fieldNames)
Extracts the given list of field values from a record value.- Parameters:
value- the record to decomposefieldNames- the fields to extract- Returns:
- the values of the the named fields, in the order they were specified.
-
selectFields
public static ScalarSettable[] selectFields(RecordSettable value, String[] fieldNames)
Extracts the given list of field setters from a writeable record buffer.- Parameters:
value- the record to decomposefieldNames- the fields to extract- Returns:
- the setters of the the named fields, in the order they were specified.
-
castFields
public static <T extends ScalarValued> T[] castFields(RecordValued value, Class<T> clazz, String[] fieldNames)
Extracts the given list of field names, casting them to the specified type.- Type Parameters:
T- the type to which we are casting- Parameters:
value- The record from which we are extracting fieldsclazz- The type to which we are castingfieldNames- The list of field names to extract- Returns:
- A list of fields in the order specified by fieldNames
-
castFields
public static <T extends ScalarSettable> T[] castFields(RecordSettable value, Class<T> clazz, String[] fieldNames)
Extracts the given list of field names, casting them to the specified type.- Type Parameters:
T- the type to which we are casting- Parameters:
value- The record from which we are extracting fieldsclazz- The type to which we are castingfieldNames- The list of field names to extract- Returns:
- A list of fields in the order specified by fieldNames
-
castFields
public static <T extends ScalarSettable> T[] castFields(ScalarSettable[] fields, Class<T> clazz, Integer[] fieldIndices)
Extracts the given list of field indices, casting them to the specified type.- Type Parameters:
T- the type to which we are casting- Parameters:
fields- The array of fieldsclazz- The type to which we are castingfieldIndices- The list of field indices to extract- Returns:
- A list of fields in the order specified by fieldNames
-
castFields
public static <T extends ScalarValued> T[] castFields(ScalarValued[] fields, Class<T> clazz)
Casts an array of fields to the specified type- Type Parameters:
T- the type to which we are casting- Parameters:
fields- the array of fieldsclazz- the type to cast the fields to- Returns:
- The list of fields, casted to the specified type
-
castFields
public static <T extends ScalarSettable> T[] castFields(ScalarSettable[] fields, Class<T> clazz)
Casts an array of fields to the specified type- Type Parameters:
T- the type to which we are casting- Parameters:
fields- the array of fieldsclazz- the type to cast the fields to- Returns:
- The list of fields, casted to the specified type
-
asToken
public static DataToken asToken(TokenValued value)
Creates an immutable copy of the given token value.If a large number of values are to be converted, it is usually more efficient to use a
TokenConverterinstead of repeatedly calling this method.- Parameters:
value- the value to copy- Returns:
- a token containing the same value as the input
-
convert
public static BigDecimal convert(double d)
Converts a double value to aBigDecimal.- Parameters:
d- the value to convert- Returns:
- a
BigDecimalwith the given value.
-
convert
public static BigDecimal convert(long l)
Converts a long value to aBigDecimal.- Parameters:
l- the value to convert- Returns:
- a
BigDecimalwith the given value.
-
forceDouble
public static double forceDouble(NumericValued value)
Converts a numeric value to a double value, truncating if necessary. Precision will be lost if the source is wider than adouble.- Parameters:
value- the source number value- Returns:
- the number value as a
double.
-
forceFloat
public static float forceFloat(NumericValued value)
Converts a numeric value to a float value, truncating if necessary. Precision will be lost if the source is wider than afloat.- Parameters:
value- the source number value- Returns:
- the value as a
float.
-
forceLong
public static long forceLong(NumericValued value)
Converts a numeric value to a long value, truncating if necessary. Precision will be lost if the source is wider than along.- Parameters:
value- the source number value- Returns:
- the value as a
long.
-
forceInt
public static int forceInt(NumericValued value)
Converts a numeric value to an integer value, truncating if necessary. Precision will be lost if the source is wider than anint.- Parameters:
value- the source number value- Returns:
- the value as an
int.
-
hashCode
public static int hashCode(BinaryValued value)
Computes a hash code for a binary value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(BooleanValued value)
Computes a hash code for a boolean value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(CharValued value)
Computes a hash code for a char value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(DurationValued value)
Computes a hash code for a duration value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(DateValued value)
Computes a hash code for a date value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(DoubleValued value)
Computes a hash code for a double value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(FloatValued value)
Computes a hash code for a float value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(IntValued value)
Computes a hash code for an integer value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(Ip4AddressValued value)
Computes a hash code for a ip4address value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(Ip6AddressValued value)
Computes a hash code for a ip6address value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(LongValued value)
Computes a hash code for a long value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(MoneyValued value)
Computes a hash code for a money value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(NumericValued value)
Computes a hash code for a numeric value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(ObjectValued<?> value)
Computes a hash code for an object value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(PeriodValued value)
Computes a hash code for a period value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(StringValued value)
Computes a hash code for a string value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(TimeValued value)
Computes a hash code for a time value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
hashCode
public static int hashCode(TimestampValued value)
Computes a hash code for a string value.- Parameters:
value- the value to hash- Returns:
- the hash code for the value
-
asString
public static String asString(TokenValued value)
Formats a token value as a string suitable for output.If a large number of values are to be formatted, it is usually more efficient to use a
TokenConverterinstead of repeatedly calling this method.- Parameters:
value- the value to format- Returns:
- a string value. A null value is represented as the empty string.
-
asString
public static String asString(BinaryValued value)
Formats a binary value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a hexadecimal string encoding the value. A null value is represented as the empty string.
-
asString
public static String asString(BooleanValued value)
Formats a boolean value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(CharValued value)
Formats a character value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(DurationValued value)
Formats a duration value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(DateValued value)
Formats a date value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- an ISO 8601 formatted date string. A null value is represented as the empty string.
-
asString
public static String asString(DoubleValued value)
Formats a double value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(FloatValued value)
Formats a float value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(IntValued value)
Formats an integer value as a string suitable for output.- Parameters:
value- i value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(Ip4AddressValued value)
Formats an ipv4 value as a string suitable for output.- Parameters:
value- i value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(Ip6AddressValued value)
Formats an ipv6 value as a string suitable for output.- Parameters:
value- i value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(LongValued value)
Formats a long value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(MoneyValued value)
Formats a money value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(NumericValued value)
Formats a numeric value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(ObjectValued<?> value)
Formats an object value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. The exact
representation will depend on the implementation of
toString()on the object. A null value is represented as the empty string.
-
asString
public static String asString(PeriodValued value)
Formats a period value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string representing the value. A null value is represented as the empty string.
-
asString
public static String asString(StringValued value)
Formats a string value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- a string value. A null value is represented as the empty string.
-
asString
public static String asString(TimeValued value)
Formats a time value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- an ISO 8601 time of day string with zone offset. A null value is represented as the empty string.
-
asString
public static String asString(TimestampValued value)
Formats a timestamp value as a string suitable for output.- Parameters:
value- the value to format- Returns:
- an ISO 8601 timestamp string. A null value is represented as the empty string.
-
equal
public static boolean equal(BinaryValued value1, BinaryValued value2)
Indicates whether two binary values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(BooleanValued value1, BooleanValued value2)
Indicates whether two boolean values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(CharValued value1, CharValued value2)
Indicates whether two character values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(DurationValued value1, DurationValued value2)
Indicates whether two duration values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(DateValued value1, DateValued value2)
Indicates whether two date values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(DoubleValued value1, DoubleValued value2)
Indicates whether two double values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(FloatValued value1, FloatValued value2)
Indicates whether two float values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(IntValued value1, IntValued value2)
Indicates whether two integer values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(Ip4AddressValued value1, Ip4AddressValued value2)
Indicates whether two ip4address values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(Ip6AddressValued value1, Ip6AddressValued value2)
Indicates whether two ip6address values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(LongValued value1, LongValued value2)
Indicates whether two long values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(MoneyValued value1, MoneyValued value2)
Indicates whether two money values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(NumericValued value1, NumericValued value2)
Indicates whether two numeric values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static <O> boolean equal(ObjectValued<O> value1, ObjectValued<O> value2)
Indicates whether two object values are equal. Nulls are considered unequal in this context.- Type Parameters:
O- the type of the objects- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal (as determined by theirequals()method),falseotherwise
-
equal
public static boolean equal(PeriodValued value1, PeriodValued value2)
Indicates whether two period values are equal. The values are not normalized before comparison. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(StringValued value1, StringValued value2)
Indicates whether two string values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(TimeValued value1, TimeValued value2)
Indicates whether two time values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
equal
public static boolean equal(TimestampValued value1, TimestampValued value2)
Indicates whether two timestamp values are equal. Nulls are considered unequal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
trueif the two values are equal,falseotherwise
-
compare
public static int compare(BinaryValued value1, BinaryValued value2)
Indicates the relative ordering of two binary values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public 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.- Parameters:
value1- the first valuevalue2- the second non-null value, as an array of binary data- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(BooleanValued value1, BooleanValued value2)
Indicates the relative ordering of two boolean values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(CharValued value1, CharValued value2)
Indicates the relative ordering of two character values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(DurationValued value1, DurationValued value2)
Indicates the relative ordering of two duration values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(DateValued value1, DateValued value2)
Indicates the relative ordering of two date values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(DoubleValued value1, DoubleValued value2)
Indicates the relative ordering of two double values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(FloatValued value1, FloatValued value2)
Indicates the relative ordering of two float values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(IntValued value1, IntValued value2)
Indicates the relative ordering of two integer values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(Ip4AddressValued value1, Ip4AddressValued value2)
Indicates the relative ordering of two ip4address values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(Ip6AddressValued value1, Ip6AddressValued value2)
Indicates the relative ordering of two ip4address values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(LongValued value1, LongValued value2)
Indicates the relative ordering of two long values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(MoneyValued value1, MoneyValued value2)
Indicates the relative ordering of two money values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(NumericValued value1, long value2)
Indicates the relative ordering of a number value and a non-nulllongin ascending order. If necessary, the narrower of the two values will be widened.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(NumericValued value1, double value2)
Indicates the relative ordering of a number value and a non-nulldoublein ascending order. If necessary, the narrower of the two values will be widened.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(NumericValued value1, BigDecimal value2)
Indicates the relative ordering of a number value and a non-nulljava.math.BigDecimalin ascending order. If necessary, the narrower of the two values will be widened.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(NumericValued value1, NumericValued value2)
Indicates the relative ordering of two numeric values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static <O extends Comparable<O>> int compare(ObjectValued<O> value1, ObjectValued<O> value2)
Indicates the relative ordering of two object values in ascending order. Nulls are considered equal in this context. The ordering is that defined by the object'scompareTo(Object,Object)method; thus this is restricted to Java objects implementingComparable.- Type Parameters:
O- the type of Java objects. This must be a comparable type.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(PeriodValued value1, PeriodValued value2)
Indicates the relative ordering of two period values in ascending order. The values will be normalized before comparison. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compareNormalizedPeriod
public static int compareNormalizedPeriod(Period p1, Period p2)
Indicates the relative ordering of two periods in ascending order. The period values are normalized before comparison.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(StringValued value1, StringValued value2)
Indicates the relative ordering of two string values in ascending order. Nulls are considered equal in this context. Strings are ordered based on the Unicode code points of their characters.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compareByCodepoint
public static int compareByCodepoint(String value1, String value2)
Indicates the relative ordering of two string values by code point in ascending order. UnlikeString.compareTo(String), this method produces an ordering consistent with Unicode code points. This ordering differs only for characters aboveCharacter.MAX_SURROGATEwhich have code points before those represented by any surrogate pair.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(TimeValued value1, TimeValued value2)
Indicates the relative ordering of two time values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(TimestampValued value1, TimestampValued value2)
Indicates the relative ordering of two timestamp values in ascending order. Nulls are considered equal in this context.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
compare
public static int compare(ScalarValued value1, ScalarValued value2)
Indicates the relative ordering of two scalar values in ascending order. Nulls are considered equal in this context. The two values must be of comparable types.If a large number of comparisons are to be done, it is more efficient to use a
TokenComparatorinstead of repeatedly calling this method.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a negative integer, zero, or a positive integer if the first argument is respectively less than, equal to, or greater than the second.
-
getNull
public static TokenValued getNull(TokenType type)
Returns an appropriate null value for the given type.- Parameters:
type- The token type.- Returns:
- an appropriate null value for the given type.
-
transfer
public static void transfer(TokenValued[] sources, TokenSettable[] dest)
Transfers the given array of sources to the array of destinations by-position.- Parameters:
sources- The sources.dest- The desrinations. Must be the same length as sources
-
getZero
public static DataToken getZero(TokenType type)
Returns an appropriate zero value for the given type.- Parameters:
type- The token type.- Returns:
- an appropriate null value for the given type.
-
parse
public static ScalarToken parse(ScalarTokenType type, String value)
Parses the given string as a value of the specified type. If the value is available in a primitive form (that is, as anintor other datatype), it is more efficient to directly create a token instead of converting it to a string and parsing it.- Parameters:
type- the expected type of the value's string representationvalue- the string representation of a token value- Returns:
- a token with the represented value
-
getJavaClass
public static Class<?> getJavaClass(ScalarTokenType type)
-
-