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


Java CloseableIterator.remove方法代码示例

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


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

示例1: 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

示例2: testIteratePageSize

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

	int numItems = 1000;
	fooDao.callBatchTasks(new InsertCallable(numItems, fooDao));

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

示例3: 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

示例4: 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

示例5: 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

示例6: testNoNextBeforeRemove

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testNoNextBeforeRemove() 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 {
		iterator.remove();
		fail("expected exception");
	} catch (IllegalStateException e) {
		// expected
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:16,代码来源:AndroidJdbcBaseDaoImplTest.java

示例7: testIteratorRemoveNoNext

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

示例8: testIterateRemove

import com.j256.ormlite.dao.CloseableIterator; //导入方法依赖的package包/类
public void testIterateRemove() throws Exception {
	Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
	List<Foo> acctList = fooDao.queryForAll();
	int initialSize = acctList.size();

	Foo foo1 = new Foo();
	foo1.stuff = "s1";
	Foo foo2 = new Foo();
	foo2.stuff = "s2";
	Foo foo3 = new Foo();
	foo3.stuff = "s3";
	fooDao.create(foo1);
	fooDao.create(foo2);
	fooDao.create(foo3);

	assertTrue(foo1.id != foo2.id);
	assertTrue(foo1.id != foo3.id);
	assertTrue(foo2.id != foo3.id);

	assertEquals(foo1, fooDao.queryForId(foo1.id));
	assertEquals(foo2, fooDao.queryForId(foo2.id));
	assertEquals(foo3, fooDao.queryForId(foo3.id));

	acctList = fooDao.queryForAll();
	assertEquals(initialSize + 3, acctList.size());
	assertEquals(foo1, acctList.get(acctList.size() - 3));
	assertEquals(foo2, acctList.get(acctList.size() - 2));
	assertEquals(foo3, acctList.get(acctList.size() - 1));
	int acctC = 0;
	CloseableIterator<Foo> iterator = fooDao.iterator();
	try {
		while (iterator.hasNext()) {
			Foo foo = iterator.next();
			if (acctC == acctList.size() - 3) {
				assertEquals(foo1, foo);
			} else if (acctC == acctList.size() - 2) {
				iterator.remove();
				assertEquals(foo2, foo);
			} else if (acctC == acctList.size() - 1) {
				assertEquals(foo3, foo);
			}
			acctC++;
		}
		assertEquals(initialSize + 3, acctC);
	} finally {
		iterator.close();
	}
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:49,代码来源:AndroidJdbcBaseDaoImplTest.java


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