当前位置: 首页>>代码示例>>Java>>正文


Java CloseableIterator.close方法代码示例

本文整理汇总了Java中com.j256.ormlite.dao.CloseableIterator.close方法的典型用法代码示例。如果您正苦于以下问题:Java CloseableIterator.close方法的具体用法?Java CloseableIterator.close怎么用?Java CloseableIterator.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.dao.CloseableIterator的用法示例。


在下文中一共展示了CloseableIterator.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: textList

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public String textList() {
    String result = "";
    CloseableIterator<DbRequest> iterator = null;
    try {
        iterator = MainApp.getDbHelper().getDbRequestInterator();
        try {
            while (iterator.hasNext()) {
                DbRequest dbr = iterator.next();
                result += "<br>";
                result += dbr.action.toUpperCase() + " ";
                result += dbr.collection + ": ";
                result += dbr.data;
            }
        } finally {
            iterator.close();
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return result;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:22,代码来源:UploadQueue.java

示例2: getGeometryColumns

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
/**
 * Get the Geometry Columns, should only return one or no value
 * 
 * @return geometry columns
 */
public GeometryColumns getGeometryColumns() {
	GeometryColumns result = null;
	if (geometryColumns.size() > 1) {
		// This shouldn't happen with the unique table name constraint on
		// geometry columns
		throw new GeoPackageException(
				"Unexpected state. More than one GeometryColumn has a foreign key to the Contents. Count: "
						+ geometryColumns.size());
	} else if (geometryColumns.size() == 1) {
		CloseableIterator<GeometryColumns> iterator = geometryColumns
				.closeableIterator();
		try {
			result = iterator.next();
		} finally {
			try {
				iterator.close();
			} catch (IOException e) {
				throw new GeoPackageException(
						"Failed to close the Geometry Columns iterator", e);
			}
		}
	}
	return result;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:30,代码来源:Contents.java

示例3: getTileMatrixSet

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
/**
 * Get the Tile Matrix Set, should only return one or no value
 * 
 * @return tile matrix set
 */
public TileMatrixSet getTileMatrixSet() {
	TileMatrixSet result = null;
	if (tileMatrixSet.size() > 1) {
		// This shouldn't happen with the table name primary key on tile
		// matrix set
		throw new GeoPackageException(
				"Unexpected state. More than one TileMatrixSet has a foreign key to the Contents. Count: "
						+ tileMatrixSet.size());
	} else if (tileMatrixSet.size() == 1) {
		CloseableIterator<TileMatrixSet> iterator = tileMatrixSet
				.closeableIterator();
		try {
			result = iterator.next();
		} finally {
			try {
				iterator.close();
			} catch (IOException e) {
				throw new GeoPackageException(
						"Failed to close the Tile Matrix Set iterator", e);
			}
		}
	}
	return result;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:30,代码来源:Contents.java

示例4: testMoveClosed

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testMoveClosed() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);

	CloseableIterator<Foo> iterator = dao.iterator();
	try {
		assertFalse(iterator.hasNext());
		assertNull(iterator.first());
		assertNull(iterator.previous());
		assertNull(iterator.current());
		assertNull(iterator.nextThrow());
		assertNull(iterator.moveRelative(10));
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:17,代码来源:SelectIteratorTest.java

示例5: testBasic

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testBasic() throws Exception {
	Dao<MyDouble, Object> dao = createDao(MyDouble.class, true);

	MyDouble foo = new MyDouble();
	foo.val = 1.23456789123456;
	assertEquals(1, dao.create(foo));

	MyDouble result = dao.queryForId(foo.id);
	assertNotNull(result);
	assertEquals(foo.val, result.val, 0.0);

	GenericRawResults<String[]> results = dao.queryRaw(dao.queryBuilder().prepareStatementString());
	CloseableIterator<String[]> iterator = results.closeableIterator();
	try {
		assertTrue(iterator.hasNext());
		String[] strings = iterator.next();
		assertNotNull(strings);

		assertTrue(strings.length >= 2);
		assertEquals(Integer.toString(foo.id), strings[0]);
		assertEquals(Double.toString(foo.val), strings[1]);
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-tests,代码行数:27,代码来源:SqliteRawRowMapperImplTest.java

示例6: testCloseIteratorBeforeNext

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testCloseIteratorBeforeNext() throws Exception {
	Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	foo1.stuff = "s1";
	fooDao.create(foo1);
	CloseableIterator<Foo> iterator = fooDao.iterator();
	try {
		while (iterator.hasNext()) {
			closeConnectionSource();
			iterator.next();
		}
		if (!CLOSE_IS_NOOP) {
			fail("expected exception");
		}
	} catch (IllegalStateException e) {
		// expected
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:21,代码来源:AndroidJdbcBaseDaoImplTest.java

示例7: testCloseIteratorBeforeRemove

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testCloseIteratorBeforeRemove() throws Exception {
	Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	foo1.stuff = "s1";
	fooDao.create(foo1);
	CloseableIterator<Foo> iterator = fooDao.iterator();
	try {
		while (iterator.hasNext()) {
			iterator.next();
			closeConnectionSource();
			iterator.remove();
		}
		if (!CLOSE_IS_NOOP) {
			fail("expected exception");
		}
	} catch (Exception e) {
		// expected
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:22,代码来源:AndroidJdbcBaseDaoImplTest.java

示例8: testIteratorJdbcMoveBack

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test(expected = SQLException.class)
public void testIteratorJdbcMoveBack() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);
	Foo foo = new Foo();
	assertEquals(1, dao.create(foo));

	QueryBuilder<Foo, Integer> qb = dao.queryBuilder();
	qb.orderBy(Foo.VAL_COLUMN_NAME, true);
	CloseableIterator<Foo> iterator = dao.iterator(qb.prepare());
	try {
		assertEquals(foo, iterator.first());
		iterator.first();
		fail("Should have thrown");
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:18,代码来源:SelectIteratorTest.java

示例9: testIteratorRawResults

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testIteratorRawResults() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	assertEquals(1, dao.create(foo1));

	GenericRawResults<String[]> rawResults = dao.queryRaw("SELECT " + Foo.ID_COLUMN_NAME + " FROM FOO");
	CloseableIterator<String[]> iterator = rawResults.closeableIterator();
	try {
		assertTrue(iterator.hasNext());
		iterator.next();
		iterator.remove();
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:17,代码来源:SelectIteratorTest.java

示例10: testIteratorPreparedQuery

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testIteratorPreparedQuery() throws Exception {
	final Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
	// do an insert of bunch of items
	final int numItems = 100;
	fooDao.callBatchTasks(new InsertCallable(numItems, fooDao));

	int lastX = 10;
	PreparedQuery<Foo> preparedQuery =
			fooDao.queryBuilder().where().ge(Foo.VAL_FIELD_NAME, numItems - lastX).prepare();

	// now delete them with the iterator to test page-size
	CloseableIterator<Foo> iterator = fooDao.iterator(preparedQuery);
	try {
		int itemC = 0;
		while (iterator.hasNext()) {
			iterator.next();
			itemC++;
		}
		assertEquals(lastX, itemC);
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:24,代码来源:AndroidJdbcBaseDaoImplTest.java

示例11: testIteratorNextRemoveRemoveNoNext

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testIteratorNextRemoveRemoveNoNext() throws Exception {
	Dao<Foo, Object> dao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	assertEquals(1, dao.create(foo1));
	Foo foo2 = new Foo();
	assertEquals(1, dao.create(foo2));
	CloseableIterator<Foo> iterator = dao.iterator();
	try {
		iterator.next();
		iterator.remove();
		iterator.remove();
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:17,代码来源:SelectIteratorTest.java

示例12: testIteratorRemove

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testIteratorRemove() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	assertEquals(1, dao.create(foo1));

	assertEquals(1, dao.queryForAll().size());

	CloseableIterator<Foo> iterator = dao.iterator();
	assertTrue(iterator.hasNext());
	Foo result = iterator.next();
	assertEquals(foo1.id, result.id);
	iterator.remove();

	assertFalse(iterator.hasNext());
	assertNull(iterator.nextThrow());

	assertEquals(0, dao.queryForAll().size());
	iterator.close();
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:21,代码来源:SelectIteratorTest.java

示例13: testIteratorHasNextClosed

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testIteratorHasNextClosed() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);
	Foo foo1 = new Foo();
	assertEquals(1, dao.create(foo1));

	assertEquals(1, dao.queryForAll().size());

	CloseableIterator<Foo> iterator = dao.iterator();
	assertTrue(iterator.hasNext());
	iterator.next();

	assertFalse(iterator.hasNext());
	assertNull(iterator.nextThrow());

	iterator.close();
	assertFalse(iterator.hasNext());
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:19,代码来源:SelectIteratorTest.java

示例14: testStringArrayRowMapper

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testStringArrayRowMapper() throws Exception {
	Dao<MyDouble, Object> dao = createDao(MyDouble.class, true);

	MyDouble foo = new MyDouble();
	foo.val = 1.23456789123456;
	assertEquals(1, dao.create(foo));

	MyDouble result = dao.queryForId(foo.id);
	assertNotNull(result);
	assertEquals(foo.val, result.val, 0.0);

	GenericRawResults<String[]> results =
			dao.queryRaw(dao.queryBuilder().selectColumns("id", "val").prepareStatementString());
	CloseableIterator<String[]> iterator = results.closeableIterator();
	try {
		assertTrue(iterator.hasNext());
		String[] strings = iterator.next();
		assertNotNull(strings);

		assertTrue(strings.length >= 2);
		assertEquals(foo.id, Integer.parseInt(strings[0]));
		// NOTE: this doesn't work because the output is truncated
		// assertEquals(foo.val, Double.parseDouble(strings[1]));
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:28,代码来源:SqliteRawRowMapperImplTest.java

示例15: testObjectArrayRowMapper

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testObjectArrayRowMapper() throws Exception {
	Dao<MyDouble, Object> dao = createDao(MyDouble.class, true);

	MyDouble foo = new MyDouble();
	foo.val = 1.23456789123456;
	assertEquals(1, dao.create(foo));

	MyDouble result = dao.queryForId(foo.id);
	assertNotNull(result);
	assertEquals(foo.val, result.val, 0.0);

	GenericRawResults<Object[]> results =
			dao.queryRaw(dao.queryBuilder().selectColumns("id", "val").prepareStatementString(), new DataType[] {
					DataType.INTEGER, DataType.DOUBLE });
	CloseableIterator<Object[]> iterator = results.closeableIterator();
	try {
		assertTrue(iterator.hasNext());
		Object[] objs = iterator.next();
		assertNotNull(objs);

		assertTrue(objs.length >= 2);
		assertEquals(foo.id, objs[0]);
		// this works fine
		assertEquals(foo.val, objs[1]);
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:29,代码来源:SqliteRawRowMapperImplTest.java


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