Class ClickHouseShortValue

java.lang.Object
com.clickhouse.data.value.ClickHouseShortValue
All Implemented Interfaces:
ClickHouseValue, Serializable

public class ClickHouseShortValue extends Object implements ClickHouseValue
Wrapper class of short.
See Also:
  • Constructor Details

    • ClickHouseShortValue

      protected ClickHouseShortValue(boolean isNull, short value)
  • Method Details

    • ofNull

      public static ClickHouseShortValue ofNull()
      Creates a new instance representing null Int16 value.
      Returns:
      new instance representing null value
    • ofUnsignedNull

      public static ClickHouseShortValue ofUnsignedNull()
      Creates a new instance representing null UInt16 value.
      Returns:
      new instance representing null value
    • ofNull

      public static ClickHouseShortValue ofNull(boolean unsigned)
      Creates a new instance representing null value.
      Parameters:
      unsigned - true if the value is unsigned; false otherwise
      Returns:
      new instance representing null value
    • ofNull

      public static ClickHouseShortValue ofNull(ClickHouseValue ref, boolean unsigned)
      Updates the given value to null or creates a new instance when ref is null.
      Parameters:
      ref - object to update, could be null
      unsigned - true if the value is unsigned; false otherwise
      Returns:
      same object as ref or a new instance if it's null
    • of

      public static ClickHouseShortValue of(short value)
      Wraps the given Int16 value.
      Parameters:
      value - value
      Returns:
      object representing the value
    • ofUnsigned

      public static ClickHouseShortValue ofUnsigned(short value)
      Wraps the given UInt16 value.
      Parameters:
      value - value
      Returns:
      object representing the value
    • of

      public static ClickHouseShortValue of(short value, boolean unsigned)
      Wraps the given value.
      Parameters:
      value - value
      unsigned - true if value is unsigned; false otherwise
      Returns:
      object representing the value
    • of

      public static ClickHouseShortValue of(int value)
      Wraps the given Int16 value.
      Parameters:
      value - value
      Returns:
      object representing the value
    • ofUnsigned

      public static ClickHouseShortValue ofUnsigned(int value)
      Wraps the given UInt16 value.
      Parameters:
      value - value
      Returns:
      object representing the value
    • of

      public static ClickHouseShortValue of(int value, boolean unsigned)
      Wraps the given value.
      Parameters:
      value - value
      unsigned - true if value is unsigned; false otherwise
      Returns:
      object representing the value
    • of

      public static ClickHouseShortValue of(Number value, boolean unsigned)
      Wraps the given value.
      Parameters:
      value - value
      unsigned - true if value is unsigned; false otherwise
      Returns:
      object representing the value
    • of

      public static ClickHouseShortValue of(ClickHouseValue ref, short value, boolean unsigned)
      Updates value of the given object or create a new instance when ref is null.
      Parameters:
      ref - object to update, could be null
      value - value
      unsigned - true if value is unsigned; false otherwise
      Returns:
      same object as ref or a new instance if it's null
    • set

      protected final ClickHouseShortValue set(boolean isNull, short value)
    • getValue

      public final short getValue()
      Gets value.
      Returns:
      value
    • copy

      public ClickHouseShortValue copy(boolean deep)
      Description copied from interface: ClickHouseValue
      Gets a copy of this value object.
      Specified by:
      copy in interface ClickHouseValue
      Parameters:
      deep - true to create a deep copy; false for a shallow copy
      Returns:
      copy of this value object
    • isNullOrEmpty

      public final 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 interface ClickHouseValue
      Returns:
      true if the value is null or empty; false otherwise
    • asByte

      public byte asByte()
      Description copied from interface: ClickHouseValue
      Gets value as byte.
      Specified by:
      asByte in interface ClickHouseValue
      Returns:
      byte value
    • asShort

      public short asShort()
      Description copied from interface: ClickHouseValue
      Gets value as short.
      Specified by:
      asShort in interface ClickHouseValue
      Returns:
      short value
    • asInteger

      public int asInteger()
      Description copied from interface: ClickHouseValue
      Gets value as integer.
      Specified by:
      asInteger in interface ClickHouseValue
      Returns:
      integer value
    • asLong

      public long asLong()
      Description copied from interface: ClickHouseValue
      Gets value as long.
      Specified by:
      asLong in interface ClickHouseValue
      Returns:
      long value
    • asBigInteger

      public BigInteger asBigInteger()
      Description copied from interface: ClickHouseValue
      Gets value as BigInteger.
      Specified by:
      asBigInteger in interface ClickHouseValue
      Returns:
      big integer, could be null
    • asFloat

      public float asFloat()
      Description copied from interface: ClickHouseValue
      Gets value as float.
      Specified by:
      asFloat in interface ClickHouseValue
      Returns:
      float value
    • asDouble

      public double asDouble()
      Description copied from interface: ClickHouseValue
      Gets value as double.
      Specified by:
      asDouble in interface ClickHouseValue
      Returns:
      double value
    • asBigDecimal

      public BigDecimal asBigDecimal(int scale)
      Description copied from interface: ClickHouseValue
      Gets value as BigDecimal.
      Specified by:
      asBigDecimal in interface ClickHouseValue
      Parameters:
      scale - scale of the decimal
      Returns:
      big decimal, could be null
    • asObject

      public Object asObject()
      Description copied from interface: ClickHouseValue
      Gets value as an object.
      Specified by:
      asObject in interface ClickHouseValue
      Returns:
      an object representing the value, 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 interface ClickHouseValue
      Returns:
      string value, could be null
    • resetToDefault

      public ClickHouseShortValue resetToDefault()
      Description copied from interface: ClickHouseValue
      Resets to default value of corresponding data type.
      Specified by:
      resetToDefault in interface ClickHouseValue
      Returns:
      this object
    • resetToNullOrEmpty

      public ClickHouseShortValue 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 interface ClickHouseValue
      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 to 123, while string "12'3" will be converted to @{code '12\'3'}.
      Specified by:
      toSqlExpression in interface ClickHouseValue
      Returns:
      escaped SQL expression
    • update

      public ClickHouseShortValue update(boolean value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(char value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(byte value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(short value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(int value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(long value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(float value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(double value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(BigInteger value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(BigDecimal value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(Enum<?> value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(String value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(ClickHouseValue value)
      Description copied from interface: ClickHouseValue
      Updates value.
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update
      Returns:
      this object
    • update

      public ClickHouseShortValue update(Object value)
      Description copied from interface: ClickHouseValue
      Updates value. This method tries to identify type of value and then use corresponding update method to proceed. Unknown value will be passed to ClickHouseValue.updateUnknown(Object).
      Specified by:
      update in interface ClickHouseValue
      Parameters:
      value - value to update, could be null
      Returns:
      this object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object