Package org.apache.calcite.util
Class ConversionUtil
- java.lang.Object
-
- org.apache.calcite.util.ConversionUtil
-
public class ConversionUtil extends java.lang.Object
Utility functions for converting from one type to another
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NATIVE_UTF16_CHARSET_NAME
static java.lang.String
TEST_UNICODE_SQL_ESCAPED_LITERAL
A constant string which can be used wherever a SQL literal containing Unicode escape characters is needed in a test.static java.lang.String
TEST_UNICODE_STRING
A constant string which can be used wherever a Java string containing Unicode characters is needed in a test.
-
Constructor Summary
Constructors Modifier Constructor Description private
ConversionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Boolean
toBoolean(java.lang.String str)
Converts a string into a booleanstatic byte[]
toByteArrayFromString(java.lang.String value, int radix)
Converts a string into a byte array.static java.lang.String
toStringFromApprox(double d, boolean isFloat)
Converts an approximate value into a string, following the SQL 2003 standard.static java.lang.String
toStringFromByteArray(byte[] value, int radix)
Converts a byte array into a bit string or a hex string.
-
-
-
Field Detail
-
NATIVE_UTF16_CHARSET_NAME
public static final java.lang.String NATIVE_UTF16_CHARSET_NAME
-
TEST_UNICODE_STRING
public static final java.lang.String TEST_UNICODE_STRING
A constant string which can be used wherever a Java string containing Unicode characters is needed in a test. It spells 'anthropos' in Greek.- See Also:
- Constant Field Values
-
TEST_UNICODE_SQL_ESCAPED_LITERAL
public static final java.lang.String TEST_UNICODE_SQL_ESCAPED_LITERAL
A constant string which can be used wherever a SQL literal containing Unicode escape characters is needed in a test. It spells 'anthropos' in Greek. The escape character is the SQL default (backslash); note that the backslash-doubling here is for Java only, so by the time the SQL parser gets it, there is only one backslash.- See Also:
- Constant Field Values
-
-
Method Detail
-
toStringFromByteArray
public static java.lang.String toStringFromByteArray(byte[] value, int radix)
Converts a byte array into a bit string or a hex string.For example,
toStringFromByteArray(new byte[] {0xAB, 0xCD}, 16)
returnsABCD
.
-
toByteArrayFromString
public static byte[] toByteArrayFromString(java.lang.String value, int radix)
Converts a string into a byte array. The inverse oftoStringFromByteArray(byte[], int)
.
-
toStringFromApprox
public static java.lang.String toStringFromApprox(double d, boolean isFloat)
Converts an approximate value into a string, following the SQL 2003 standard.
-
toBoolean
public static java.lang.Boolean toBoolean(java.lang.String str)
Converts a string into a boolean
-
-