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


Java ColumnType.BOOLEAN属性代码示例

本文整理汇总了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());
}
 
开发者ID:datacleaner,项目名称:pdi-datacleaner,代码行数:19,代码来源:KettleDataContext.java

示例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;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:19,代码来源:ElasticSearchUtils.java

示例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;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:28,代码来源:TypeConverter.java

示例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);

}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:13,代码来源:TypeConverterTest.java

示例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;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:28,代码来源:InsertIntoTableAnalyzer.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:PojoDataContextTest.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:PojoDataContextTest.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:15,代码来源:SQLServerQueryRewriter.java

示例9: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.BOOLEAN || columnType == ColumnType.BIT) {
        return "SMALLINT";
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:7,代码来源:DB2QueryRewriter.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:13,代码来源:PostgresqlQueryRewriter.java

示例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.");
}
 
开发者ID:apache,项目名称:metamodel,代码行数:49,代码来源:ElasticSearchUtils.java

示例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;
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:30,代码来源:SalesforceTable.java

示例13: getExpectedColumnType

@Override
public ColumnType getExpectedColumnType(ColumnType type) {
    if (type.isBoolean()) {
        return type;
    }
    return ColumnType.BOOLEAN;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:7,代码来源:ToBooleanFunction.java

示例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 };
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:5,代码来源:SimpleTableDefPanel.java

示例15: shouldThrowForIntegerAndBooleanColumn

@Test(expected = IllegalArgumentException.class)
public void shouldThrowForIntegerAndBooleanColumn() {
    final Column booleanColumn = new MutableColumn("foo", ColumnType.BOOLEAN);
    TypeConverter.convertType(42, booleanColumn);

}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:6,代码来源:TypeConverterTest.java


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