本文整理汇总了Java中com.healthmarketscience.jackcess.CursorBuilder类的典型用法代码示例。如果您正苦于以下问题:Java CursorBuilder类的具体用法?Java CursorBuilder怎么用?Java CursorBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CursorBuilder类属于com.healthmarketscience.jackcess包,在下文中一共展示了CursorBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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")));
}
}
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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();
}
示例13: newCursor
import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public CursorBuilder newCursor() {
return new CursorBuilder(this);
}
示例14: newCursor
import com.healthmarketscience.jackcess.CursorBuilder; //导入依赖的package包/类
public CursorBuilder newCursor() {
return getTable().newCursor().setIndex(this);
}
示例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);
}