本文整理汇总了Java中com.healthmarketscience.jackcess.Column.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Column.getType方法的具体用法?Java Column.getType怎么用?Java Column.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Column
的用法示例。
在下文中一共展示了Column.getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VersionHistoryColumnInfoImpl
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
public VersionHistoryColumnInfoImpl(Column column, int complexId,
Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
Column valueCol = null;
Column modifiedCol = null;
for(Column col : getTypeColumns()) {
switch(col.getType()) {
case SHORT_DATE_TIME:
modifiedCol = col;
break;
case MEMO:
valueCol = col;
break;
default:
// ignore
}
}
_valueCol = valueCol;
_modifiedCol = modifiedCol;
}
示例2: ComplexColumnInfoImpl
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
protected ComplexColumnInfoImpl(Column column, int complexTypeId,
Table typeObjTable, Table flatTable)
throws IOException
{
_column = column;
_complexTypeId = complexTypeId;
_flatTable = flatTable;
// the flat table has all the "value" columns and 2 extra columns, a
// primary key for each row, and a LONG value which is essentially a
// foreign key to the main table.
List<Column> typeCols = new ArrayList<Column>();
List<Column> otherCols = new ArrayList<Column>();
diffFlatColumns(typeObjTable, flatTable, typeCols, otherCols);
_typeCols = Collections.unmodifiableList(typeCols);
Column pkCol = null;
Column complexValFkCol = null;
for(Column col : otherCols) {
if(col.isAutoNumber()) {
pkCol = col;
} else if(col.getType() == DataType.LONG) {
complexValFkCol = col;
}
}
if((pkCol == null) || (complexValFkCol == null)) {
throw new IOException("Could not find expected columns in flat table " +
flatTable.getName() + " for complex column with id "
+ complexTypeId);
}
_pkCol = pkCol;
_complexValFkCol = complexValFkCol;
}
示例3: isVersionHistoryColumn
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
public static boolean isVersionHistoryColumn(Table typeObjTable) {
// version history data has these columns <value>(MEMO),
// <modified>(SHORT_DATE_TIME)
List<? extends Column> typeCols = typeObjTable.getColumns();
if(typeCols.size() < 2) {
return false;
}
int numMemo = 0;
int numDate = 0;
for(Column col : typeCols) {
switch(col.getType()) {
case SHORT_DATE_TIME:
++numDate;
break;
case MEMO:
++numMemo;
break;
default:
// ignore
}
}
// be flexible, allow for extra columns...
return((numMemo >= 1) && (numDate >= 1));
}
示例4: mapDatatype
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
/**
* Maps the type of the given column to an SQLite datatype.
*
* @param column the column
* @return an SQLite datatype
* @see <a href="https://www.sqlite.org/datatype3.html">Datatypes in SQLite</a>
*/
private String mapDatatype(Column column) {
switch (column.getType()) {
/* Blob */
case BINARY:
case OLE:
return "BLOB";
/* Integers */
case BOOLEAN:
case BYTE:
case INT:
case LONG:
case MONEY:
/* SQLite does not have a dedicated type for storing timestamps and the
* default behaviour of the driver is to store the date as Unix Time */
case SHORT_DATE_TIME:
return "INTEGER";
/* Floating point */
case DOUBLE:
case FLOAT:
case NUMERIC:
return "REAL";
/* Strings */
case TEXT:
case GUID:
case MEMO:
return "TEXT";
default:
throw new IllegalArgumentException("Unsupported data type: " + column.getType());
}
}
示例5: createTable
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
/**
* Create an SQLite table for the corresponding MS Access table.
*
* @param table MS Access table
* @param jdbc The SQLite database JDBC connection
* @throws SQLException
*/
private void createTable (final Table table, final Connection jdbc) throws SQLException {
final List<Column> columns = table.getColumns();
final StringBuilder stmtBuilder = new StringBuilder();
/* Create the statement */
stmtBuilder.append("CREATE TABLE " + escapeIdentifier(table.getName()) + " (");
final int columnCount = columns.size();
for (int i = 0; i < columnCount; i++) {
final Column column = columns.get(i);
stmtBuilder.append(escapeIdentifier(column.getName()));
stmtBuilder.append(" ");
switch (column.getType()) {
/* Blob */
case BINARY:
case OLE:
stmtBuilder.append("BLOB");
break;
/* Integers */
case BOOLEAN:
case BYTE:
case INT:
case LONG:
stmtBuilder.append("INTEGER");
break;
/* Timestamp */
case SHORT_DATE_TIME:
stmtBuilder.append("DATETIME");
break;
/* Floating point */
case DOUBLE:
case FLOAT:
case NUMERIC:
stmtBuilder.append("DOUBLE");
break;
/* Strings */
case TEXT:
case GUID:
case MEMO:
stmtBuilder.append("TEXT");
break;
/* Money -- This can't be floating point, so let's be safe with strings */
case MONEY:
stmtBuilder.append("TEXT");
break;
default:
throw new SQLException("Unhandled MS Acess datatype: " + column.getType());
}
if (i + 1 < columnCount)
stmtBuilder.append(", ");
}
stmtBuilder.append(")");
/* Execute it */
final Statement stmt = jdbc.createStatement();
stmt.execute(stmtBuilder.toString());
}
示例6: AttachmentColumnInfoImpl
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
public AttachmentColumnInfoImpl(Column column, int complexId,
Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
Column fileUrlCol = null;
Column fileNameCol = null;
Column fileTypeCol = null;
Column fileDataCol = null;
Column fileTimeStampCol = null;
Column fileFlagsCol = null;
for(Column col : getTypeColumns()) {
switch(col.getType()) {
case TEXT:
if(FILE_NAME_COL_NAME.equalsIgnoreCase(col.getName())) {
fileNameCol = col;
} else if(FILE_TYPE_COL_NAME.equalsIgnoreCase(col.getName())) {
fileTypeCol = col;
} else {
// if names don't match, assign in order: name, type
if(fileNameCol == null) {
fileNameCol = col;
} else if(fileTypeCol == null) {
fileTypeCol = col;
}
}
break;
case LONG:
fileFlagsCol = col;
break;
case SHORT_DATE_TIME:
fileTimeStampCol = col;
break;
case OLE:
fileDataCol = col;
break;
case MEMO:
fileUrlCol = col;
break;
default:
// ignore
}
}
_fileUrlCol = fileUrlCol;
_fileNameCol = fileNameCol;
_fileTypeCol = fileTypeCol;
_fileDataCol = fileDataCol;
_fileTimeStampCol = fileTimeStampCol;
_fileFlagsCol = fileFlagsCol;
}
示例7: isAttachmentColumn
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
public static boolean isAttachmentColumn(Table typeObjTable) {
// attachment data has these columns FileURL(MEMO), FileName(TEXT),
// FileType(TEXT), FileData(OLE), FileTimeStamp(SHORT_DATE_TIME),
// FileFlags(LONG)
List<? extends Column> typeCols = typeObjTable.getColumns();
if(typeCols.size() < 6) {
return false;
}
int numMemo = 0;
int numText = 0;
int numDate = 0;
int numOle= 0;
int numLong = 0;
for(Column col : typeCols) {
switch(col.getType()) {
case TEXT:
++numText;
break;
case LONG:
++numLong;
break;
case SHORT_DATE_TIME:
++numDate;
break;
case OLE:
++numOle;
break;
case MEMO:
++numMemo;
break;
default:
// ignore
}
}
// be flexible, allow for extra columns...
return((numMemo >= 1) && (numText >= 2) && (numOle >= 1) &&
(numDate >= 1) && (numLong >= 1));
}
示例8: createTableStatement
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
/**
* Create an SQLite table for the corresponding MS Access table.
*
* @param table MS Access table
* @throws SQLException
*/
@SuppressWarnings("unchecked")
private static String createTableStatement(Table table) throws SQLException {
List<String> columns = new ArrayList<String>();
for (Column column : (List<Column>) table.getColumns()) {
switch (column.getType()) {
// Blob
case BINARY:
case OLE:
columns.add(String.format("%s BLOB", MDB2SQLite.escape(column.getName())));
break;
// Integers
case BOOLEAN:
case BYTE:
case INT:
case LONG:
columns.add(String.format("%s INTEGER", MDB2SQLite.escape(column.getName())));
break;
// Floating point
case DOUBLE:
case FLOAT:
case NUMERIC:
columns.add(String.format("%s REAL", MDB2SQLite.escape(column.getName())));
break;
// TEXT
case TEXT:
case GUID:
case MEMO:
case MONEY:
case SHORT_DATE_TIME:
columns.add(String.format("%s TEXT", MDB2SQLite.escape(column.getName())));
break;
default:
throw new SQLException("Unhandled MS Acess datatype: " + column.getType());
}
}
String result = columns.stream().collect(Collectors.joining(", "));
return String.format("CREATE TABLE %s (%s)", MDB2SQLite.escape(table.getName()), result);
}
示例9: populateTable
import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
/**
* Populate the SQLite table
*
* @param sqlite
* @param mdbTable
* @throws SQLException
* @throws SqlJetException
*/
@SuppressWarnings("unchecked")
private static void populateTable(SqlJetDb sqlite, Table mdbTable) throws SQLException, SqlJetException {
List<Column> columns = (List<Column>) mdbTable.getColumns();
sqlite.beginTransaction(SqlJetTransactionMode.WRITE);
try {
ISqlJetTable table = sqlite.getTable(mdbTable.getName());
// Bind all the column values
for (Map<String, Object> row : mdbTable) {
List<Object> values = new ArrayList<Object>();
for (Column column : columns) {
Object value = row.get(column.getName());
// If null, just bail out early and avoid a lot of NULL checking
if (value == null) {
values.add(value);
continue;
}
// Perform any conversions
switch (column.getType()) {
case MONEY: // Store money as a string.
values.add(value.toString());
break;
case BOOLEAN: // SQLite has no booleans
values.add(((Boolean) value).booleanValue() ? "1" : 0);
break;
default:
values.add(value);
break;
}
}
table.insert(values.toArray());
}
} finally {
sqlite.commit();
}
}