Package org.h2.value

Class ValueBlob

All Implemented Interfaces:
HasSQL, Typed

public final class ValueBlob extends ValueLob
Implementation of the BINARY LARGE OBJECT data type.
  • Constructor Details

    • ValueBlob

      public ValueBlob(LobData lobData, long octetLength)
  • Method Details

    • createSmall

      public static ValueBlob createSmall(byte[] data)
      Creates a small BLOB value that can be stored in the row directly.
      Parameters:
      data - the data
      Returns:
      the BLOB
    • createTempBlob

      public static ValueBlob createTempBlob(InputStream in, long length, DataHandler handler)
      Create a temporary BLOB value from a stream.
      Parameters:
      in - the input stream
      length - the number of characters to read, or -1 for no limit
      handler - the data handler
      Returns:
      the lob value
    • createTemporary

      private static ValueBlob createTemporary(DataHandler handler, byte[] buff, int len, InputStream in, long remaining) throws IOException
      Create a BLOB in a temporary file.
      Throws:
      IOException
    • getValueType

      public int getValueType()
      Description copied from class: Value
      Get the value type.
      Specified by:
      getValueType in class Value
      Returns:
      the value type
    • getString

      public String getString()
      Description copied from class: Value
      Get the value as a string.
      Specified by:
      getString in class Value
      Returns:
      the string
    • getBytesInternal

      byte[] getBytesInternal()
      Specified by:
      getBytesInternal in class ValueLob
    • getInputStream

      public InputStream getInputStream()
      Overrides:
      getInputStream in class Value
    • getInputStream

      public InputStream getInputStream(long oneBasedOffset, long length)
      Description copied from class: Value
      Get the input stream
      Overrides:
      getInputStream in class Value
      Parameters:
      oneBasedOffset - the offset (1 means no offset)
      length - the requested length
      Returns:
      the new input stream
    • getReader

      public Reader getReader(long oneBasedOffset, long length)
      Description copied from class: Value
      Get the reader
      Overrides:
      getReader in class Value
      Parameters:
      oneBasedOffset - the offset (1 means no offset)
      length - the requested length
      Returns:
      the new reader
    • compareTypeSafe

      public int compareTypeSafe(Value v, CompareMode mode, CastDataProvider provider)
      Description copied from class: Value
      Compare this value against another value given that the values are of the same data type.
      Specified by:
      compareTypeSafe in class Value
      Parameters:
      v - the other value
      mode - the compare mode
      provider - the cast information provider
      Returns:
      0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
    • compare

      private static int compare(ValueBlob v1, ValueBlob v2)
      Compares two BLOB values directly.
      Parameters:
      v1 - first BLOB value
      v2 - second BLOB value
      Returns:
      result of comparison
    • getSQL

      public StringBuilder getSQL(StringBuilder builder, int sqlFlags)
      Description copied from interface: HasSQL
      Appends the SQL statement of this object to the specified builder.
      Parameters:
      builder - string builder
      sqlFlags - formatting flags
      Returns:
      the specified string builder
    • convertPrecision

      ValueBlob convertPrecision(long precision)
      Convert the precision to the requested value.
      Parameters:
      precision - the new precision
      Returns:
      the truncated or this value
    • copy

      public ValueLob copy(DataHandler database, int tableId)
      Description copied from class: ValueLob
      Copy a large value, to be used in the given table. For values that are kept fully in memory this method has no effect.
      Specified by:
      copy in class ValueLob
      Parameters:
      database - the data handler
      tableId - the table where this object is used
      Returns:
      the new value or itself
    • charLength

      public long charLength()
      Description copied from class: Value
      Returns length of this value in characters.
      Overrides:
      charLength in class Value
      Returns:
      length of this value in characters
    • octetLength

      public long octetLength()
      Description copied from class: Value
      Returns length of this value in bytes.
      Overrides:
      octetLength in class Value
      Returns:
      length of this value in bytes