org.h2.mvstore.type

## Class StringDataType

- java.lang.Object
- - org.h2.mvstore.type.BasicDataType<java.lang.String>
  - - org.h2.mvstore.type.StringDataType

All Implemented Interfaces:
  java.util.Comparator<java.lang.String>, DataType<java.lang.String>

    public class StringDataType
    extends BasicDataType<java.lang.String>

A string type.

### Field Summary

Fields
`static StringDataType` `INSTANCE`

### Constructor Summary

Constructors
Constructor and Description
`StringDataType()`

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `binarySearch(java.lang.String key, java.lang.Object storageObj, int size, int initialGuess)` Perform binary search for the key within the storage
`int` `compare(java.lang.String a, java.lang.String b)` Compare two keys.
`java.lang.String[]` `createStorage(int size)` Create storage object of array type to hold values
`int` `getMemory(java.lang.String obj)` Calculates the amount of used memory in bytes.
`java.lang.String` `read(java.nio.ByteBuffer buff)` Read an object.
`void` `write(WriteBuffer buff, java.lang.String s)` Write an object.

### Methods inherited from class org.h2.mvstore.type.BasicDataType

`cast, equals, hashCode, isMemoryEstimationAllowed, read, write`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

### Field Detail

#### INSTANCE

    public static final StringDataType INSTANCE

### Constructor Detail

#### StringDataType

    public StringDataType()

### Method Detail

#### createStorage

    public java.lang.String[] createStorage(int size)

Description copied from interface: `DataType`
Create storage object of array type to hold values

Parameters:
  `size` - number of values to hold
Returns:
  storage object

#### compare

    public int compare(java.lang.String a,
                       java.lang.String b)

Description copied from interface: `DataType`
Compare two keys.

Specified by:
  `compare` in interface `java.util.Comparator<java.lang.String>`
Specified by:
  `compare` in interface `DataType<java.lang.String>`
Overrides:
  `compare` in class `BasicDataType<java.lang.String>`
Parameters:
  `a` - the first key
  `b` - the second key
Returns:
  -1 if the first key is smaller, 1 if larger, and 0 if equal

#### binarySearch

    public int binarySearch(java.lang.String key,
                            java.lang.Object storageObj,
                            int size,
                            int initialGuess)

Description copied from interface: `DataType`
Perform binary search for the key within the storage

Specified by:
  `binarySearch` in interface `DataType<java.lang.String>`
Overrides:
  `binarySearch` in class `BasicDataType<java.lang.String>`
Parameters:
  `key` - to search for
  `storageObj` - to search within (an array of type T)
  `size` - number of data items in the storage
  `initialGuess` - for key position
Returns:
  index of the key , if found, - index of the insertion point, if not

#### getMemory

    public int getMemory(java.lang.String obj)

Description copied from interface: `DataType`
Calculates the amount of used memory in bytes.

Specified by:
  `getMemory` in interface `DataType<java.lang.String>`
Specified by:
  `getMemory` in class `BasicDataType<java.lang.String>`
Parameters:
  `obj` - the object
Returns:
  the used memory

#### read

    public java.lang.String read(java.nio.ByteBuffer buff)

Description copied from interface: `DataType`
Read an object.

Specified by:
  `read` in interface `DataType<java.lang.String>`
Specified by:
  `read` in class `BasicDataType<java.lang.String>`
Parameters:
  `buff` - the source buffer
Returns:
  the object

#### write

    public void write(WriteBuffer buff,
                      java.lang.String s)

Description copied from interface: `DataType`
Write an object.

Specified by:
  `write` in interface `DataType<java.lang.String>`
Specified by:
  `write` in class `BasicDataType<java.lang.String>`
Parameters:
  `buff` - the target buffer
  `s` - the value