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


Java ResultSet.contains方法代码示例

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


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

示例1: asCollection

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns a Collection-like view of the given ResultSet.
 * <p/>
 * The collection simply delegates to the ResultSet, which in turn will reflect
 * any changes made to the underlying IndexedCollection by other threads.
 * For example consecutive calls to the size() method
 * may return different values if objects are added to or removed from the IndexedCollection.
 *
 * @param resultSet The ResultSet to wrap
 * @return A Collection-like view of the given ResultSet
 */
public static <O> Collection<O> asCollection(final ResultSet<O> resultSet) {
    return new AbstractCollection<O>() {
        @Override
        public Iterator<O> iterator() {
            return resultSet.iterator();
        }
        @Override
        public int size() {
            return resultSet.size();
        }

        @Override
        public boolean contains(Object o) {
            @SuppressWarnings("unchecked")
            O object = (O)o;
            return resultSet.contains(object);
        }

        @Override
        public boolean isEmpty() {
            return resultSet.isEmpty();
        }
    };
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:36,代码来源:ResultSets.java

示例2: contains

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns true if the given object is contained in <b><u>any</u></b> underlying ResultSets.
 * @param object An object to check if contained
 * @return true if the given object is contained in <b><u>any</u></b> underlying ResultSets, false if it is not
 * contained in any ResultSets or if there are no underlying result sets
 */
@Override
public boolean contains(O object) {
    for (ResultSet<O> resultSet : this.resultSets) {
        if (resultSet.contains(object)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:16,代码来源:ResultSetUnionAll.java

示例3: contains

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns true if the given object is contained in <b><u>all</u></b> underlying ResultSets.
 * @param object An object to check if contained
 * @return true if the given object is contained in <b><u>all</u></b> underlying ResultSets, false if it is not
 * contained in one or more ResultSets or if there are no underlying result sets
 */
@Override
public boolean contains(O object) {
    if (this.resultSets.isEmpty()) {
        return false;
    }
    for (ResultSet<O> resultSet : this.resultSets) {
        if (!resultSet.contains(object)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:19,代码来源:ResultSetIntersection.java

示例4: testNewResultSet_Contains

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_Contains() throws Exception{

    // Mocks
    ConnectionManager connectionManager = mock(ConnectionManager.class);
    Connection connectionContains = mock(Connection.class);
    Connection connectionDoNotContain = mock(Connection.class);
    PreparedStatement preparedStatementContains = mock(PreparedStatement.class);
    PreparedStatement preparedStatementDoNotContains = mock(PreparedStatement.class);
    java.sql.ResultSet resultSetContains = mock(java.sql.ResultSet.class);
    java.sql.ResultSet resultSetDoNotContain = mock(java.sql.ResultSet.class);

    // Behaviour
    when(connectionManager.getConnection(any(SQLiteIndex.class), anyQueryOptions())).thenReturn(connectionContains).thenReturn(connectionDoNotContain);
    when(connectionContains.prepareStatement("SELECT objectKey FROM " + TABLE_NAME + " WHERE value = ? AND objectKey = ? LIMIT 1;")).thenReturn(preparedStatementContains);
    when(connectionDoNotContain.prepareStatement("SELECT objectKey FROM " + TABLE_NAME + " WHERE value = ? AND objectKey = ? LIMIT 1;")).thenReturn(preparedStatementDoNotContains);
    when(preparedStatementContains.executeQuery()).thenReturn(resultSetContains);
    when(preparedStatementDoNotContains.executeQuery()).thenReturn(resultSetDoNotContain);
    when(resultSetContains.next()).thenReturn(true).thenReturn(false);
    when(resultSetDoNotContain.next()).thenReturn(false);

    // Iterator
    ResultSet<Car> carsWithAbs = new SQLiteIndex<String, Car, Integer>(
            Car.FEATURES,
            OBJECT_TO_ID,
            ID_TO_OBJECT,
            "")

            .retrieve(equal(Car.FEATURES, "abs"), createQueryOptions(connectionManager));

    assertNotNull(carsWithAbs);
    boolean resultContains = carsWithAbs.contains(data.get(0));
    assertTrue(resultContains);
    verify(connectionContains, times(0)).close();

    boolean resultDoNotContain = carsWithAbs.contains(data.get(1));
    assertFalse(resultDoNotContain);
    verify(connectionDoNotContain, times(0)).close();


}
 
开发者ID:npgall,项目名称:cqengine,代码行数:42,代码来源:SQLiteIndexTest.java

示例5: testNewResultSet_FilterQuery_Contains

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_FilterQuery_Contains() throws Exception{

    // Mocks
    FilterQuery<Car, String> filterQuery = mockFilterQuery();
    ConnectionManager connectionManager = mock(ConnectionManager.class);
    Connection connectionContains = mock(Connection.class);
    Connection connectionDoNotContain = mock(Connection.class);
    Connection connectionNoRows = mock(Connection.class);
    PreparedStatement preparedStatementContains = mock(PreparedStatement.class);
    PreparedStatement preparedStatementDoNotContains = mock(PreparedStatement.class);
    PreparedStatement preparedStatementNoRows = mock(PreparedStatement.class);
    java.sql.ResultSet resultSetContains = mock(java.sql.ResultSet.class);
    java.sql.ResultSet resultSetDoNotContain = mock(java.sql.ResultSet.class);
    java.sql.ResultSet resultSetNoRows = mock(java.sql.ResultSet.class);

    // Behaviour
    //SELECT objectKey, value FROM cqtbl_%s WHERE objectKey=?
    when(connectionManager.getConnection(any(SQLiteIndex.class), anyQueryOptions())).thenReturn(connectionContains).thenReturn(connectionDoNotContain).thenReturn(connectionNoRows);
    when(connectionContains.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementContains);
    when(connectionDoNotContain.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementDoNotContains);
    when(connectionNoRows.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementNoRows);
    when(preparedStatementContains.executeQuery()).thenReturn(resultSetContains);
    when(preparedStatementDoNotContains.executeQuery()).thenReturn(resultSetDoNotContain);
    when(preparedStatementNoRows.executeQuery()).thenReturn(resultSetNoRows);

    when(resultSetContains.next()).thenReturn(true).thenReturn(true).thenReturn(false);
    when(resultSetContains.getInt(1)).thenReturn(1).thenReturn(1);
    when(resultSetContains.getString(2)).thenReturn("abs").thenReturn("gps");

    when(resultSetDoNotContain.next()).thenReturn(true).thenReturn(false);
    when(resultSetDoNotContain.getInt(1)).thenReturn(2);
    when(resultSetDoNotContain.getString(2)).thenReturn("airbags");

    when(resultSetNoRows.next()).thenReturn(false);

    // Iterator
    ResultSet<Car> carsWithAbs = new SQLiteIndex<String, Car, Integer>(
            Car.FEATURES,
            OBJECT_TO_ID,
            ID_TO_OBJECT,
            "")

            .retrieve(filterQuery, createQueryOptions(connectionManager));

    assertNotNull(carsWithAbs);
    boolean resultContains = carsWithAbs.contains(data.get(0));
    assertTrue(resultContains);
    verify(connectionContains, times(0)).close();

    boolean resultDoNotContain = carsWithAbs.contains(data.get(1));
    assertFalse(resultDoNotContain);
    verify(connectionDoNotContain, times(0)).close();

    boolean resultNoRows = carsWithAbs.contains(CarFactory.createCar(100));
    assertFalse(resultNoRows);
    verify(connectionNoRows, times(0)).close();

}
 
开发者ID:npgall,项目名称:cqengine,代码行数:60,代码来源:SQLiteIndexTest.java


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