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


Java ColumnType.NUMBER属性代码示例

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


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

示例1: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.STRING) {
        // convert STRING to VARCHAR as the default SQL type for strings
        return rewriteColumnType(ColumnType.VARCHAR, columnSize);
    }
    if (columnType == ColumnType.NUMBER) {
        // convert NUMBER to FLOAT as the default SQL type for numbers
        return rewriteColumnType(ColumnType.FLOAT, columnSize);
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:DefaultQueryRewriter.java

示例2: toColumnType

public static ColumnType toColumnType(String attributeName, String attributeType) {
    if (attributeType == null) {
        return null;
    }
    switch (attributeType) {
    case "S":
        return ColumnType.STRING;
    case "N":
        return ColumnType.NUMBER;
    case "B":
        return ColumnType.BINARY;
    }
    logger.warn("Unexpected attribute type '{}' for attribute: {}", attributeType, attributeName);
    return null;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:15,代码来源:DynamoDbUtils.java

示例3: 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

示例4: getExpectedColumnType

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

示例5: detectType

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,代码行数:30,代码来源:InferentialColumnBuilder.java

示例6: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.NUMBER || columnType == ColumnType.NUMERIC || columnType == ColumnType.DECIMAL) {
        // as one of the only relational databases out there, Oracle has a
        // NUMBER type. For this reason NUMBER would be replaced by the
        // super-type's logic, but we handle it specifically here.
        super.rewriteColumnTypeInternal("NUMBER", columnSize);
    }
    if (columnType == ColumnType.BOOLEAN || columnType == ColumnType.BIT) {
        // Oracle has no boolean type, but recommends NUMBER(3) or CHAR(1).
        // For consistency with most other databases who have either a
        // boolean or a bit, we use the number variant because it's return
        // values (0 or 1) can be converted the most easily back to a
        // boolean.
        return "NUMBER(3)";
    }
    if (columnType == ColumnType.DOUBLE) {
        return "BINARY_DOUBLE";
    }
    if (columnType == ColumnType.FLOAT) {
        return "BINARY_FLOAT";
    }
    if (columnType == ColumnType.BINARY || columnType == ColumnType.VARBINARY) {
        return "RAW";
    }

    // following conversions based on
    // http://docs.oracle.com/cd/B19306_01/gateways.102/b14270/apa.htm
    if (columnType == ColumnType.TINYINT) {
        return "NUMBER(3)";
    }
    if (columnType == ColumnType.SMALLINT) {
        return "NUMBER(5)";
    }
    if (columnType == ColumnType.INTEGER) {
        return "NUMBER(10)";
    }
    if (columnType == ColumnType.BIGINT) {
        return "NUMBER(19)";
    }

    // Oracle has no "time only" data type but 'date' also includes time
    if (columnType == ColumnType.TIME) {
        super.rewriteColumnType(ColumnType.DATE, columnSize);
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:47,代码来源:OracleQueryRewriter.java


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