• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Table类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.healthmarketscience.jackcess.Table的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: createUniqueTable

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
/**
 * Returns a new table with a unique name and the given table definition.
 */
private static Table createUniqueTable(Database db, String name,
                                       List<ColumnBuilder> columns,
                                       ResultSetMetaData md, 
                                       ImportFilter filter)
  throws IOException, SQLException
{
  // otherwise, find unique name and create new table
  String baseName = name;
  int counter = 2;
  while(db.getTable(name) != null) {
    name = baseName + (counter++);
  }
  
  return new TableBuilder(name)
    .addColumns(filter.filterColumns(columns, md))
    .toTable(db);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:21,代码来源:ImportUtil.java


示例2: 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();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:24,代码来源:ImportTest.java


示例3: matches

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public boolean matches(Table table, String columnName, Object value1,
                       Object value2)
{
  if(equals(value1, value2)) {
    return true;
  }

  if((value1 != null) && (value2 != null) && 
     (value1.getClass() != value2.getClass())) {

    // the values aren't the same type, try coercing them to "internal"
    // values and try again
    DataType dataType = table.getColumn(columnName).getType();
    try {
      Object internalV1 = ColumnImpl.toInternalValue(dataType, value1);
      Object internalV2 = ColumnImpl.toInternalValue(dataType, value2);
      
      return equals(internalV1, internalV2);
    } catch(IOException e) {
      // ignored, just go with the original result
    }
  }
  return false;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:25,代码来源:SimpleColumnMatcher.java


示例4: matches

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public boolean matches(Table table, String columnName, Object value1,
                       Object value2)
{
  if(!table.getColumn(columnName).getType().isTextual()) {
    // use simple equality
    return SimpleColumnMatcher.INSTANCE.matches(table, columnName, 
                                                value1, value2);
  }

  // convert both values to Strings and compare case-insensitively
  try {
    CharSequence cs1 = ColumnImpl.toCharSequence(value1);
    CharSequence cs2 = ColumnImpl.toCharSequence(value2);

    return((cs1 == cs2) ||
           ((cs1 != null) && (cs2 != null) &&
            cs1.toString().equalsIgnoreCase(cs2.toString())));
  } catch(IOException e) {
    throw new RuntimeIOException("Could not read column " + columnName 
                                 + " value", e);
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:23,代码来源:CaseInsensitiveColumnMatcher.java


示例5: isLinkedTable

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public boolean isLinkedTable(Table table) throws IOException {

    if((table == null) || (this == table.getDatabase())) {
      // if the table is null or this db owns the table, not linked
      return false;
    }

    // common case, local table name == remote table name
    TableInfo tableInfo = lookupTable(table.getName());
    if((tableInfo != null) && tableInfo.isLinked() &&
       matchesLinkedTable(table, ((LinkedTableInfo)tableInfo).linkedTableName,
                          ((LinkedTableInfo)tableInfo).linkedDbName)) {
      return true;
    }

    // but, the local table name may not match the remote table name, so we
    // need to do a search if the common case fails
    return _tableFinder.isLinkedTable(table);
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:20,代码来源:DatabaseImpl.java


示例6: VersionHistoryColumnInfoImpl

import com.healthmarketscience.jackcess.Table; //导入依赖的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;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:25,代码来源:VersionHistoryColumnInfoImpl.java


示例7: replaceColumn

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void replaceColumn(Table t, String colName) throws Exception
{
  Field colsField = TableImpl.class.getDeclaredField("_columns");
  colsField.setAccessible(true);
  List<Column> cols = (List<Column>)colsField.get(t);

  Column srcCol = null;
  ColumnImpl destCol = new BogusColumn(t, colName);
  for(int i = 0; i < cols.size(); ++i) {
    srcCol = cols.get(i);
    if(srcCol.getName().equals(colName)) {
      cols.set(i, destCol);
      break;
    }
  }

  // copy fields from source to dest
  for(Field f : Column.class.getDeclaredFields()) {
    if(!Modifier.isFinal(f.getModifiers())) {
      f.setAccessible(true);
      f.set(destCol, f.get(srcCol));
    }
  }
  
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:27,代码来源:ErrorHandlerTest.java


示例8: testReadCalcFields

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testReadCalcFields() throws Exception {

    for(TestDB testDB : TestDB.getSupportedForBasename(Basename.CALC_FIELD)) {
      Database db = open(testDB);
      Table t = db.getTable("Table1");

      List<String> rows = new ArrayList<String>();
      for(Row r : t) {
        rows.add(r.entrySet().toString());
      }

      List<String> expectedRows = Arrays.asList(
          "[ID=1, FirstName=Bruce, LastName=Wayne, LastFirst=Wayne, Bruce, City=Gotham, LastFirstLen=12, Salary=1000000.0000, MonthlySalary=83333.3333, IsRich=true, AllNames=Wayne, Bruce=Wayne, Bruce, WeeklySalary=19230.7692307692, SalaryTest=1000000.0000, BoolTest=true, Popularity=50.325000, DecimalTest=50.325000, FloatTest=2583.2092, BigNumTest=56505085819.424791296572280180]",
          "[ID=2, FirstName=Bart, LastName=Simpson, LastFirst=Simpson, Bart, City=Springfield, LastFirstLen=13, Salary=-1.0000, MonthlySalary=-0.0833, IsRich=false, AllNames=Simpson, Bart=Simpson, Bart, WeeklySalary=-0.0192307692307692, SalaryTest=-1.0000, BoolTest=true, Popularity=-36.222200, DecimalTest=-36.222200, FloatTest=0.0035889593, BigNumTest=-0.0784734499180612994241100748]",
          "[ID=3, FirstName=John, LastName=Doe, LastFirst=Doe, John, City=Nowhere, LastFirstLen=9, Salary=0.0000, MonthlySalary=0.0000, IsRich=false, AllNames=Doe, John=Doe, John, WeeklySalary=0, SalaryTest=0.0000, BoolTest=true, Popularity=0.012300, DecimalTest=0.012300, FloatTest=0.0, BigNumTest=0E-8]",
          "[ID=4, FirstName=Test, LastName=User, LastFirst=User, Test, City=Hockessin, LastFirstLen=10, Salary=100.0000, MonthlySalary=8.3333, IsRich=false, AllNames=User, Test=User, Test, WeeklySalary=1.92307692307692, SalaryTest=100.0000, BoolTest=true, Popularity=102030405060.654321, DecimalTest=102030405060.654321, FloatTest=1.27413E-10, BigNumTest=2.787019289824216980830E-7]");

      assertEquals(expectedRows, rows);

      db.close();
    }    
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:23,代码来源:CalcFieldTest.java


示例9: checkIndexEntries

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
private static void checkIndexEntries(final TestDB testDB, Table t, Index index) throws Exception
  {
//         index.initialize();
//         System.out.println("Ind " + index);

    Cursor cursor = CursorBuilder.createCursor(index);
    while(cursor.moveToNextRow()) {

      Row row = cursor.getCurrentRow();
      Cursor.Position curPos = cursor.getSavepoint().getCurrentPosition();
      boolean success = false;
      try {
        findRow(testDB, t, index, row, curPos);
        success = true;
      } finally {
        if(!success) {
          System.out.println("CurPos: " + curPos);
          System.out.println("Value: " + row + ": " + 
                             toUnicodeStr(row.get("data")));
        }          
      }
    }
    
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:25,代码来源:IndexCodesTest.java


示例10: x_testCreateIsoFile

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void x_testCreateIsoFile() throws Exception
{
  Database db = create(Database.FileFormat.V2000, true);

  Table t = new TableBuilder("test")
    .addColumn(new ColumnBuilder("row", DataType.TEXT))
    .addColumn(new ColumnBuilder("data", DataType.TEXT))
    .toTable(db);
  
  for(int i = 0; i < 256; ++i) {
    String str = "AA" + ((char)i) + "AA";
    t.addRow("row" + i, str);
  }

  db.close();
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:IndexCodesTest.java


示例11: x_testReadAllCodesMdb

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void x_testReadAllCodesMdb() throws Exception
  {
//     Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes.mdb"));
//     Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes_orig.mdb"));
//     Database db = openCopy(new File("/data2/jackcess_test/testSomeMoreCodes.mdb"));
    Database db = openCopy(Database.FileFormat.V2000, new File("/data2/jackcess_test/testStillMoreCodes.mdb"));
    Table t = db.getTable("Table5");

    Index ind = t.getIndexes().iterator().next();
    ((IndexImpl)ind).initialize();
    
    System.out.println("Ind " + ind);

    Cursor cursor = CursorBuilder.createCursor(ind);
    while(cursor.moveToNextRow()) {
      System.out.println("=======");
      String entryStr = 
        entryToString(cursor.getSavepoint().getCurrentPosition());
      System.out.println("Entry Bytes: " + entryStr);
      System.out.println("Value: " + cursor.getCurrentRow() + "; " +
                         toUnicodeStr(cursor.getCurrentRow().get("data")));
    }

    db.close();
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:26,代码来源:IndexCodesTest.java


示例12: addCombos

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
private int addCombos(Table t, int rowNum, String s, char[] cs, int len)
  throws Exception
{
  if(s.length() >= len) {
    return rowNum;
  }

  for(int i = 0; i < cs.length; ++i) {
    String name = "row" + (rowNum++);
    String ss = s + cs[i];
    t.addRow(name, ss);
    rowNum = addCombos(t, rowNum, ss, cs, len);
  }

  return rowNum;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:IndexCodesTest.java


示例13: x_testReadIsoMdb

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void x_testReadIsoMdb() throws Exception
  {
//     Database db = open(new File("/tmp/test_ind.mdb"));
//     Database db = open(new File("/tmp/test_ind2.mdb"));
    Database db = open(Database.FileFormat.V2000, new File("/tmp/test_ind3.mdb"));
//     Database db = open(new File("/tmp/test_ind4.mdb"));

    Table t = db.getTable("Table1");
    Index index = t.getIndex("B");
    ((IndexImpl)index).initialize();
    System.out.println("Ind " + index);

    Cursor cursor = CursorBuilder.createCursor(index);
    while(cursor.moveToNextRow()) {
      System.out.println("=======");
      System.out.println("Savepoint: " + cursor.getSavepoint());
      System.out.println("Value: " + cursor.getCurrentRow());
    }
    
    db.close();
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:22,代码来源:IndexCodesTest.java


示例14: testReadLongValue

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testReadLongValue() throws Exception {

    for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.TEST2, true)) {
      Database db = openMem(testDB);
      Table table = db.getTable("MSP_PROJECTS");
      Row row = table.getNextRow();
      assertEquals("Jon Iles this is a a vawesrasoih aksdkl fas dlkjflkasjd flkjaslkdjflkajlksj dfl lkasjdf lkjaskldfj lkas dlk lkjsjdfkl; aslkdf lkasjkldjf lka skldf lka sdkjfl;kasjd falksjdfljaslkdjf laskjdfk jalskjd flkj aslkdjflkjkjasljdflkjas jf;lkasjd fjkas dasdf asd fasdf asdf asdmhf lksaiyudfoi jasodfj902384jsdf9 aw90se fisajldkfj lkasj dlkfslkd jflksjadf as", row.get("PROJ_PROP_AUTHOR"));
      assertEquals("T", row.get("PROJ_PROP_COMPANY"));
      assertEquals("Standard", row.get("PROJ_INFO_CAL_NAME"));
      assertEquals("Project1", row.get("PROJ_PROP_TITLE"));
      byte[] foundBinaryData = row.getBytes("RESERVED_BINARY_DATA");
      byte[] expectedBinaryData =
        toByteArray(new File("src/test/data/test2BinData.dat"));
      assertTrue(Arrays.equals(expectedBinaryData, foundBinaryData));

      db.close();
    }
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:19,代码来源:LongValueTest.java


示例15: testLongValueAsMiddleColumn

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testLongValueAsMiddleColumn() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);
    Table newTable = new TableBuilder("NewTable")
      .addColumn(new ColumnBuilder("a").setSQLType(Types.INTEGER))
      .addColumn(new ColumnBuilder("b").setSQLType(Types.LONGVARCHAR))
      .addColumn(new ColumnBuilder("c").setSQLType(Types.VARCHAR))
      .toTable(db);

    String lval = createString(2000); // "--2000 chars long text--";
    String tval = createString(40); // "--40chars long text--";
    newTable.addRow(new Integer(1), lval, tval);

    newTable = db.getTable("NewTable");
    Map<String, Object> readRow = newTable.getNextRow();
    assertEquals(new Integer(1), readRow.get("a"));
    assertEquals(lval, readRow.get("b"));
    assertEquals(tval, readRow.get("c"));

    db.close();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:24,代码来源:LongValueTest.java


示例16: doTestWriteAndRead

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
private static void doTestWriteAndRead(Database db) throws Exception {
    createTestTable(db);
    Object[] row = createTestRow();
    row[3] = null;
    Table table = db.getTable("Test");
    int count = 1000;
    ((DatabaseImpl)db).getPageChannel().startWrite();
    try {
      for (int i = 0; i < count; i++) {
        table.addRow(row);
      }
    } finally {
      ((DatabaseImpl)db).getPageChannel().finishWrite();
    }
    for (int i = 0; i < count; i++) {
      Map<String, Object> readRow = table.getNextRow();
      assertEquals(row[0], readRow.get("A"));
      assertEquals(row[1], readRow.get("B"));
      assertEquals(row[2], readRow.get("C"));
      assertEquals(row[3], readRow.get("D"));
      assertEquals(row[4], readRow.get("E"));
      assertEquals(row[5], readRow.get("F"));
      assertEquals(row[6], readRow.get("G"));
      assertEquals(row[7], readRow.get("H"));
    }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:27,代码来源:DatabaseReadWriteTest.java


示例17: testAutoNumber

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testAutoNumber() throws Exception 
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .toTable(db);

    doTestAutoNumber(table);

    db.close();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:AutoNumberTest.java


示例18: testInsertLongAutoNumber

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testInsertLongAutoNumber() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .toTable(db);

    doTestInsertLongAutoNumber(table);

    db.close();
  }    
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:AutoNumberTest.java


示例19: testInsertLongAutoNumberPK

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testInsertLongAutoNumberPK() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .setPrimaryKey("a")
      .toTable(db);

    doTestInsertLongAutoNumber(table);

    db.close();
  }    
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:18,代码来源:AutoNumberTest.java


示例20: testNoEnforceForeignKeys

import com.healthmarketscience.jackcess.Table; //导入依赖的package包/类
public void testNoEnforceForeignKeys() throws Exception {
  for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {

    Database db = openCopy(testDB);
    db.setEnforceForeignKeys(false);
    Table t1 = db.getTable("Table1");
    Table t2 = db.getTable("Table2");
    Table t3 = db.getTable("Table3");

    t1.addRow(20, 0, 20, "some data", 20);

    Cursor c = CursorBuilder.createCursor(t2);
    c.moveToNextRow();
    c.updateCurrentRow(30, "foo30");

    c = CursorBuilder.createCursor(t3);
    c.moveToNextRow();
    c.deleteCurrentRow();

    db.close();
  }
  
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:24,代码来源:FKEnforcerTest.java



注:本文中的com.healthmarketscience.jackcess.Table类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DBFactory类代码示例发布时间:2022-05-21
下一篇:
Java JdbmPartition类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap