本文整理汇总了Java中org.apache.metamodel.schema.ColumnType.BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java ColumnType.BOOLEAN属性的具体用法?Java ColumnType.BOOLEAN怎么用?Java ColumnType.BOOLEAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.metamodel.schema.ColumnType
的用法示例。
在下文中一共展示了ColumnType.BOOLEAN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnType
private ColumnType getColumnType(ValueMetaInterface valueMeta) {
switch (valueMeta.getType()) {
case ValueMetaInterface.TYPE_STRING:
return ColumnType.VARCHAR;
case ValueMetaInterface.TYPE_INTEGER:
return ColumnType.INTEGER;
case ValueMetaInterface.TYPE_DATE:
return ColumnType.DATE;
case ValueMetaInterface.TYPE_BOOLEAN:
return ColumnType.BOOLEAN;
case ValueMetaInterface.TYPE_NUMBER:
return ColumnType.DOUBLE;
case ValueMetaInterface.TYPE_BINARY:
return ColumnType.BINARY;
case ValueMetaInterface.TYPE_BIGNUMBER:
return ColumnType.DECIMAL;
}
throw new RuntimeException("It is currently not possible to profile values of type: " + valueMeta.getTypeDesc());
}
示例2: getColumnTypeFromElasticSearchType
public static ColumnType getColumnTypeFromElasticSearchType(final String metaDataFieldType) {
final ColumnType columnType;
if (metaDataFieldType.startsWith("date")) {
columnType = ColumnType.DATE;
} else if (metaDataFieldType.equals("long")) {
columnType = ColumnType.BIGINT;
} else if (metaDataFieldType.equals("string")) {
columnType = ColumnType.STRING;
} else if (metaDataFieldType.equals("float")) {
columnType = ColumnType.FLOAT;
} else if (metaDataFieldType.equals("boolean")) {
columnType = ColumnType.BOOLEAN;
} else if (metaDataFieldType.equals("double")) {
columnType = ColumnType.DOUBLE;
} else {
columnType = ColumnType.STRING;
}
return columnType;
}
示例3: convertType
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;
}
示例4: shouldReturnBooleanForBooleanColumn
@Test
public void shouldReturnBooleanForBooleanColumn() {
final Column booleanColumn = new MutableColumn("foo", ColumnType.BOOLEAN);
Object result = TypeConverter.convertType(true, booleanColumn);
assertTrue(result instanceof Boolean);
assertEquals(true, result);
result = TypeConverter.convertType(false, booleanColumn);
assertTrue(result instanceof Boolean);
assertEquals(false, result);
}
示例5: convertType
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;
}
示例6: testScenarioWithMap
public void testScenarioWithMap() throws Exception {
final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "col1", "col2", "col3" },
new ColumnType[] { ColumnType.VARCHAR, ColumnType.INTEGER, ColumnType.BOOLEAN });
final List<Map<String, ?>> maps = new ArrayList<Map<String, ?>>();
maps.add(createMap("2", 1000, true));
maps.add(createMap("1", 1001, false));
maps.add(createMap("1", 1002, true));
maps.add(createMap("2", 1003, false));
maps.add(createMap("2", 1004, false));
final TableDataProvider<?> tableDataProvider = new MapTableDataProvider(tableDef, maps);
runScenario(tableDataProvider);
}
示例7: testScenarioWithArrays
public void testScenarioWithArrays() throws Exception {
final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "col1", "col2", "col3" },
new ColumnType[] { ColumnType.VARCHAR, ColumnType.INTEGER, ColumnType.BOOLEAN });
final List<Object[]> arrays = new ArrayList<Object[]>();
arrays.add(new Object[] { "2", 1000, true });
arrays.add(new Object[] { "1", 1001, false });
arrays.add(new Object[] { "1", 1002, true });
arrays.add(new Object[] { "2", 1003, false });
arrays.add(new Object[] { "2", 1004, false });
final TableDataProvider<?> tableDataProvider = new ArrayTableDataProvider(tableDef, arrays);
runScenario(tableDataProvider);
}
示例8: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.DOUBLE) {
return "FLOAT";
}
if (columnType == ColumnType.BOOLEAN) {
return "BIT";
}
if (columnType.isLiteral() && columnSize == null) {
// SQL server provides the convenient MAX parameter. If not
// specified, the default size of e.g. a VARCHAR is 1!
return rewriteColumnTypeInternal(columnType.getName(), "MAX");
}
return super.rewriteColumnType(columnType, columnSize);
}
示例9: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.BOOLEAN || columnType == ColumnType.BIT) {
return "SMALLINT";
}
return super.rewriteColumnType(columnType, columnSize);
}
示例10: getColumnType
@Override
public ColumnType getColumnType(int jdbcType, String nativeType, Integer columnSize) {
switch (nativeType) {
case "bool":
// override the normal behaviour of postgresql which maps "bool" to
// a BIT.
return ColumnType.BOOLEAN;
case "json":
case "jsonb":
return ColumnType.MAP;
}
return super.getColumnType(jdbcType, nativeType, columnSize);
}
示例11: getType
/**
* Determines the best fitting type. For reference of ElasticSearch types,
* see
*
* <pre>
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html
* </pre>
*
*
* @param column
* @return
*/
private static String getType(Column column) {
String nativeType = column.getNativeType();
if (!Strings.isNullOrEmpty(nativeType)) {
return nativeType;
}
final ColumnType type = column.getType();
if (type == null) {
throw new IllegalStateException("No column type specified for '" + column.getName()
+ "' - cannot build ElasticSearch mapping without type.");
}
if (type.isLiteral()) {
return "text";
} else if (type == ColumnType.FLOAT) {
return "float";
} else if (type == ColumnType.DOUBLE || type == ColumnType.NUMERIC || type == ColumnType.NUMBER) {
return "double";
} else if (type == ColumnType.SMALLINT) {
return "short";
} else if (type == ColumnType.TINYINT) {
return "byte";
} else if (type == ColumnType.INTEGER) {
return "integer";
} else if (type == ColumnType.DATE || type == ColumnType.TIMESTAMP) {
return "date";
} else if (type == ColumnType.BINARY || type == ColumnType.VARBINARY) {
return "binary";
} else if (type == ColumnType.BOOLEAN || type == ColumnType.BIT) {
return "boolean";
} else if (type == ColumnType.MAP) {
return "object";
}
throw new UnsupportedOperationException("Unsupported column type '" + type.getName() + "' of column '" + column
.getName() + "' - cannot translate to an ElasticSearch type.");
}
示例12: toColumnType
protected static ColumnType toColumnType(FieldType type) {
switch (type) {
case _boolean:
return ColumnType.BOOLEAN;
case _int:
return ColumnType.INTEGER;
case _double:
case currency:
return ColumnType.DOUBLE;
case date:
return ColumnType.DATE;
case datetime:
return ColumnType.TIMESTAMP;
case time:
return ColumnType.TIME;
case string:
case email:
case url:
case phone:
case reference:
case textarea:
case encryptedstring:
case base64:
case id:
case picklist:
return ColumnType.VARCHAR;
default:
return ColumnType.OTHER;
}
}
示例13: getExpectedColumnType
@Override
public ColumnType getExpectedColumnType(ColumnType type) {
if (type.isBoolean()) {
return type;
}
return ColumnType.BOOLEAN;
}
示例14: getAvailableColumnTypes
private ColumnType[] getAvailableColumnTypes() {
return new ColumnType[] { ColumnType.VARCHAR, ColumnType.DECIMAL, ColumnType.INTEGER, ColumnType.BOOLEAN,
ColumnType.DATE, ColumnType.TIME, ColumnType.TIMESTAMP, ColumnType.MAP, ColumnType.LIST,
ColumnType.BINARY };
}
示例15: shouldThrowForIntegerAndBooleanColumn
@Test(expected = IllegalArgumentException.class)
public void shouldThrowForIntegerAndBooleanColumn() {
final Column booleanColumn = new MutableColumn("foo", ColumnType.BOOLEAN);
TypeConverter.convertType(42, booleanColumn);
}