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


Java ColumnType.isLiteral方法代码示例

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


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

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

示例4: rewriteColumnType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
@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,代码行数:16,代码来源:SQLServerQueryRewriter.java

示例5: rewriteColumnType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.NUMERIC) {
        return super.rewriteColumnType(ColumnType.DECIMAL, columnSize);
    }
    if (columnType.isLiteral() && columnSize == null) {
        if (columnType == ColumnType.STRING || columnType == ColumnType.VARCHAR
                || columnType == ColumnType.NVARCHAR) {
            // MySQL requires size to be specified, so instead we choose the
            // text type
            return "TEXT";
        }
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:16,代码来源:MysqlQueryRewriter.java

示例6: getValueAsSql

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
public static String getValueAsSql(Column column, Object value, IQueryRewriter queryRewriter) {
    if (value == null) {
        return "NULL";
    }
    final ColumnType columnType = column.getType();
    if (columnType.isLiteral() && value instanceof String) {
        value = queryRewriter.escapeQuotes((String) value);
    }
    final String formatSqlValue = FormatHelper.formatSqlValue(columnType, value);
    return formatSqlValue;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:JdbcUtils.java

示例7: getType

import org.apache.metamodel.schema.ColumnType; //导入方法依赖的package包/类
/**
 * 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,代码行数:50,代码来源:ElasticSearchUtils.java

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

示例9: getExpectedColumnType

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

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

示例11: isLiteral

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


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