Get boolean from raw binary format.

@param columnInfo column information
@return boolean value
@throws SQLException if column type doesn't permit conversion
770642
public boolean getInternalBoolean(ColumnInformation columnInfo) throws SQLException {
    if (lastValueWasNull()) {
      return false;
    }
    switch (columnInfo.getColumnType()) {
      case BIT:
        return parseBit() != 0;
      case TINYINT:
        return getInternalTinyInt(columnInfo) != 0;
      case SMALLINT:
      case YEAR:
        return getInternalSmallInt(columnInfo) != 0;
      case INTEGER:
      case MEDIUMINT:
        return getInternalMediumInt(columnInfo) != 0;
      case BIGINT:
        return getInternalLong(columnInfo) != 0;
      case FLOAT:
        return getInternalFloat(columnInfo) != 0;
      case DOUBLE:
        return getInternalDouble(columnInfo) != 0;
      case DECIMAL:
      case OLDDECIMAL:
        return getInternalBigDecimal(columnInfo).longValue() != 0;
      default:
        final String rawVal = new String(buf, pos, length, StandardCharsets.UTF_8);
        return !("false".equals(rawVal) || "0".equals(rawVal));
    }
  }
717971
public BooleanType castToBoolean(Base b) throws FHIRException {
		if (b instanceof BooleanType)
			return (BooleanType) b;
		else
			throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean");
	}
1051049
private boolean query()
		throws SQLException
	{
		statement = this.connection.createStatement();

		String query = "SELECT PrimaryKey, RevisionCounter,"
				+ " RevisionID, ArticleID, Timestamp, FullRevisionID "
				+ "FROM revisions";

		if (primaryKey > 0) {
			query += " WHERE PrimaryKey > " + primaryKey;
		}

		if (MAX_NUMBER_RESULTS > 0) {
			query += " LIMIT " + MAX_NUMBER_RESULTS;
		}

		result = statement.executeQuery(query);
		return result.next();
	}
575157
public String getColumnName(final int column) throws SQLException {
    String columnName = getColumnInformation(column).getOriginalName();
    if (returnTableAlias) {
      columnName = getColumnInformation(column).getName(); //for old mysql compatibility
    }

    if ("".equals(columnName)) {
      // odd things that are no columns, e.g count(*)
      columnName = getColumnLabel(column);
    }
    return columnName;
  }
1267329
@Override
    public Boolean get(int i) {
        byte b = data.getByte(i);
        if (b == BooleanColumnType.BYTE_TRUE) {
            return Boolean.TRUE;
        }
        if (b == BooleanColumnType.BYTE_FALSE) {
            return Boolean.FALSE;
        }
        return null;
    }
1267692
function convertRawBoolean(rawColumnValue, column, context)
{
  var ret;

  if ((rawColumnValue === '1') || (rawColumnValue === 'TRUE'))
  {
    ret = true;
  }
  else if ((rawColumnValue === '0') || (rawColumnValue === 'FALSE'))
  {
    ret = false;
  }

  return ret;
}
395022
public long getInternalLong(ColumnInformation columnInfo) throws SQLException {
    if (lastValueWasNull()) {
      return 0;
    }
    try {
      switch (columnInfo.getColumnType()) {
        case FLOAT:
          Float floatValue = Float.valueOf(new String(buf, pos, length, StandardCharsets.UTF_8));
          if (floatValue.compareTo((float) Long.MAX_VALUE) >= 1) {
            throw new SQLException(
                "Out of range value for column '" + columnInfo.getName() + "' : value "
                    + new String(buf, pos, length, StandardCharsets.UTF_8)
                    + " is not in Long range", "22003", 1264);
          }
          return floatValue.longValue();
        case DOUBLE:
          Double doubleValue = Double.valueOf(new String(buf, pos, length, StandardCharsets.UTF_8));
          if (doubleValue.compareTo((double) Long.MAX_VALUE) >= 1) {
            throw new SQLException(
                "Out of range value for column '" + columnInfo.getName() + "' : value "
                    + new String(buf, pos, length, StandardCharsets.UTF_8)
                    + " is not in Long range", "22003", 1264);
          }
          return doubleValue.longValue();
        case BIT:
          return parseBit();
        case TINYINT:
        case SMALLINT:
        case YEAR:
        case INTEGER:
        case MEDIUMINT:
        case BIGINT:
          long result = 0;
          boolean negate = false;
          int begin = pos;
          if (length > 0 && buf[begin] == 45) { //minus sign
            negate = true;
            begin++;
          }
          for (; begin < pos + length; begin++) {
            result = result * 10 + buf[begin] - 48;
          }
          //specific for BIGINT : if value > Long.MAX_VALUE , will become negative until -1
          if (result < 0) {
            //CONJ-399 : handle specifically Long.MIN_VALUE that has absolute value +1 compare to LONG.MAX_VALUE
            if (result == Long.MIN_VALUE && negate) {
              return Long.MIN_VALUE;
            }
            throw new SQLException(
                "Out of range value for column '" + columnInfo.getName() + "' for value "
                    + new String(buf, pos, length, StandardCharsets.UTF_8), "22003", 1264);
          }
          return (negate ? -1 * result : result);
        default:
          return Long.parseLong(new String(buf, pos, length, StandardCharsets.UTF_8));
      }

    } catch (NumberFormatException nfe) {
      //parse error.
      //if its a decimal retry without the decimal part.
      String value = new String(buf, pos, length, StandardCharsets.UTF_8);
      if (isIntegerRegex.matcher(value).find()) {
        try {
          return Long.parseLong(value.substring(0, value.indexOf(".")));
        } catch (NumberFormatException nfee) {
          //eat exception
        }
      }
      throw new SQLException(
          "Out of range value for column '" + columnInfo.getName() + "' : value " + value, "22003",
          1264);
    }
  }
583680
public boolean getBoolean(String fieldName) throws DbfException {
        Boolean value = (Boolean) get(fieldName);
        return value != null && value;
    }
936816
public String getColumnClassName(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        VoltType type = sourceResultSet.table.getColumnType(column - 1);
        String result = type.getJdbcClass();
        if (result == null) {
            throw SQLError.get(SQLError.TRANSLATION_NOT_FOUND, type);
        }
        return result;
    }
633857
String getColIsNullable(int i) {

        ColumnSchema column = table.getColumn(i);

        return (column.isNullable() && !column.isPrimaryKey()) ? "YES"
                                                               : "NO";
    }
1052275
public int getPrecision(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        VoltType type = sourceResultSet.table.getColumnType(column - 1);
        Integer result =  type.getTypePrecisionAndRadix()[0];
        if (result == null) {
            result = 0;
        }
        return result;
    }
175912
@Override
    protected VoltTable.ColumnInfo getColumnInfo(String columnTypeName, String colName) {
        return super.getColumnInfo(getVoltColumnTypeName(columnTypeName), colName);
    }
78610
public String getColumnName(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        return sourceResultSet.table.getColumnName(column - 1);
    }
913023
Integer getColBufLen(int i) {

        int          size;
        int          type;
        ColumnSchema column;

        column = table.getColumn(i);
        type   = column.getDataType().getJDBCTypeCode();

        switch (type) {

            case Types.SQL_CHAR :
            case Types.SQL_CLOB :
            case Types.VARCHAR_IGNORECASE :
            case Types.SQL_VARCHAR : {
                size = column.getDataType().precision > Integer.MAX_VALUE
                       ? Integer.MAX_VALUE
                       : (int) column.getDataType().precision;

                if (size == 0) {}
                else if (size > HALF_MAX_INT) {
                    size = 0;
                } else {
                    size = 2 * size;
                }

                break;
            }
            case Types.SQL_BINARY :
            case Types.SQL_BLOB :
            case Types.SQL_VARBINARY : {
                size = column.getDataType().precision > Integer.MAX_VALUE
                       ? Integer.MAX_VALUE
                       : (int) column.getDataType().precision;

                break;
            }
            case Types.SQL_BIGINT :
            case Types.SQL_DOUBLE :
            case Types.SQL_FLOAT :
            case Types.SQL_DATE :
            case Types.SQL_REAL :
            case Types.SQL_TIME_WITH_TIME_ZONE :
            case Types.SQL_TIME : {
                size = 8;

                break;
            }
            case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
            case Types.SQL_TIMESTAMP : {
                size = 12;

                break;
            }
            case Types.SQL_INTEGER :
            case Types.SQL_SMALLINT :
            case Types.TINYINT : {
                size = 4;

                break;
            }
            case Types.SQL_BOOLEAN : {
                size = 1;

                break;
            }
            default : {
                size = 0;

                break;
            }
        }

        return (size > 0) ? ValuePool.getInt(size)
                          : null;
    }
1260660
public String getInternalString(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
      throws SQLException {
    if (lastValueWasNull()) {
      return null;
    }

    switch (columnInfo.getColumnType()) {
      case BIT:
        return String.valueOf(parseBit());
      case DOUBLE:
      case FLOAT:
        return zeroFillingIfNeeded(new String(buf, pos, length, StandardCharsets.UTF_8),
            columnInfo);
      case TIME:
        return getInternalTimeString(columnInfo);
      case DATE:
        Date date = getInternalDate(columnInfo, cal, timeZone);
        if (date == null) {
          if ((lastValueNull & BIT_LAST_ZERO_DATE) != 0) {
            lastValueNull ^= BIT_LAST_ZERO_DATE;
            return new String(buf, pos, length, StandardCharsets.UTF_8);
          }
          return null;
        }
        return date.toString();
      case YEAR:
        if (options.yearIsDateType) {
          Date date1 = getInternalDate(columnInfo, cal, timeZone);
          return (date1 == null) ? null : date1.toString();
        }
        break;
      case TIMESTAMP:
      case DATETIME:
        Timestamp timestamp = getInternalTimestamp(columnInfo, cal, timeZone);
        if (timestamp == null) {
          if ((lastValueNull & BIT_LAST_ZERO_DATE) != 0) {
            lastValueNull ^= BIT_LAST_ZERO_DATE;
            return new String(buf, pos, length, StandardCharsets.UTF_8);
          }
          return null;
        }
        return timestamp.toString();
      case DECIMAL:
      case OLDDECIMAL:
        BigDecimal bigDecimal = getInternalBigDecimal(columnInfo);
        return (bigDecimal == null) ? null : zeroFillingIfNeeded(bigDecimal.toString(), columnInfo);
      case NULL:
        return null;
      default:
        break;
    }

    if (maxFieldSize > 0) {
      return new String(buf, pos, Math.min(maxFieldSize * 3, length), StandardCharsets.UTF_8)
          .substring(0, Math.min(maxFieldSize, length));
    }

    return new String(buf, pos, length, StandardCharsets.UTF_8);
  }
335196
public static Type toType(String columnDef) {
		if ("BIGINT".equalsIgnoreCase(columnDef))
			return Type.BIGINT;
		if ("BINARY".equalsIgnoreCase(columnDef))
			return Type.BINARY;
		if ("BIT".equalsIgnoreCase(columnDef))
			return Type.BIT;
		if ("BLOB".equalsIgnoreCase(columnDef))
			return Type.BLOB;
		if ("BOOLEAN".equalsIgnoreCase(columnDef))
			return Type.BOOLEAN;
		if ("CHAR".equalsIgnoreCase(columnDef))
			return Type.CHAR;
		if ("CLOB".equalsIgnoreCase(columnDef))
			return Type.CLOB;
		if ("DATE".equalsIgnoreCase(columnDef))
			return Type.DATE;
		if ("DECIMAL".equalsIgnoreCase(columnDef))
			return Type.DECIMAL;
		if ("DOUBLE".equalsIgnoreCase(columnDef))
			return Type.DOUBLE;
		if ("FLOAT".equalsIgnoreCase(columnDef))
			return Type.FLOAT;
		if ("INTEGER".equalsIgnoreCase(columnDef))
			return Type.INTEGER;
		if ("JAVA_OBJECT".equalsIgnoreCase(columnDef))
			return Type.JAVA_OBJECT;
		if ("LONGNVARCHAR".equalsIgnoreCase(columnDef))
			return Type.LONGNVARCHAR;
		if ("LONGVARBINARY".equalsIgnoreCase(columnDef))
			return Type.LONGVARBINARY;
		if ("LONGVARCHAR".equalsIgnoreCase(columnDef))
			return Type.LONGVARCHAR;
		if ("NCHAR".equalsIgnoreCase(columnDef))
			return Type.NCHAR;
		if ("NCLOB".equalsIgnoreCase(columnDef))
			return Type.NCLOB;
		if ("NUMERIC".equalsIgnoreCase(columnDef))
			return Type.NUMERIC;
		if ("NVARCHAR".equalsIgnoreCase(columnDef))
			return Type.NVARCHAR;
		if ("OTHER".equalsIgnoreCase(columnDef))
			return Type.OTHER;
		if ("REAL".equalsIgnoreCase(columnDef))
			return Type.REAL;
		if ("SMALLINT".equalsIgnoreCase(columnDef))
			return Type.SMALLINT;
		if ("TIME".equalsIgnoreCase(columnDef))
			return Type.TIME;
		if ("TIMESTAMP".equalsIgnoreCase(columnDef))
			return Type.TIMESTAMP;
		if ("TINYINT".equalsIgnoreCase(columnDef))
			return Type.TINYINT;
		if ("VARBINARY".equalsIgnoreCase(columnDef))
			return Type.VARBINARY;
		if ("VARCHAR".equalsIgnoreCase(columnDef))
			return Type.VARCHAR;
		// @formatter:on
		throw new DialectException("'" + columnDef + "' is not a legal SQL column definition name");
	}
502543
public int getColumnDisplaySize(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        VoltType type = sourceResultSet.table.getColumnType(column - 1);
        switch(type)
        {
            case TINYINT:
                return (new Byte(Byte.MIN_VALUE)).toString().length();
            case SMALLINT:
                return (new Short(Short.MIN_VALUE)).toString().length();
            case INTEGER:
                return (new Integer(Integer.MIN_VALUE)).toString().length();
            case BIGINT:
                return (new Long(Long.MIN_VALUE)).toString().length();
            case FLOAT:
                return (new Double(Double.MIN_VALUE)).toString().length();
            case DECIMAL:
                return 40;
            case TIMESTAMP:
                return 32;
            case GEOGRAPHY_POINT:
                return GeographyPointValue.getValueDisplaySize();
            case STRING:
            case VARBINARY:
            case GEOGRAPHY:
                return 128; // That is wrong: should be length in bytes / 3 (max bytes per char for UTF8), but we don't receive the length!
            default:
                throw SQLError.get(SQLError.TRANSLATION_NOT_FOUND, type);
        }
    }