ru.yandex.clickhouse.response.parser

## Class ClickHouseValueParser<T>

- java.lang.Object
- - ru.yandex.clickhouse.response.parser.ClickHouseValueParser<T>

    public abstract class ClickHouseValueParser<T>
    extends Object

### Constructor Summary

Constructors
Constructor and Description
`ClickHouseValueParser()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`protected T` `getDefaultValue()`
`static <T> ClickHouseValueParser<T>` `getParser(Class<T> clazz)`
`static long` `normalizeTime(ClickHouseColumnInfo info, long time)`
`abstract T` `parse(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone timeZone)` Parses the supplied byte fragment `value` using meta data contained in `columnInfo`.
`static boolean` `parseBoolean(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`static double` `parseDouble(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`static float` `parseFloat(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`static int` `parseInt(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`static long` `parseLong(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`static short` `parseShort(ByteFragment value, ClickHouseColumnInfo columnInfo)`
`T` `parseWithDefault(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone resultTimeZone)` Parses the supplied byte fragment `value` using meta data contained in `columnInfo`.

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

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

### Constructor Detail

#### ClickHouseValueParser

    public ClickHouseValueParser()

### Method Detail

#### normalizeTime

    public static long normalizeTime(ClickHouseColumnInfo info,
                                     long time)

#### getParser

    public static <T> ClickHouseValueParser<T> getParser(Class<T> clazz)
                                                  throws SQLException

Throws:
  `SQLException`

#### parseInt

    public static final int parseInt(ByteFragment value,
                                     ClickHouseColumnInfo columnInfo)
                              throws SQLException

Throws:
  `SQLException`

#### parseLong

    public static final long parseLong(ByteFragment value,
                                       ClickHouseColumnInfo columnInfo)
                                throws SQLException

Throws:
  `SQLException`

#### parseBoolean

    public static final boolean parseBoolean(ByteFragment value,
                                             ClickHouseColumnInfo columnInfo)
                                      throws SQLException

Throws:
  `SQLException`

#### parseShort

    public static final short parseShort(ByteFragment value,
                                         ClickHouseColumnInfo columnInfo)
                                  throws SQLException

Throws:
  `SQLException`

#### parseDouble

    public static final double parseDouble(ByteFragment value,
                                           ClickHouseColumnInfo columnInfo)
                                    throws SQLException

Throws:
  `SQLException`

#### parseFloat

    public static final float parseFloat(ByteFragment value,
                                         ClickHouseColumnInfo columnInfo)
                                  throws SQLException

Throws:
  `SQLException`

#### parse

    public abstract T parse(ByteFragment value,
                            ClickHouseColumnInfo columnInfo,
                            TimeZone timeZone)
                     throws SQLException

Parses the supplied byte fragment `value` using meta data contained in `columnInfo`. Date / time parsing uses `resultTimeZone`, unless only local values are involved.

Parameters:
  `value` - value as returned from the server
  `columnInfo` - meta data of the column
  `timeZone` - time zone to be used when parsing dates or times
Returns:
  the result of parsing `value` as an object of type `T`
Throws:
  `SQLException` - if the value cannot be parsed under the given circumstances

#### parseWithDefault

    public T parseWithDefault(ByteFragment value,
                              ClickHouseColumnInfo columnInfo,
                              TimeZone resultTimeZone)
                       throws SQLException

Parses the supplied byte fragment `value` using meta data contained in `columnInfo`. Date / time parsing uses `resultTimeZone`, unless only local values are involved.

If the result would be null, this method will check if there is a default value in place which should be returned instead. The default value depends on the class. This method is intended to be used when parsing numeric values which later need to be converted to primitive, e.g. int or float.

Parameters:
  `value` - value as returned from the server or a default value
  `columnInfo` - meta data of the column
  `resultTimeZone` - time zone to be used when parsing dates or times
Returns:
  the result of parsing `value` as an object of type `T`
Throws:
  `SQLException` - if the value cannot be parsed under the given circumstances

#### getDefaultValue

    protected T getDefaultValue()