Package com.clickhouse.client.data
Class ClickHouseStringValue
- java.lang.Object
-
- com.clickhouse.client.data.ClickHouseStringValue
-
- All Implemented Interfaces:
ClickHouseValue
,Serializable
public class ClickHouseStringValue extends Object implements ClickHouseValue
Wraper class of string.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClickHouseStringValue(byte[] bytes)
protected
ClickHouseStringValue(String value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimal
asBigDecimal(int scale)
Gets value asBigDecimal
.BigInteger
asBigInteger()
Gets value asBigInteger
.byte[]
asBinary()
Gets binary value as byte array.byte[]
asBinary(int length, Charset charset)
Gets binary value as byte array.boolean
asBoolean()
Gets value as boolean.byte
asByte()
Gets value as byte.LocalDate
asDate()
Gets value asLocalDate
.LocalDateTime
asDateTime(int scale)
Gets value asLocalDateTime
.double
asDouble()
Gets value as double.<T extends Enum<T>>
TasEnum(Class<T> enumType)
Gets value as enum.float
asFloat()
Gets value as float.Inet4Address
asInet4Address()
Gets value asInet4Address
.Inet6Address
asInet6Address()
Gets value asInet6Address
.int
asInteger()
Gets value as integer.long
asLong()
Gets value as long.Object
asObject()
Gets value as an object.short
asShort()
Gets value as short.String
asString()
Gets value as unbounded string, using default charset(usually UTF-8).String
asString(int length, Charset charset)
Gets value as fixed length(in bytes) string.LocalTime
asTime()
Gets value asLocalTime
.UUID
asUuid()
Gets value as UUID.ClickHouseStringValue
copy(boolean deep)
Gets a copy of this value object.boolean
equals(Object obj)
int
hashCode()
boolean
isNullOrEmpty()
Checks if the value is null, or empty for non-null types like Array, Tuple and Map.static ClickHouseStringValue
of(byte[] bytes)
Wrap the given value.static ClickHouseStringValue
of(ClickHouseValue ref, byte[] bytes)
Update value of the given object or create a new instance ifref
is null.static ClickHouseStringValue
of(ClickHouseValue ref, String value)
Update value of the given object or create a new instance ifref
is null.static ClickHouseStringValue
of(String value)
Wrap the given value.static ClickHouseStringValue
ofNull()
Create a new instance representing null value.static ClickHouseStringValue
ofNull(ClickHouseValue ref)
Update given value to null or create a new instance ifref
is null.ClickHouseStringValue
resetToDefault()
Resets to default value of corresponding data type.ClickHouseStringValue
resetToNullOrEmpty()
Resets value to null, or empty when null is not supported(e.g.protected ClickHouseStringValue
set(byte[] bytes)
protected ClickHouseStringValue
set(String value)
String
toSqlExpression()
Converts the value to escaped SQL expression.String
toString()
ClickHouseStringValue
update(boolean value)
Updates value.ClickHouseStringValue
update(byte value)
Updates value.ClickHouseStringValue
update(byte[] value)
Updates value.ClickHouseStringValue
update(char value)
Updates value.ClickHouseStringValue
update(double value)
Updates value.ClickHouseStringValue
update(float value)
Updates value.ClickHouseStringValue
update(int value)
Updates value.ClickHouseStringValue
update(long value)
Updates value.ClickHouseStringValue
update(short value)
Updates value.ClickHouseStringValue
update(ClickHouseValue value)
Updates value.ClickHouseStringValue
update(Enum<?> value)
Updates value.ClickHouseStringValue
update(Object value)
Updates value.ClickHouseStringValue
update(String value)
Updates value.ClickHouseValue
update(BigDecimal value)
Updates value.ClickHouseValue
update(BigInteger value)
Updates value.ClickHouseStringValue
update(Inet4Address value)
Updates value.ClickHouseStringValue
update(Inet6Address value)
Updates value.ClickHouseStringValue
update(LocalDate value)
Updates value.ClickHouseStringValue
update(LocalDateTime value)
Updates value.ClickHouseStringValue
update(LocalTime value)
Updates value.ClickHouseStringValue
update(UUID value)
Updates value.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.clickhouse.client.ClickHouseValue
asArray, asArray, asBigDecimal, asBinary, asBinary, asByteStream, asCharacter, asCharacterStream, asDateTime, asInstant, asInstant, asMap, asMap, asObject, asOffsetDateTime, asOffsetDateTime, asString, asString, asTime, asTuple, asZonedDateTime, asZonedDateTime, copy, isInfinity, isNaN, newUnsupportedException, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, updateUnknown
-
-
-
-
Constructor Detail
-
ClickHouseStringValue
protected ClickHouseStringValue(String value)
-
ClickHouseStringValue
protected ClickHouseStringValue(byte[] bytes)
-
-
Method Detail
-
ofNull
public static ClickHouseStringValue ofNull()
Create a new instance representing null value.- Returns:
- new instance representing null value
-
ofNull
public static ClickHouseStringValue ofNull(ClickHouseValue ref)
Update given value to null or create a new instance ifref
is null.- Parameters:
ref
- object to update, could be null- Returns:
- same object as
ref
or a new instance if it's null
-
of
public static ClickHouseStringValue of(String value)
Wrap the given value.- Parameters:
value
- value- Returns:
- object representing the value
-
of
public static ClickHouseStringValue of(byte[] bytes)
Wrap the given value.- Parameters:
bytes
- bytes- Returns:
- object representing the value
-
of
public static ClickHouseStringValue of(ClickHouseValue ref, String value)
Update value of the given object or create a new instance ifref
is null.- Parameters:
ref
- object to update, could be nullvalue
- value- Returns:
- same object as
ref
or a new instance if it's null
-
of
public static ClickHouseStringValue of(ClickHouseValue ref, byte[] bytes)
Update value of the given object or create a new instance ifref
is null.- Parameters:
ref
- object to update, could be nullbytes
- bytes- Returns:
- same object as
ref
or a new instance if it's null
-
set
protected ClickHouseStringValue set(String value)
-
set
protected ClickHouseStringValue set(byte[] bytes)
-
copy
public ClickHouseStringValue copy(boolean deep)
Description copied from interface:ClickHouseValue
Gets a copy of this value object.- Specified by:
copy
in interfaceClickHouseValue
- Parameters:
deep
- true to create a deep copy; false for a shallow copy- Returns:
- copy of this value object
-
isNullOrEmpty
public boolean isNullOrEmpty()
Description copied from interface:ClickHouseValue
Checks if the value is null, or empty for non-null types like Array, Tuple and Map.Please pay attention that only nullability will be considered for String, meaning this method will return
false
for an empty string. This is because String is treated as value-based type instead of a container like Array.- Specified by:
isNullOrEmpty
in interfaceClickHouseValue
- Returns:
- true if the value is null or empty; false otherwise
-
asBoolean
public boolean asBoolean()
Description copied from interface:ClickHouseValue
Gets value as boolean.- Specified by:
asBoolean
in interfaceClickHouseValue
- Returns:
- boolean value
-
asByte
public byte asByte()
Description copied from interface:ClickHouseValue
Gets value as byte.- Specified by:
asByte
in interfaceClickHouseValue
- Returns:
- byte value
-
asShort
public short asShort()
Description copied from interface:ClickHouseValue
Gets value as short.- Specified by:
asShort
in interfaceClickHouseValue
- Returns:
- short value
-
asInteger
public int asInteger()
Description copied from interface:ClickHouseValue
Gets value as integer.- Specified by:
asInteger
in interfaceClickHouseValue
- Returns:
- integer value
-
asLong
public long asLong()
Description copied from interface:ClickHouseValue
Gets value as long.- Specified by:
asLong
in interfaceClickHouseValue
- Returns:
- long value
-
asBigInteger
public BigInteger asBigInteger()
Description copied from interface:ClickHouseValue
Gets value asBigInteger
.- Specified by:
asBigInteger
in interfaceClickHouseValue
- Returns:
- big integer, could be null
-
asFloat
public float asFloat()
Description copied from interface:ClickHouseValue
Gets value as float.- Specified by:
asFloat
in interfaceClickHouseValue
- Returns:
- float value
-
asDouble
public double asDouble()
Description copied from interface:ClickHouseValue
Gets value as double.- Specified by:
asDouble
in interfaceClickHouseValue
- Returns:
- double value
-
asBigDecimal
public BigDecimal asBigDecimal(int scale)
Description copied from interface:ClickHouseValue
Gets value asBigDecimal
.- Specified by:
asBigDecimal
in interfaceClickHouseValue
- Parameters:
scale
- scale of the decimal- Returns:
- big decimal, could be null
-
asDate
public LocalDate asDate()
Description copied from interface:ClickHouseValue
Gets value asLocalDate
.- Specified by:
asDate
in interfaceClickHouseValue
- Returns:
- date, could be null
-
asTime
public LocalTime asTime()
Description copied from interface:ClickHouseValue
Gets value asLocalTime
.- Specified by:
asTime
in interfaceClickHouseValue
- Returns:
- time, could be null
-
asDateTime
public LocalDateTime asDateTime(int scale)
Description copied from interface:ClickHouseValue
Gets value asLocalDateTime
.- Specified by:
asDateTime
in interfaceClickHouseValue
- Parameters:
scale
- scale of the date time, between 0 (second) and 9 (nano second)- Returns:
- date time, could be null
-
asEnum
public <T extends Enum<T>> T asEnum(Class<T> enumType)
Description copied from interface:ClickHouseValue
Gets value as enum.- Specified by:
asEnum
in interfaceClickHouseValue
- Type Parameters:
T
- type of the enum- Parameters:
enumType
- enum class- Returns:
- enum, could be null
-
asInet4Address
public Inet4Address asInet4Address()
Description copied from interface:ClickHouseValue
Gets value asInet4Address
.- Specified by:
asInet4Address
in interfaceClickHouseValue
- Returns:
- IPv4 address, could be null
-
asInet6Address
public Inet6Address asInet6Address()
Description copied from interface:ClickHouseValue
Gets value asInet6Address
.- Specified by:
asInet6Address
in interfaceClickHouseValue
- Returns:
- IPv6 address, could be null
-
asObject
public Object asObject()
Description copied from interface:ClickHouseValue
Gets value as an object.- Specified by:
asObject
in interfaceClickHouseValue
- Returns:
- an object representing the value, could be null
-
asBinary
public byte[] asBinary()
Description copied from interface:ClickHouseValue
Gets binary value as byte array.- Specified by:
asBinary
in interfaceClickHouseValue
- Returns:
- byte array which could be null
-
asBinary
public byte[] asBinary(int length, Charset charset)
Description copied from interface:ClickHouseValue
Gets binary value as byte array.- Specified by:
asBinary
in interfaceClickHouseValue
- Parameters:
length
- byte length of value, 0 or negative number means no limitcharset
- charset, null is same as default(UTF-8)- Returns:
- byte array which could be null
-
asString
public String asString()
Description copied from interface:ClickHouseValue
Gets value as unbounded string, using default charset(usually UTF-8).- Specified by:
asString
in interfaceClickHouseValue
- Returns:
- string value, could be null
-
asString
public String asString(int length, Charset charset)
Description copied from interface:ClickHouseValue
Gets value as fixed length(in bytes) string.- Specified by:
asString
in interfaceClickHouseValue
- Parameters:
length
- byte length of the string, 0 or negative number means unboundedcharset
- charset, null is same as default(UTF-8)- Returns:
- string value, could be null
-
asUuid
public UUID asUuid()
Description copied from interface:ClickHouseValue
Gets value as UUID.- Specified by:
asUuid
in interfaceClickHouseValue
- Returns:
- uuid, could be null
-
resetToDefault
public ClickHouseStringValue resetToDefault()
Description copied from interface:ClickHouseValue
Resets to default value of corresponding data type.- Specified by:
resetToDefault
in interfaceClickHouseValue
- Returns:
- this object
-
resetToNullOrEmpty
public ClickHouseStringValue resetToNullOrEmpty()
Description copied from interface:ClickHouseValue
Resets value to null, or empty when null is not supported(e.g. Array, Tuple and Map etc.).Keep in mind that String is value-based type, so this method will change its value to null instead of an empty string.
- Specified by:
resetToNullOrEmpty
in interfaceClickHouseValue
- Returns:
- this object
-
toSqlExpression
public String toSqlExpression()
Description copied from interface:ClickHouseValue
Converts the value to escaped SQL expression. For example, number 123 will be converted to123
, while string "12'3" will be converted to @{code '12\'3'}.- Specified by:
toSqlExpression
in interfaceClickHouseValue
- Returns:
- escaped SQL expression
-
update
public ClickHouseStringValue update(boolean value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(char value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(byte value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(byte[] value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(short value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(int value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(long value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(float value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(double value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseValue update(BigInteger value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseValue update(BigDecimal value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(Enum<?> value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(Inet4Address value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(Inet6Address value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(LocalDate value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(LocalTime value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(LocalDateTime value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(String value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(UUID value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(ClickHouseValue value)
Description copied from interface:ClickHouseValue
Updates value.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update- Returns:
- this object
-
update
public ClickHouseStringValue update(Object value)
Description copied from interface:ClickHouseValue
Updates value. This method tries to identify type ofvalue
and then use corresponding update method to proceed. Unknown value will be passed toClickHouseValue.updateUnknown(Object)
.- Specified by:
update
in interfaceClickHouseValue
- Parameters:
value
- value to update, could be null- Returns:
- this object
-
-