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

Java CursorBuilder类代码示例

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

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



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

示例1: getRelationshipsImpl

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
private List<Relationship> getRelationshipsImpl(
    TableImpl table1, TableImpl table2, boolean includeSystemTables)
  throws IOException
{
  initRelationships();
  
  List<Relationship> relationships = new ArrayList<Relationship>();

  if(table1 != null) {
    Cursor cursor = createCursorWithOptionalIndex(
        _relationships, REL_COL_FROM_TABLE, table1.getName());
    collectRelationships(cursor, table1, table2, relationships,
                         includeSystemTables);
    cursor = createCursorWithOptionalIndex(
        _relationships, REL_COL_TO_TABLE, table1.getName());
    collectRelationships(cursor, table2, table1, relationships,
                         includeSystemTables);
  } else {
    collectRelationships(new CursorBuilder(_relationships).toCursor(),
                         null, null, relationships, includeSystemTables);
  }
  
  return relationships;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:25,代码来源:DatabaseImpl.java


示例2: checkIndexEntries

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的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


示例3: x_testReadAllCodesMdb

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的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


示例4: x_testReadIsoMdb

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的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


示例5: testNoEnforceForeignKeys

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的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


示例6: getCursor

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public Cursor getCursor() throws IOException {
	Index idx = getBestIndex();
	Cursor cursor;
	CursorBuilder cb=table.newCursor();
	if (idx == null)
		cursor = cb.toCursor();
	else
		cursor = cb.setIndex(idx).toCursor();
	cursor.setColumnMatcher(new ColumnMatcher());
	return cursor;
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:12,代码来源:IndexSelector.java


示例7: JackcessDenseObjectMatrix2D

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public JackcessDenseObjectMatrix2D(File file, String tablename) throws IOException {
	super(0, 0);
	database = DatabaseBuilder.open(file);
	VerifyUtil.verifyNotNull(database, "database could not be opened");
	table = database.getTable(tablename);
	VerifyUtil.verifyNotNull(table, "table not found in database");
	columns = table.getColumns();
	cursor = CursorBuilder.createCursor(table);

	for (int i = 0; i < columns.size(); i++) {
		setColumnLabel(i, columns.get(i).getName());
	}
	setLabel(tablename);
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:15,代码来源:JackcessDenseObjectMatrix2D.java


示例8: create

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
/**
 * Creates a new Joiner based on the given index which backs a foreign-key
 * relationship.  The table of the given index will be the "from" table and
 * the table on the other end of the relationship will be the "to" table.
 *
 * @param fromIndex the index backing one side of a foreign-key relationship
 */
public static Joiner create(Index fromIndex)
  throws IOException
{
  Index toIndex = fromIndex.getReferencedIndex();
  IndexCursor toCursor = CursorBuilder.createCursor(toIndex);
  // text lookups are always case-insensitive
  toCursor.setColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE);
  return new Joiner(fromIndex, toCursor);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:Joiner.java


示例9: findRow

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
private static void findRow(final TestDB testDB, Table t, Index index,
                            Row expectedRow,
                            Cursor.Position expectedPos)
  throws Exception
{
  Object[] idxRow = ((IndexImpl)index).constructIndexRow(expectedRow);
  Cursor cursor = CursorBuilder.createCursor(index, idxRow, idxRow);

  Cursor.Position startPos = cursor.getSavepoint().getCurrentPosition();
  
  cursor.beforeFirst();
  while(cursor.moveToNextRow()) {
    Row row = cursor.getCurrentRow();
    if(expectedRow.equals(row)) {
      // verify that the entries are indeed equal
      Cursor.Position curPos = cursor.getSavepoint().getCurrentPosition();
      assertEquals(entryToString(expectedPos), entryToString(curPos));
      return;
    }
  }

  // TODO long rows not handled completely yet in V2010
  // seems to truncate entry at 508 bytes with some trailing 2 byte seq
  if(testDB.getExpectedFileFormat() == Database.FileFormat.V2010) {
    String rowId = expectedRow.getString("name");
    String tName = t.getName();
    if(("Table11".equals(tName) || "Table11_desc".equals(tName)) &&
       ("row10".equals(rowId) || "row11".equals(rowId) || 
        "row12".equals(rowId))) {
      System.out.println(
          "TODO long rows not handled completely yet in V2010: " + tName +
                         ", " + rowId);
      return;
    }
  }

  fail("testDB: " + testDB + ";\nCould not find expected row " + expectedRow + " starting at " +
       entryToString(startPos));
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:40,代码来源:IndexCodesTest.java


示例10: removeFirst

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public boolean removeFirst(E e) throws IOException {
	if (mapper.hasId()) {
		return removeById(mapper.getId(e));
	}
	Row row = CursorBuilder.findRow(table, mapper.getMappedRow(e, false));
	if (row != null) {
		table.deleteRow(row);
		return true;
	}
	return false;
}
 
开发者ID:amgohan,项目名称:jackcess-orm,代码行数:12,代码来源:AccessDao.java


示例11: _findById

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
protected Row _findById(Object id) throws IOException {
	if(!mapper.hasId()) {
		throw new JackcessException("this class " + clazz.getCanonicalName() + " does not have an @Id annotation.");
	}
	final String idColumnName = mapper.getDbColumn(mapper.getAttributeIdName());
	Row row = CursorBuilder.findRow(table, Collections.singletonMap(idColumnName, id));
	return row;
}
 
开发者ID:amgohan,项目名称:jackcess-orm,代码行数:9,代码来源:AccessDao.java


示例12: createCPCModel

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
/**
 * Creates an Jena model corresponding to a version of CPC and saves it to a Turtle file.
 * 
 * @param version Version of the classification ("1.1", "2", "2.1").
 * @param withNotes Boolean indicating if the explanatory notes must be produced in the model.
 * @throws Exception In case of problem getting the data or creating the file.
 */
private void createCPCModel(String version, boolean withNotes) throws Exception {

	logger.debug("Construction of the Jena model for CPC version " + version);

	// Init the Jena model for the given version of the classification
	initModel(version);

	// For CPC, the naming of the columns in the tables between different versions is not coherent
	String codeColumnName = ("2.1".equals(version)) ? "CPC21code" : "Code";
	String labelColumnName = ("2.1".equals(version)) ? "CPC21title" : "Description";
	String noteColumnName = ("2.1".equals(version)) ? "CPC21ExplanatoryNote" : "ExplanatoryNote";

	// Open a cursor on the main table and iterate through all the records
	Table table = DatabaseBuilder.open(new File(INPUT_FOLDER + CPC_ACCESS_FILE.get(version))).getTable(CPC_ACCESS_TABLE.get(version));
	Cursor cursor = CursorBuilder.createCursor(table);
	logger.debug("Cursor defined on table " + CPC_ACCESS_TABLE.get(version));
	for (Row row : cursor.newIterable()) {
		String itemCode = row.getString(codeColumnName);
		Resource itemResource = cpcModel.createResource(Names.getItemURI(itemCode, "CPC", version), SKOS.Concept);
		itemResource.addProperty(SKOS.notation, cpcModel.createLiteral(itemCode));
		itemResource.addProperty(SKOS.prefLabel, cpcModel.createLiteral(row.getString(labelColumnName), "en"));
		// Add explanatory notes if requested
		// TODO For CPC Ver.2 and CPC Ver.2.1, all notes together in one column. For now all is recorded as a skos:skosNote
		if (withNotes) {
			String note = row.getString(noteColumnName + "ExplanatoryNote");
			if ((note != null) && (note.length() > 0)) itemResource.addProperty(SKOS.scopeNote, cpcModel.createLiteral(note, "en"));
		}
		// Create the SKOS hierarchical properties for the item
		itemResource.addProperty(SKOS.inScheme, scheme);
		String parentCode = getParentCode(itemCode);
		if (parentCode == null) {
			scheme.addProperty(SKOS.hasTopConcept, itemResource);
			itemResource.addProperty(SKOS.topConceptOf, scheme);
		} else {
			Resource parentResource = cpcModel.createResource(Names.getItemURI(parentCode, "CPC", version), SKOS.Concept);
			parentResource.addProperty(SKOS.narrower, itemResource);
			itemResource.addProperty(SKOS.broader, parentResource);
		}
		// Add the item as a member of its level
		Resource level = levels.get(itemCode.length() - 1);
		level.addProperty(SKOS.member, itemResource);
	}
	logger.debug("Finished reading table " + CPC_ACCESS_TABLE.get(version));
	// Create additional labels if they exist
	if (CPC_SPANISH_LABELS_FILE.get(version) != null)
		this.addLabels(INPUT_FOLDER + CPC_SPANISH_LABELS_FILE.get(version), version, "es");

	// Write the Turtle file and clear the model
	String turtleFileName = OUTPUT_FOLDER + Names.getCSContext("CPC", version) + ".ttl";
	cpcModel.write(new FileOutputStream(turtleFileName), "TTL");
	logger.info("The Jena model for CPC Ver." + version + " has been written to " + turtleFileName);
	cpcModel.close();
}
 
开发者ID:FranckCo,项目名称:Stamina,代码行数:61,代码来源:CPCModelMaker.java


示例13: newCursor

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public CursorBuilder newCursor() {
  return new CursorBuilder(this);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:4,代码来源:TableImpl.java


示例14: newCursor

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public CursorBuilder newCursor() {
  return getTable().newCursor().setIndex(this);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:4,代码来源:IndexImpl.java


示例15: create

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
/**
 * Creates a ComplexColumnInfo for a complex column.
 */
public static ComplexColumnInfo<? extends ComplexValue> create(
    ColumnImpl column, ByteBuffer buffer, int offset)
  throws IOException
{
  int complexTypeId = buffer.getInt(
      offset + column.getFormat().OFFSET_COLUMN_COMPLEX_ID);

  DatabaseImpl db = column.getDatabase();
  TableImpl complexColumns = db.getSystemComplexColumns();
  IndexCursor cursor = CursorBuilder.createCursor(
      complexColumns.getPrimaryKeyIndex());
  if(!cursor.findFirstRowByEntry(complexTypeId)) {
    throw new IOException(column.withErrorContext(
        "Could not find complex column info for complex column with id " +
        complexTypeId));
  }
  Row cColRow = cursor.getCurrentRow();
  int tableId = cColRow.getInt(COL_TABLE_ID);
  if(tableId != column.getTable().getTableDefPageNumber()) {
    throw new IOException(column.withErrorContext(
        "Found complex column for table " + tableId + " but expected table " +
        column.getTable().getTableDefPageNumber()));
  }
  int flatTableId = cColRow.getInt(COL_FLAT_TABLE_ID);
  int typeObjId = cColRow.getInt(COL_COMPLEX_TYPE_OBJECT_ID);

  TableImpl typeObjTable = db.getTable(typeObjId);
  TableImpl flatTable = db.getTable(flatTableId);

  if((typeObjTable == null) || (flatTable == null)) {
    throw new IOException(column.withErrorContext(
        "Could not find supporting tables (" + typeObjId + ", " + flatTableId
        + ") for complex column with id " + complexTypeId));
  }
  
  // we inspect the structore of the "type table" to determine what kind of
  // complex info we are dealing with
  if(isMultiValueColumn(typeObjTable)) {
    return new MultiValueColumnInfoImpl(column, complexTypeId, typeObjTable,
                                    flatTable);
  } else if(isAttachmentColumn(typeObjTable)) {
    return new AttachmentColumnInfoImpl(column, complexTypeId, typeObjTable,
                                    flatTable);
  } else if(isVersionHistoryColumn(typeObjTable)) {
    return new VersionHistoryColumnInfoImpl(column, complexTypeId, typeObjTable,
                                        flatTable);
  }
  
  LOG.warn(column.withErrorContext(
               "Unsupported complex column type " + typeObjTable.getName()));
  return new UnsupportedColumnInfoImpl(column, complexTypeId, typeObjTable,
                                       flatTable);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:57,代码来源:ComplexColumnSupport.java


示例16: testBigInt

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

    for (final Database.FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
      JetFormat format = DatabaseImpl.getFileFormatDetails(fileFormat)
        .getFormat();

      if(!format.isSupportedDataType(DataType.BIG_INT)) {
        continue;
      }

      Database db = create(fileFormat);

      Table t = new TableBuilder("Test")
        .addColumn(new ColumnBuilder("id", DataType.LONG)
                   .setAutoNumber(true))
        .addColumn(new ColumnBuilder("data1", DataType.TEXT))
        .addColumn(new ColumnBuilder("num1", DataType.BIG_INT))
        .addIndex(new IndexBuilder("idx").addColumns("num1"))
        .toTable(db);

      long[] vals = new long[] {
        0L, -10L, 3844L, -45309590834L, 50392084913L, 65000L, -6489273L};

      List<Map<String, Object>> expectedTable = 
        new ArrayList<Map<String, Object>>();

      int idx = 1;
      for(long lng : vals) {
        t.addRow(Column.AUTO_NUMBER, "" + lng, lng);

        expectedTable.add(createExpectedRow(
                              "id", idx++,
                              "data1", "" + lng,
                              "num1", lng));
      }

      Collections.sort(expectedTable, new Comparator<Map<String, Object>>() {
          public int compare(
              Map<String, Object> r1,
              Map<String, Object> r2) {
            Long l1 = (Long)r1.get("num1");
            Long l2 = (Long)r2.get("num1");
            return l1.compareTo(l2);
          }
        });
      
      Cursor c = new CursorBuilder(t).setIndexByName("idx").toIndexCursor();

      assertCursor(expectedTable, c);

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


示例17: newCursor

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
@Override
public CursorBuilder newCursor() {
    return null;
}
 
开发者ID:hzpz,项目名称:access-export,代码行数:5,代码来源:IndexStub.java


示例18: iteratorRaw

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
private TupleIterator iteratorRaw() throws IOException {
	return new TupleIterator() {
		Database db = DatabaseBuilder.open(new File(meta.getFileSpec()));
		Table table = db.getTable(meta.getTable());
		Cursor cursor = CursorBuilder.createCursor(table);
		Row currentLine = null;
		
		@Override
		public boolean hasNext() {
			if (currentLine != null)
				return true;
			try {
				if (cursor.moveToNextRow()) {
					currentLine = cursor.getCurrentRow();
					if (currentLine == null)
						return false;
					return true;
				}
			} catch (IOException ioe) {
				System.out.println("TableACCDB[1]: error " + ioe);					
			}
			return false;
		}

		@Override
		public ValueTuple next() {
			if (hasNext())
				try {
					return toTuple(table, currentLine);
				} finally {
					currentLine = null;
				}
			else
				return null;
		}

		@Override
		public void close() {
			try {
				db.close();
			} catch (IOException e) {
				System.out.println("TableACCDB[2]: error " + e);
			}
		}
	};		
}
 
开发者ID:DaveVoorhis,项目名称:Rel,代码行数:47,代码来源:TableACCDB.java


示例19: exportWriter

import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
/**
 * Copy a table in this database into a new delimited text file. <br>
 * Equivalent to: {@code exportWriter(Cursor.createCursor(db.getTable(tableName)), out, header, delim, quote, filter);}
 * 
 * @param db
 *          Database the table to export belongs to
 * @param tableName
 *          Name of the table to export
 * @param out
 *          Writer to export to
 * @param header
 *          If <code>true</code> the first line contains the column names
 * @param delim
 *          The column delimiter, <code>null</code> for default (comma)
 * @param quote
 *          The quote character
 * @param filter
 *          valid export filter
 * 
 * @see #exportWriter(Cursor,BufferedWriter,boolean,String,char,ExportFilter)
 * @see Builder
 */
public static void exportWriter(Database db, String tableName,
    BufferedWriter out, boolean header, String delim,
    char quote, ExportFilter filter)
    throws IOException 
{
  exportWriter(CursorBuilder.createCursor(db.getTable(tableName)), out, header,
               delim, quote, filter);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:31,代码来源:ExportUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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