当前位置: 首页>>代码示例>>Java>>正文


Java ColumnType.isNumber方法代码示例

本文整理汇总了Java中org.apache.metamodel.schema.ColumnType.isNumber方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnType.isNumber方法的具体用法?Java ColumnType.isNumber怎么用?Java ColumnType.isNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.metamodel.schema.ColumnType的用法示例。


在下文中一共展示了ColumnType.isNumber方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSize

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
/**
 * Gets the size (in bytes) of a column with a specific {@link ColumnType}
 * and size
 */
private int getSize(ColumnType type, int columnSize) {
	final int baseSize;
	if (type.isBinary()) {
		baseSize = 1;
	} else if (type.isBoolean()) {
		baseSize = 1;
	} else if (type.isLiteral()) {
		baseSize = 2;
	} else if (type.isNumber()) {
		baseSize = 16;
	} else {
		baseSize = DEFAULT_COLUMN_SIZE;
	}

	int result = baseSize * columnSize;

	if (type.isLargeObject()) {
		// assign at least 4KB for LOBs.
		result = Math.max(result, 4 * KB);
	}

	return result;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:28,代码来源:FetchSizeCalculator.java

示例2: convert

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
private Object convert(final String value, final ColumnType type) {
    if (value == null) {
        return null;
    }
    if (type == null) {
        return value;
    }

    final Object result;
    if (type.isNumber()) {
        result = NumberComparator.toNumber(value);
    } else if (type.isBoolean()) {
        result = BooleanComparator.toBoolean(value);
    } else if (type.isTimeBased()) {
        result = TimeComparator.toDate(value);
    } else {
        result = value;
    }

    if (result == null) {
        throw new IllegalStateException("Failed to convert value '" + value + "' to type: " + type);
    }

    return result;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:26,代码来源:SugarCrmDataSet.java

示例3: convertType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
static Object convertType(final Object value, final Column targetColumn) throws IllegalArgumentException {
    if (value == null) {
        return null;
    }
    Object result = value;
    final ColumnType type = targetColumn.getType();
    if (type.isLiteral()) {
        // for strings, only convert some simple cases, since JDBC drivers
        // typically also do a decent job here (with eg. Clob types, char[]
        // types etc.)
        if (value instanceof Number || value instanceof Date) {
            result = value.toString();
        }
    } else if (type.isNumber()) {
        final Number numberValue = ConvertToNumberTransformer.transformValue(value);
        if (numberValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to number");
        }
        result = numberValue;
    } else if (type == ColumnType.BOOLEAN) {
        final Boolean booleanValue = ConvertToBooleanTransformer.transformValue(value);
        if (booleanValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to boolean");
        }
        result = booleanValue;
    }
    return result;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:29,代码来源:TypeConverter.java

示例4: convertType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
private Object convertType(final Object value, Column targetColumn) throws IllegalArgumentException {
    if (value == null) {
        return null;
    }
    Object result = value;
    ColumnType type = targetColumn.getType();
    if (type.isLiteral()) {
        // for strings, only convert some simple cases, since JDBC drivers
        // typically also do a decent job here (with eg. Clob types, char[]
        // types etc.)
        if (value instanceof Number || value instanceof Date) {
            result = value.toString();
        }
    } else if (type.isNumber()) {
        Number numberValue = ConvertToNumberTransformer.transformValue(value);
        if (numberValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to number");
        }
        result = numberValue;
    } else if (type == ColumnType.BOOLEAN) {
        Boolean booleanValue = ConvertToBooleanTransformer.transformValue(value);
        if (booleanValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to boolean");
        }
        result = booleanValue;
    }
    return result;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:29,代码来源:InsertIntoTableAnalyzer.java

示例5: toAttributeType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
public static ScalarAttributeType toAttributeType(ColumnType type) {
    if (type == null) {
        return ScalarAttributeType.S;
    }
    if (type.isBinary()) {
        return ScalarAttributeType.B;
    }
    if (type.isNumber()) {
        return ScalarAttributeType.S;
    }
    // default to string
    return ScalarAttributeType.S;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:14,代码来源:DynamoDbUtils.java

示例6: convert

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
private Object convert(Object value, ColumnType columnType) {
    if (value instanceof String && !columnType.isLiteral()) {
        if (columnType.isBoolean()) {
            return BooleanComparator.toBoolean(value);
        }
        if (columnType.isNumber()) {
            return NumberComparator.toNumber(value);
        }
        if (columnType.isTimeBased()) {
            final SimpleDateFormat dateFormat;
            if (columnType == ColumnType.DATE) {
                // note: we don't apply the timezone for DATE fields, since
                // they don't contain time-of-day information.
                dateFormat = new SimpleDateFormat(SalesforceDataContext.SOQL_DATE_FORMAT_IN, Locale.ENGLISH);
            } else if (columnType == ColumnType.TIME) {
                dateFormat = new SimpleDateFormat(SalesforceDataContext.SOQL_TIME_FORMAT_IN, Locale.ENGLISH);
                dateFormat.setTimeZone(SalesforceDataContext.SOQL_TIMEZONE);
            } else {
                dateFormat = new SimpleDateFormat(SalesforceDataContext.SOQL_DATE_TIME_FORMAT_IN, Locale.ENGLISH);
                dateFormat.setTimeZone(SalesforceDataContext.SOQL_TIMEZONE);
            }

            try {
                return dateFormat.parse(value.toString());
            } catch (ParseException e) {
                throw new IllegalStateException("Unable to parse date/time value: " + value);
            }
        }
    }
    return value;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:32,代码来源:SalesforceDataSet.java

示例7: getExpectedColumnType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
@Override
public ColumnType getExpectedColumnType(ColumnType type) {
    if (type.isNumber()) {
        return type;
    }
    return ColumnType.NUMBER;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:8,代码来源:ToNumberFunction.java

示例8: detectType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
private ColumnType detectType() {
    if (_columnTypes.isEmpty()) {
        return ColumnType.OTHER;
    }

    if (_columnTypes.size() == 1) {
        return _columnTypes.iterator().next();
    }

    boolean allStrings = true;
    boolean allNumbers = true;

    for (ColumnType type : _columnTypes) {
        if (allStrings && !type.isLiteral()) {
            allStrings = false;
        } else if (allNumbers && !type.isNumber()) {
            allNumbers = false;
        }
    }

    if (allStrings) {
        return ColumnType.STRING;
    }

    if (allNumbers) {
        return ColumnType.NUMBER;
    }

    return ColumnType.OTHER;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:31,代码来源:InferentialColumnBuilder.java

示例9: isNumber

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
private static boolean isNumber(ColumnType columnType, Object operand) {
    if (columnType == null) {
        return operand instanceof Number;
    }
    return columnType.isNumber();
}
 
开发者ID:apache,项目名称:metamodel,代码行数:7,代码来源:FormatHelper.java


注:本文中的org.apache.metamodel.schema.ColumnType.isNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。