net.snowflake.client.core

## Class ResultUtil

- java.lang.Object
- - net.snowflake.client.core.ResultUtil

    public class ResultUtil
    extends Object

Created by jhuang on 2/1/16.

### Nested Class Summary

Nested Classes
`static class` `ResultUtil.ResultInput`
`static class` `ResultUtil.ResultOutput`

### Constructor Summary

Constructors
Constructor and Description
`ResultUtil()`

### Method Summary

All Methods Static Methods Concrete Methods
`static int` `calculateUpdateCount(SFBaseResultSet resultSet)`
`static boolean` `getBoolean(String str)` Converst snowflake bool to java boolean
`static String` `getBooleanAsString(boolean bool)` Convert a boolean to a string
`static Date` `getDate(String str, TimeZone tz, SFSession session)` Convert a date internal object to a Date object in specified timezone.
`static String` `getDateAsString(Date date, net.snowflake.common.core.SnowflakeDateTimeFormat dateFormatter)` Convert a date value into a string
`static net.snowflake.common.core.SFTime` `getSFTime(String obj, int scale, SFSession session)` Convert a time internal value (scaled number of seconds + fractional seconds) into an SFTime.
`static String` `getSFTimeAsString(net.snowflake.common.core.SFTime sft, int scale, net.snowflake.common.core.SnowflakeDateTimeFormat timeFormatter)` Convert a time value into a string
`static net.snowflake.common.core.SFTimestamp` `getSFTimestamp(String timestampStr, int scale, int internalColumnType, long resultVersion, TimeZone sessionTZ, SFSession session)` Convert a timestamp internal value (scaled number of seconds + fractional seconds) into a SFTimestamp.
`static String` `getSFTimestampAsString(net.snowflake.common.core.SFTimestamp sfTS, int columnType, int scale, net.snowflake.common.core.SnowflakeDateTimeFormat timestampNTZFormatter, net.snowflake.common.core.SnowflakeDateTimeFormat timestampLTZFormatter, net.snowflake.common.core.SnowflakeDateTimeFormat timestampTZFormatter, SFSession session)` Convert a SFTimestamp to a string value.
`static int` `listSearchCaseInsensitive(List<String> source, String target)` Given a list of String, do a case insensitive search for target string Used by resultsetMetadata to search for target column name
`static ResultUtil.ResultOutput` `processResult(ResultUtil.ResultInput resultData, SFSession sfSession)` A common helper to process result response

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

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

### Constructor Detail

#### ResultUtil

    public ResultUtil()

### Method Detail

#### processResult

    public static ResultUtil.ResultOutput processResult(ResultUtil.ResultInput resultData,
                                                        SFSession sfSession)
                                                 throws SnowflakeSQLException

A common helper to process result response

Parameters:
  `resultData` - wrapper object over simple json result
  `sfSession` - the Snowflake session
Returns:
  processed result output
Throws:
  `SnowflakeSQLException` - if failed to get number of columns

#### getSFTimestamp

    public static net.snowflake.common.core.SFTimestamp getSFTimestamp(String timestampStr,
                                                                       int scale,
                                                                       int internalColumnType,
                                                                       long resultVersion,
                                                                       TimeZone sessionTZ,
                                                                       SFSession session)
                                                                throws SFException

Convert a timestamp internal value (scaled number of seconds + fractional seconds) into a SFTimestamp.

Parameters:
  `timestampStr` - timestamp object
  `scale` - timestamp scale
  `internalColumnType` - snowflake timestamp type
  `resultVersion` - For new result version, timestamp with timezone is formatted as the seconds since epoch with fractional part in the decimal followed by time zone index. E.g.: "123.456 1440". Here 123.456 is the * number of seconds since epoch and 1440 is the timezone index.
  `sessionTZ` - session timezone
  `session` - session object
Returns:
  converted snowflake timestamp object
Throws:
  `SFException` - if timestampStr is an invalid timestamp

#### getSFTime

    public static net.snowflake.common.core.SFTime getSFTime(String obj,
                                                             int scale,
                                                             SFSession session)
                                                      throws SFException

Convert a time internal value (scaled number of seconds + fractional seconds) into an SFTime. Example: getSFTime("123.456", 5) returns an SFTime for 00:02:03.45600.

Parameters:
  `obj` - time object
  `scale` - time scale
  `session` - session object
Returns:
  snowflake time object
Throws:
  `SFException` - if time is invalid

#### getSFTimeAsString

    public static String getSFTimeAsString(net.snowflake.common.core.SFTime sft,
                                           int scale,
                                           net.snowflake.common.core.SnowflakeDateTimeFormat timeFormatter)

Convert a time value into a string

Parameters:
  `sft` - snowflake time object
  `scale` - time scale
  `timeFormatter` - time formatter
Returns:
  time in string

#### getBooleanAsString

    public static String getBooleanAsString(boolean bool)

Convert a boolean to a string

Parameters:
  `bool` - boolean
Returns:
  boolean in string

#### getSFTimestampAsString

    public static String getSFTimestampAsString(net.snowflake.common.core.SFTimestamp sfTS,
                                                int columnType,
                                                int scale,
                                                net.snowflake.common.core.SnowflakeDateTimeFormat timestampNTZFormatter,
                                                net.snowflake.common.core.SnowflakeDateTimeFormat timestampLTZFormatter,
                                                net.snowflake.common.core.SnowflakeDateTimeFormat timestampTZFormatter,
                                                SFSession session)
                                         throws SFException

Convert a SFTimestamp to a string value.

Parameters:
  `sfTS` - snowflake timestamp object
  `columnType` - internal snowflake t
  `scale` - timestamp scale
  `timestampNTZFormatter` - snowflake timestamp ntz format
  `timestampLTZFormatter` - snowflake timestamp ltz format
  `timestampTZFormatter` - snowflake timestamp tz format
  `session` - session object
Returns:
  timestamp in string in desired format
Throws:
  `SFException` - timestamp format is missing

#### getDateAsString

    public static String getDateAsString(Date date,
                                         net.snowflake.common.core.SnowflakeDateTimeFormat dateFormatter)

Convert a date value into a string

Parameters:
  `date` - date will be converted
  `dateFormatter` - date format
Returns:
  date in string

#### getDate

    public static Date getDate(String str,
                               TimeZone tz,
                               SFSession session)
                        throws SFException

Convert a date internal object to a Date object in specified timezone.

Parameters:
  `str` - snowflake date object
  `tz` - timezone we want convert to
  `session` - snowflake session object
Returns:
  java date object
Throws:
  `SFException` - if date is invalid

#### getBoolean

    public static boolean getBoolean(String str)

Converst snowflake bool to java boolean

Parameters:
  `str` - boolean type in string representation
Returns:
  true if the value indicates true otherwise false

#### calculateUpdateCount

    public static int calculateUpdateCount(SFBaseResultSet resultSet)
                                    throws SFException,
                                           SQLException

Throws:
  `SFException`
  `SQLException`

#### listSearchCaseInsensitive

    public static int listSearchCaseInsensitive(List<String> source,
                                                String target)

Given a list of String, do a case insensitive search for target string Used by resultsetMetadata to search for target column name

Parameters:
  `source` - source string list
  `target` - target string to match
Returns:
  index in the source string list that matches the target string