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


Java ColumnType.BIT属性代码示例

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


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

示例1: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.BLOB) {
        return "bytea";
    }
    if (columnType == ColumnType.BIT) {
        return "BOOLEAN";
    }
    if (columnType == ColumnType.DOUBLE) {
        return "double precision";
    }
    if (columnType == ColumnType.MAP) {
        return "jsonb";
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:16,代码来源:PostgresqlQueryRewriter.java

示例2: testEqualsAndHashCode

/**
 * Tests that the following (general) rules apply to the object:
 * <p/>
 * <li>the hashcode is the same when run twice on an unaltered object</li>
 * <li>if o1.equals(o2) then this condition must be true: o1.hashCode() ==
 * 02.hashCode()
 */
public void testEqualsAndHashCode() throws Exception {
    Column col1 = new MutableColumn("Col1", ColumnType.BIT);

    FilterItem c1 = new FilterItem(new SelectItem(col1), OperatorType.EQUALS_TO, true);
    FilterItem c2 = new FilterItem(new SelectItem(col1), OperatorType.EQUALS_TO, true);
    assertEquals(c1, c2);
    assertEquals(c1.hashCode(), c2.hashCode());

    c2 = new FilterItem(new SelectItem(col1), OperatorType.GREATER_THAN, true);
    assertFalse(c1.equals(c2));
    assertFalse(c1.hashCode() == c2.hashCode());

    Column col2 = new MutableColumn("Col2", ColumnType.VARBINARY);
    c2 = new FilterItem(new SelectItem(col2), OperatorType.EQUALS_TO, true);
    assertFalse(c1.equals(c2));
    assertFalse(c1.hashCode() == c2.hashCode());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:24,代码来源:FilterItemTest.java

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

示例4: rewriteColumnType

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

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

示例6: formatSqlBoolean

public static String formatSqlBoolean(ColumnType columnType, boolean b) {
    if (columnType == ColumnType.BIT) {
        if (b) {
            return "1";
        } else {
            return "0";
        }
    } else {
        if (b) {
            return "TRUE";
        } else {
            return "FALSE";
        }
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:15,代码来源:FormatHelper.java

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