Class ClickHouseValueParser<T>
- java.lang.Object
-
- ru.yandex.clickhouse.response.parser.ClickHouseValueParser<T>
-
public abstract class ClickHouseValueParser<T> extends Object
-
-
Constructor Summary
Constructors Constructor Description ClickHouseValueParser()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected TgetDefaultValue()static <T> ClickHouseValueParser<T>getParser(Class<T> clazz)static longnormalizeTime(ClickHouseColumnInfo info, long time)abstract Tparse(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone timeZone)Parses the supplied byte fragmentvalueusing meta data contained incolumnInfo.static booleanparseBoolean(ByteFragment value, ClickHouseColumnInfo columnInfo)static doubleparseDouble(ByteFragment value, ClickHouseColumnInfo columnInfo)static floatparseFloat(ByteFragment value, ClickHouseColumnInfo columnInfo)static intparseInt(ByteFragment value, ClickHouseColumnInfo columnInfo)static longparseLong(ByteFragment value, ClickHouseColumnInfo columnInfo)static shortparseShort(ByteFragment value, ClickHouseColumnInfo columnInfo)TparseWithDefault(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone resultTimeZone)Parses the supplied byte fragmentvalueusing meta data contained incolumnInfo.
-
-
-
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 fragmentvalueusing meta data contained incolumnInfo. Date / time parsing usesresultTimeZone, unless only local values are involved.- Parameters:
value- value as returned from the servercolumnInfo- meta data of the columntimeZone- time zone to be used when parsing dates or times- Returns:
- the result of parsing
valueas an object of typeT - 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 fragmentvalueusing meta data contained incolumnInfo. Date / time parsing usesresultTimeZone, 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 valuecolumnInfo- meta data of the columnresultTimeZone- time zone to be used when parsing dates or times- Returns:
- the result of parsing
valueas an object of typeT - Throws:
SQLException- if the value cannot be parsed under the given circumstances
-
getDefaultValue
protected T getDefaultValue()
-
-