Get the SQL type of this field.
Typically BOOLEAN or BYTE.
@param bIncludeLength Include the field length in this description.
@param properties Database properties to determine the SQL type.
975609
public String getSQLType(boolean bIncludeLength, Map<String, Object> properties) 
    {
        String strType = (String)properties.get(DBSQLTypes.BOOLEAN);
        if (strType == null)
            strType = DBSQLTypes.BYTE;      // The default SQL Type (Byte)
        return strType;
    }
1121335
public int getSolverLength() {
    // Attribute name alias, creation date, Id length,
    int length = 4 + 8 + 4;

    // Id,
    if (this.identifier != null) {
      try {
        length += this.identifier.getBytes("UTF-16BE").length;
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Unable to encode UTF16 strings.", e);
      }
    }

    // Data length
    length += 4;
    // Data
    if (this.data != null) {
      length += this.data.length;
    }

    return length;
  }
337976
public static InsertType detectInsertType(SQLiteModelMethod method) {
		SQLiteDaoDefinition daoDefinition = method.getParent();
		SQLiteEntity entity = method.getEntity();
		TypeName beanTypeName = typeName(entity.getElement());

		InsertType insertResultType = null;

		// check type of arguments
		int beanCounter = 0;
		int beanCollectionCounter = 0;
		for (Pair<String, TypeName> param : method.getParameters()) {
			if (TypeUtility.isEquals(param.value1, beanTypeName)) {
				beanCounter++;
			} else if (TypeUtility.isCollectionOfType(param.value1, beanTypeName)) {
				beanCollectionCounter++;
			}
		}

		AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() == 0, method,
				" INSERT operations require at least one parameter");

		if (beanCounter == 0 && beanCollectionCounter == 0) {
			// method to insert raw data: no bean is used
			insertResultType = InsertType.INSERT_RAW;

			ModelAnnotation annotation = method.getAnnotation(BindSqlInsert.class);

			// check value attribute
			AssertKripton.failWithInvalidMethodSignException(
					AnnotationUtility.extractAsStringArray(method, annotation, AnnotationAttributeType.FIELDS)
							.size() > 0,
					method, " can not use attribute %s in this kind of query definition",
					AnnotationAttributeType.FIELDS.getValue());

			// check excludeFields attribute
			AssertKripton.failWithInvalidMethodSignException(
					AnnotationUtility.extractAsStringArray(method, annotation, AnnotationAttributeType.EXCLUDED_FIELDS)
							.size() > 0,
					method, " can not use attribute %s in this kind of query definition",
					AnnotationAttributeType.EXCLUDED_FIELDS.getValue());

			// check if there is only one parameter
			AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() != 1
					&& TypeUtility.isEquals(method.getParameters().get(0).value1, daoDefinition.getEntityClassName()),
					method);

			// check no
			AssertKripton.failWithInvalidMethodSignException(
					annotation.getAttributeAsBoolean(AnnotationAttributeType.INCLUDE_PRIMARY_KEY), method,
					"attribute '%s' can not be used here", AnnotationAttributeType.INCLUDE_PRIMARY_KEY.getValue());

		} else if (beanCounter == 1) {
			insertResultType = InsertType.INSERT_BEAN;

			AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() > 1, method,
					" aspected only one parameter of %s type", daoDefinition.getEntityClassName());
		} else if (beanCollectionCounter == 1) {
			insertResultType = InsertType.INSERT_LIST_BEAN;
			AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() > 1, method,
					" aspected only one collection of %s type as parameter", daoDefinition.getEntityClassName());

			AssertKripton.assertTrueOrInvalidMethodSignException(
					TypeUtility.isCollectionOfType(method.getReturnClass(), beanTypeName)
							|| TypeUtility.isEquals(method.getReturnClass(), typeName(Void.TYPE)),
					method, " invalid return type for multiple insert method",
					daoDefinition.getEntityClassName());
		} else {
			throw (new InvalidMethodSignException(method,
					"only one parameter of type " + typeName(entity.getElement()) + " can be used"));
		}

		return insertResultType;
	}
1116405
public final boolean isPropertyTypeDeclared(String propertyName) {
    StaticTypedSlot slot = getSlot(propertyName);
    return slot == null ? false : !slot.isTypeInferred();
  }
393626
function checkFieldLength(parsed, field, length) {
  length = length || transactionFields[field].options.length;
  if (parsed.transactions[field] && parsed.transactions[field].toString().length > length) {
    console.log(parsed.transactions);
    console.log(field, parsed.transactions[field]);
  }
}
525273
public static JdbcType getJdbcTypeByReflection(String fieldType)
    {
        JdbcType result;
        
        if (fieldType.equalsIgnoreCase(Character.class.getName()) || fieldType.equalsIgnoreCase("char"))
            result = getJdbcTypeByName("char");
        else if (fieldType.equalsIgnoreCase(Short.class.getName()) || fieldType.equalsIgnoreCase("short"))
            result = getJdbcTypeByName("smallint");
        else if (fieldType.equalsIgnoreCase(Integer.class.getName()) || fieldType.equalsIgnoreCase("int"))
            result = getJdbcTypeByName("integer");
        else if (fieldType.equalsIgnoreCase(Long.class.getName()) || fieldType.equalsIgnoreCase("long"))
            result = getJdbcTypeByName("bigint");
        else if (fieldType.equalsIgnoreCase(Byte.class.getName()) || fieldType.equalsIgnoreCase("byte"))
            result = getJdbcTypeByName("tinyint");
        else if (fieldType.equalsIgnoreCase(Float.class.getName()) || fieldType.equalsIgnoreCase("float"))
            result = getJdbcTypeByName("real");
        else if (fieldType.equalsIgnoreCase(Double.class.getName()) || fieldType.equalsIgnoreCase("double"))
            result = getJdbcTypeByName("float");
        else if (fieldType.equalsIgnoreCase(String.class.getName()))
            result = getJdbcTypeByName("varchar");
        /*
        TODO: arminw: useful? This only will work in conjunction with  a FieldConversion
        */
        else if (fieldType.equalsIgnoreCase(java.util.Date.class.getName()))
            result = getJdbcTypeByName("date");
        else if (fieldType.equalsIgnoreCase(Date.class.getName()))
            result = getJdbcTypeByName("date");
        else if (fieldType.equalsIgnoreCase(Time.class.getName()))
            result = getJdbcTypeByName("time");
        else if (fieldType.equalsIgnoreCase(Timestamp.class.getName()))
            result = getJdbcTypeByName("timestamp");
        else if (fieldType.equalsIgnoreCase(BigDecimal.class.getName()))
            result = getJdbcTypeByName("decimal");
        else if (fieldType.equalsIgnoreCase(Ref.class.getName()))
            result = getJdbcTypeByName("ref");
        else if (fieldType.equalsIgnoreCase(Struct.class.getName()))
            result = getJdbcTypeByName("struct");
        else if (fieldType.equalsIgnoreCase(Boolean.class.getName()) || fieldType.equalsIgnoreCase("boolean"))
            result = getJdbcTypeByName("bit");
//#ifdef JDBC30
        else if (fieldType.equalsIgnoreCase(URL.class.getName()))
            result = getJdbcTypeByName("datalink");
//#endif
        else
            throw new OJBRuntimeException("The type " + fieldType + " can not be handled by OJB automatically."
                    + " Please specify a type as defined by java.sql.Types in your field-descriptor");
        return result;
    }
9514
public static int getTypeValForSqlType(SqlType sqlType) throws SQLException {
		int[] typeVals = typeToValMap.get(sqlType);
		if (typeVals == null) {
			throw new SQLException("SqlType is unknown to type val mapping: " + sqlType);
		}
		if (typeVals.length == 0) {
			throw new SQLException("SqlType does not have any JDBC type value mapping: " + sqlType);
		} else {
			return typeVals[0];
		}
	}
385936
private boolean isStringType(final JDBCType type) {
		return JDBCType.CHAR.equals(type) || JDBCType.NCHAR.equals(type) || JDBCType.VARCHAR.equals(type)
				|| JDBCType.NVARCHAR.equals(type) || JDBCType.LONGNVARCHAR.equals(type);
	}
12286
public function getBinaryTypeDeclarationSQL(array $field)
    {
        if (! isset($field['length'])) {
            $field['length'] = $this->getBinaryDefaultLength();
        }

        $fixed = $field['fixed'] ?? false;

        $maxLength = $this->getBinaryMaxLength();

        if ($field['length'] > $maxLength) {
            if ($maxLength > 0) {
                @trigger_error(sprintf(
                    'Binary field length %d is greater than supported by the platform (%d). Reduce the field length or use a BLOB field instead.',
                    $field['length'],
                    $maxLength
                ), E_USER_DEPRECATED);
            }

            return $this->getBlobTypeDeclarationSQL($field);
        }

        return $this->getBinaryTypeDeclarationSQLSnippet($field['length'], $fixed);
    }
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;
    }
1248272
public Class<?> getJavaType(int sqlType, String typeName, int size, int digits, String tableName, String columnName) {
        // table.column mapped class
        Type<?> type = javaTypeMapping.getType(tableName, columnName);
        if (type != null) {
            return type.getReturnedClass();
        } else if (typeName != null && !typeName.isEmpty()) {
            typeName = typeName.toLowerCase();
            // typename mapped class
            Class<?> clazz = typeToName.get(typeName);
            if (clazz != null) {
                return clazz;
            }
            if (sqlType == Types.ARRAY) {
                if (typeName.startsWith("_")) {
                    typeName = typeName.substring(1);
                } else if (typeName.endsWith(" array")) {
                    typeName = typeName.substring(0, typeName.length() - 6);
                }
                if (typeName.contains("[")) {
                    typeName = typeName.substring(0, typeName.indexOf("["));
                }
                if (typeName.contains("(")) {
                    typeName = typeName.substring(0, typeName.indexOf("("));
                }

                Integer sqlComponentType = templates.getCodeForTypeName(typeName);
                if (sqlComponentType == null) {
                    logger.warn("Found no JDBC type for " + typeName + " using OTHER instead");
                    sqlComponentType = Types.OTHER;
                }
                Class<?> componentType = jdbcTypeMapping.get(sqlComponentType, size, digits);
                return Array.newInstance(componentType, 0).getClass();
            }
        }
        // sql type mapped class
        return jdbcTypeMapping.get(sqlType, size, digits);
    }
921556
public int getColumnType(final int column) throws SQLException {
    ColumnInformation ci = getColumnInformation(column);
    switch (ci.getColumnType()) {
      case BIT:
        if (ci.getLength() == 1) {
          return Types.BIT;
        }
        return Types.VARBINARY;
      case TINYINT:
        if (ci.getLength() == 1 && options.tinyInt1isBit) {
          return Types.BIT;
        }
        return Types.TINYINT;
      case YEAR:
        if (options.yearIsDateType) {
          return Types.DATE;
        }
        return Types.SMALLINT;
      case BLOB:
        if (ci.getLength() < 0 || ci.getLength() > 16777215) {
          return Types.LONGVARBINARY;
        }
        return Types.VARBINARY;
      case VARCHAR:
      case VARSTRING:
        if (ci.isBinary()) {
          return Types.VARBINARY;
        }
        if (ci.getLength() < 0) {
          return Types.LONGVARCHAR;
        }
        return Types.VARCHAR;
      case STRING:
        if (ci.isBinary()) {
          return Types.BINARY;
        }
        return Types.CHAR;
      default:
        return ci.getColumnType().getSqlType();
    }

  }
613973
private void ensureLength(FieldDescriptorDef fieldDef, String checkLevel)
    {
        if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_LENGTH))
        {
            String defaultLength = JdbcTypeHelper.getDefaultLengthFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));

            if (defaultLength != null)
            {
                LogHelper.warn(true,
                               FieldDescriptorConstraints.class,
                               "ensureLength",
                               "The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no length setting though its jdbc type requires it (in most databases); using default length of "+defaultLength);
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_LENGTH, defaultLength);
            }
        }
    }
1287156
static int getWireFormatForFieldType(final WireFormat.FieldType type, boolean isPacked) {
        if (isPacked) {
            return WireFormat.WIRETYPE_LENGTH_DELIMITED;
        } else {
            return type.getWireType();
        }
    }
641568
public static int toSQLType(String strType) throws DatabaseException {
	strType = strType.toUpperCase().trim();
	if (strType.startsWith("CF_SQL_")) strType = strType.substring(7);
	if (strType.startsWith("SQL_")) strType = strType.substring(4);

	if (strType.length() > 2) {
	    char first = strType.charAt(0);
	    if (first == 'A') {
		if (strType.equals("ARRAY")) return Types.ARRAY;
	    }
	    else if (first == 'B') {
		if (strType.equals("BIGINT")) return Types.BIGINT;
		else if (strType.equals("BINARY")) return Types.BINARY;
		else if (strType.equals("BIT")) return Types.BIT;
		else if (strType.equals("BLOB")) return Types.BLOB;
		else if (strType.equals("BOOLEAN")) return Types.BOOLEAN;
		else if (strType.equals("BOOL")) return Types.BOOLEAN;
	    }
	    else if (first == 'C') {
		if (strType.equals("CLOB")) return Types.CLOB;
		else if (strType.equals("CHAR")) return Types.CHAR;
		else if (strType.equals("CLOB")) return Types.CLOB;
		else if (strType.equals("CURSOR")) return CFTypes.CURSOR;
	    }
	    else if (first == 'D') {
		if (strType.equals("DATALINK")) return Types.DATALINK;
		else if (strType.equals("DATE")) return Types.DATE;
		else if (strType.equals("DISTINCT")) return Types.DISTINCT;
		else if (strType.equals("DECIMAL")) return Types.DECIMAL;
		else if (strType.equals("DOUBLE")) return Types.DOUBLE;
	    }
	    else if (first == 'F') {
		if (strType.equals("FLOAT")) return Types.FLOAT;
	    }
	    else if (first == 'I') {
		if (strType.equals("IDSTAMP")) return CFTypes.IDSTAMP;
		else if (strType.equals("INTEGER")) return Types.INTEGER;
		else if (strType.equals("INT")) return Types.INTEGER;
	    }
	    else if (first == 'L') {
		// if(strType.equals("LONG"))return Types.INTEGER;
		if (strType.equals("LONGVARBINARY")) return Types.LONGVARBINARY;
		else if (strType.equals("LONGVARCHAR")) return Types.LONGVARCHAR;
	    }
	    else if (first == 'M') {
		if (strType.equals("MONEY")) return Types.DOUBLE;
		else if (strType.equals("MONEY4")) return Types.DOUBLE;
	    }
	    else if (first == 'N') {
		if (strType.equals("NUMERIC")) return Types.NUMERIC;
		else if (strType.equals("NUMBER")) return Types.NUMERIC;
		else if (strType.equals("NULL")) return Types.NULL;
		else if (strType.equals("NCHAR")) return Types.NCHAR;
		else if (strType.equals("NCLOB")) return Types.NCLOB;
		else if (strType.equals("NVARCHAR")) return Types.NVARCHAR;

	    }
	    else if (first == 'O') {
		if (strType.equals("OTHER")) return Types.OTHER;
		else if ("OBJECT".equals(strType)) return Types.OTHER;
	    }
	    else if (first == 'R') {
		if (strType.equals("REAL")) return Types.REAL;
		else if (strType.equals("REF")) return Types.REF;
		else if (strType.equals("REFCURSOR")) return CFTypes.CURSOR;
	    }
	    else if (first == 'S') {
		if (strType.equals("SMALLINT")) return Types.SMALLINT;
		else if (strType.equals("STRUCT")) return Types.STRUCT;
		else if (strType.equals("STRING")) return Types.VARCHAR;
		else if (strType.equals("SQLXML")) return Types.SQLXML;
	    }
	    else if (first == 'T') {
		if (strType.equals("TIME")) return Types.TIME;
		else if (strType.equals("TIMESTAMP")) return Types.TIMESTAMP;
		else if (strType.equals("TINYINT")) return Types.TINYINT;
	    }
	    else if (first == 'V') {
		if (strType.equals("VARBINARY")) return Types.VARBINARY;
		else if (strType.equals("VARCHAR")) return Types.VARCHAR;
		else if (strType.equals("VARCHAR2")) return CFTypes.VARCHAR2;
	    }
	}

	throw new DatabaseException("invalid CF SQL Type [" + strType + "]", null, null, null);
    }
756259
private int getLengthFromByteArray(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getShort();
    }
771142
public boolean doRemoteCriteria(StringBuffer strbFilter, boolean bIncludeFileName, Vector<BaseField> vParamList)
    {
        BaseField fldTarget = null;
        if (typeFieldName != null)
            fldTarget = this.getOwner().getField(typeFieldName);
        else
            fldTarget = this.getOwner().getField(m_iTypeField);
        String strToCompare = Integer.toString(m_iTargetValue);
        boolean bDontSkip = this.fieldCompare(fldTarget, strToCompare, DBConstants.EQUALS, strbFilter, bIncludeFileName, vParamList);
        if (strbFilter != null)
            bDontSkip = true; // Don't need to compare, if I'm creating a filter to pass to SQL 
        if (bDontSkip)
            return super.doRemoteCriteria(strbFilter, bIncludeFileName, vParamList);    // Dont skip this record
        else
            return false;   // Skip this one
    }