本文整理汇总了Java中com.healthmarketscience.jackcess.Table.getColumns方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getColumns方法的具体用法?Java Table.getColumns怎么用?Java Table.getColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Table
的用法示例。
在下文中一共展示了Table.getColumns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImportFromFileWithOnlyHeaders
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
public void testImportFromFileWithOnlyHeaders() throws Exception
{
for (final FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
String tableName = new ImportUtil.Builder(db, "test")
.setDelimiter("\\t")
.importFile(new File("src/test/data/sample-input-only-headers.tab"));
Table t = db.getTable(tableName);
List<String> colNames = new ArrayList<String>();
for(Column c : t.getColumns()) {
colNames.add(c.getName());
}
assertEquals(Arrays.asList(
"RESULT_PHYS_ID", "FIRST", "MIDDLE", "LAST", "OUTLIER",
"RANK", "CLAIM_COUNT", "PROCEDURE_COUNT",
"WEIGHTED_CLAIM_COUNT", "WEIGHTED_PROCEDURE_COUNT"),
colNames);
db.close();
}
}
示例2: escapeIdentifiers
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private LinkedHashMap<String, Object> escapeIdentifiers(
LinkedHashMap<String, Object> map, Table t) {
List<? extends Column> colums = t.getColumns();
LinkedHashMap<String, Object> vl = new LinkedHashMap<String, Object>();
for (Column cl : colums) {
String key = cl.getName();
String ekey=SQLConverter.escapeIdentifier(key)
.toUpperCase();
if( !map.containsKey(ekey)&&
map.containsKey(ekey.substring(1, ekey.length()-1))){
ekey=ekey.substring(1, ekey.length()-1);
}
vl.put(key, map.get(ekey));
}
return vl;
}
示例3: saveColumnsDefaults
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private void saveColumnsDefaults(String[] defaults,Boolean[] required,Table table) throws IOException{
List<? extends Column> cols=table.getColumns();
int j=0;
if(defaults!=null||required!=null)
for(Column cl:cols){
PropertyMap map=cl.getProperties();
if(defaults!=null&&defaults[j]!=null){
map.put(PropertyMap.DEFAULT_VALUE_PROP,DataType.TEXT,defaults[j]);
}
if(required!=null&&required[j]!=null &&required[j]){
map.put(PropertyMap.REQUIRED_PROP,DataType.BOOLEAN,required[j]);
}
map.save();
j++;
}
}
示例4: loadData
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
@Override
public void loadData(List<Tuple<String, File>> files, Importer importer) throws InvalidFileException, IOException {
Database database = DatabaseBuilder.open(files.get(0).getRight());
for (String tableName : database.getTableNames()) {
importer.startCollection(tableName);
Table table = database.getTable(tableName);
List<? extends Column> columns = table.getColumns();
for (int i = 0; i < columns.size(); i++) {
importer.registerPropertyName(i, columns.get(i).getName());
}
for (Row row : table) {
importer.startEntity();
for (int colNum = 0 ; colNum < columns.size(); colNum++) {
Object cellValue = row.get(columns.get(colNum).getName());
if (cellValue == null) {
cellValue = "";
}
importer.setValue(colNum, "" + cellValue);
}
importer.finishEntity();
}
importer.finishCollection();
}
}
示例5: debugTable
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private static void debugTable(Table table, SequenceWriter columnCsv) throws IOException {
System.out.println("\tTable columns for " + table.getName());
try {
for (Column nextColumn : table.getColumns()) {
System.out.println("\t\t" + nextColumn.getName());
columnCsv.write(Arrays.asList(table.getName() + "." + nextColumn.getName(),
table.getName() + "." + nextColumn.getName(), "", ""));
}
Index primaryKeyIndex = table.getPrimaryKeyIndex();
System.out.println(
"\tFound primary key index for table: " + table.getName() + " named " + primaryKeyIndex.getName());
debugIndex(primaryKeyIndex, new HashSet<>(), columnCsv);
for (Index nextIndex : table.getIndexes()) {
if (!nextIndex.getName().equals(primaryKeyIndex.getName())) {
System.out.println("\tFound non-primary key index for table: " + table.getName() + " named "
+ nextIndex.getName());
debugIndex(nextIndex, new HashSet<>(), null);
}
}
} catch (IllegalArgumentException e) {
System.out.println("No primary key index found for table: " + table.getName());
}
Cursor cursor = table.getDefaultCursor();
int i = 0;
while (cursor.moveToNextRow()) {
if (i >= 5) {
break;
}
System.out.println(cursor.getCurrentRow().toString());
i++;
}
}
示例6: diffFlatColumns
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
protected static void diffFlatColumns(Table typeObjTable,
Table flatTable,
List<Column> typeCols,
List<Column> otherCols)
{
// each "flat"" table has the columns from the "type" table, plus some
// others. separate the "flat" columns into these 2 buckets
for(Column col : flatTable.getColumns()) {
if(((TableImpl)typeObjTable).hasColumn(col.getName())) {
typeCols.add(col);
} else {
otherCols.add(col);
}
}
}
示例7: isMultiValueColumn
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
public static boolean isMultiValueColumn(Table typeObjTable) {
// if we found a single value of a "simple" type, then we are dealing with
// a multi-value column
List<? extends Column> typeCols = typeObjTable.getColumns();
return ((typeCols.size() == 1) &&
MULTI_VALUE_TYPES.contains(typeCols.get(0).getType()));
}
示例8: isVersionHistoryColumn
import com.healthmarketscience.jackcess.Table; //导入方法依赖的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));
}
示例9: insertIntoTable
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
@Override
public String insertIntoTable(Table table) {
final StringBuilder stmtBuilder = new StringBuilder();
stmtBuilder.append("INSERT INTO ");
stmtBuilder.append(createStringConstant(table.getName()));
stmtBuilder.append(" (");
final List<? extends Column> columns = table.getColumns();
for (Iterator<? extends Column> iterator = columns.iterator(); iterator.hasNext(); ) {
Column column = iterator.next();
stmtBuilder.append(createStringConstant(column.getName()));
if (iterator.hasNext()) {
stmtBuilder.append(", ");
}
}
stmtBuilder.append(") VALUES (");
for (Iterator<? extends Column> iterator = columns.iterator(); iterator.hasNext(); ) {
iterator.next();
stmtBuilder.append("?");
if (iterator.hasNext()) {
stmtBuilder.append(", ");
}
}
stmtBuilder.append(")");
return stmtBuilder.toString();
}
示例10: toTuple
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private ValueTuple toTuple(Table table, Row row) {
Value[] rowData = new Value[table.getColumnCount()];
int columnIndex = 0;
for (Column column: table.getColumns()) {
String columnName = column.getName();
Object value = row.get(columnName);
rowData[columnIndex++] = ValueCharacter.select(generator, (value == null) ? "" : value.toString());
}
return new ValueTuple(generator, rowData);
}
示例11: AutoNumberAction
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
public AutoNumberAction(Table table, Object[] memento,Object[] byAccess) throws SQLException {
super();
this.table = table;
int i = 0;
PreparedStatement ps = null;
for (Column cl : table.getColumns()) {
if (cl.isAutoNumber()) {
UcanaccessConnection conn = UcanaccessConnection
.getCtxConnection();
Connection connHsqldb = conn.getHSQLDBConnection();
String cn = SQLConverter.escapeIdentifier(cl.getName());
Object cnOld = memento[i];
Object cnNew = byAccess[i];
oldAutoValues.put(cl.getName(), cnOld);
newAutoValues.put(cl.getName(), cnNew);
try {
conn.setFeedbackState(true);
String stmt = "UPDATE "
+ SQLConverter.escapeIdentifier(table.getName())
+ " SET " + cn + "=? WHERE " + cn + "=?";
ps = connHsqldb.prepareStatement(stmt);
ps.setObject(1, cnNew);
ps.setObject(2, cnOld);
ps.executeUpdate();
UcanaccessConnection.getCtxConnection()
.setFeedbackState(false);
} finally {
if (ps != null)
ps.close();
}
}
++i;
}
}
示例12: UpdateCommand
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
public UpdateCommand(Table table, Map<String, Object> map, Object[] modifiedRow,
String execId) {
super();
this.tableColumns = table.getColumns();
this.indexSelector = new IndexSelector(table);
this.rowPattern = map;
this.modifiedRow = modifiedRow;
this.execId = execId;
checkBlob(modifiedRow);
this.table=table;
}
示例13: createSyncrTable
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private void createSyncrTable(Table t,boolean systemTable) throws SQLException, IOException {
String tn = t.getName();
String ntn =schema( SQLConverter.escapeIdentifier(tn),systemTable);
StringBuffer sbC = new StringBuffer("CREATE CACHED TABLE ").append(
ntn).append("(");
List<? extends Column> lc = t.getColumns();
String comma = "";
ArrayList<String> arTrigger = new ArrayList<String>();
for (Column cl : lc) {
String htype = cl.getType().equals(DataType.TEXT) ? "VARCHAR("
+ cl.getLengthInUnits() + ")" : TypesMap.map2hsqldb(cl
.getType());
sbC.append(comma)
.append(SQLConverter.escapeIdentifier(cl.getName()))
.append(" ").append(htype);
PropertyMap pm = cl.getProperties();
Object required = pm.getValue(PropertyMap.REQUIRED_PROP);
if (required != null && ((Boolean) required)) {
sbC.append(" NOT NULL ");
}
comma = ",";
}
sbC.append(")");
execCreate(sbC.toString(),true);
for (String trigger : arTrigger) {
execCreate(trigger,true);
}
}
示例14: hasAppendOnly
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private boolean hasAppendOnly(Table t) {
for (Column c:t.getColumns()){
if(c.isAppendOnly()){
return true;
}
}
return false;
}
示例15: hasAutoNumberColumn
import com.healthmarketscience.jackcess.Table; //导入方法依赖的package包/类
private static boolean hasAutoNumberColumn(Table t) {
List<? extends Column> lc = t.getColumns();
for (Column cl : lc) {
if (cl.isAutoNumber()) {
return true;
}
}
return false;
}