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


Java ReadFilter类代码示例

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


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

示例1: testReadWithFilterPerPage

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Test
public void testReadWithFilterPerPage() {
    store.save(new Data("foo", "desc of foo"));
    store.save(new Data("bar", "desc of bar"));

    ReadFilter filter = new ReadFilter();
    filter.setLimit(1);

    Collection<Data> datas = store.readWithFilter(filter);
    Assert.assertNotNull("datas could not be null", datas);
    Assert.assertEquals("datas should 1 data", 1, datas.size());
    Assert.assertEquals("foo", datas.iterator().next().getName());

    filter.setOffset(1);
    datas = store.readWithFilter(filter);
    Assert.assertEquals("bar", datas.iterator().next().getName());
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:18,代码来源:MemoryStoreTest.java

示例2: runRead

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
/**
 * Runs a read method, returns the result of the call back and makes sure no
 * exceptions are thrown
 *
 * @param restPipe
 */
private <T> List<T> runRead(Pipe<T> restPipe, ReadFilter readFilter) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);
    final AtomicReference<List<T>> resultRef = new AtomicReference<List<T>>();

    restPipe.read(readFilter, new Callback<List<T>>() {
        @Override
        public void onSuccess(List<T> data) {
            resultRef.set(data);
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            hasException.set(true);
            Logger.getLogger(RestAdapterTest.class.getSimpleName()).log(Level.SEVERE, e.getMessage(), e);
            latch.countDown();
        }
    });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertFalse(hasException.get());

    return resultRef.get();
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:32,代码来源:RestAdapterTest.java

示例3: runReadForException

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
/**
 * Runs a read method, returns the result of the call back and rethrows the
 * underlying exception
 *
 * @param restPipe
 */
private <T> List<T> runReadForException(Pipe<T> restPipe, ReadFilter readFilter) throws InterruptedException, Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);
    final AtomicReference<Exception> exceptionref = new AtomicReference<Exception>();
    restPipe.read(readFilter, new Callback<List<T>>() {
        @Override
        public void onSuccess(List<T> data) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            hasException.set(true);
            exceptionref.set(e);
            latch.countDown();
        }
    });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertTrue(hasException.get());

    throw exceptionref.get();
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:30,代码来源:RestAdapterTest.java

示例4: testNext

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testNext() {
    Pipe pipe = mock(Pipe.class);
    ReadFilter next = new ReadFilter();
    List delegate = new ArrayList();
    ReadFilter previous = new ReadFilter();

    next.setLinkUri(URI.create("./next"));
    previous.setLinkUri(URI.create("./previous"));

    WrappingPagedList list = new WrappingPagedList(pipe, delegate, next, previous);
    list.next(mock(Callback.class));
    list.previous(mock(Callback.class));

    verify(pipe).read(eq(next), any(Callback.class));
    verify(pipe).read(eq(previous), any(Callback.class));

}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:20,代码来源:PagedListTest.java

示例5: exec

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public SingleColumnJsonArrayList exec(Gson gson, SQLStore presentationStore, Uri uri, ContentValues[] values, String selection, String[] selectionArgs) {
    if (DevNexusContentProvider.presentations == null) {
        DevNexusContentProvider.presentations = new ArrayList<Presentation>(presentationStore.readAll());
        if (presentations.isEmpty()) {
            loadTemplate(presentationStore);
        }
    }

    if (selection == null || selection.isEmpty()) {
        return new SingleColumnJsonArrayList(new ArrayList<Presentation>(DevNexusContentProvider.presentations));
    } else {
        String[] queries = selection.split(" && ");
        JSONObject where = new JSONObject();
        for (int i = 0; i < queries.length; i++) {
            try {
                where.put(queries[i], selectionArgs[i]);
            } catch (JSONException e) {
                Log.e(TAG, e.getMessage(), e);
            }
        }

        ReadFilter filter = new ReadFilter();

        filter.setWhere(where);

        return new SingleColumnJsonArrayList(new ArrayList<Presentation>(presentationStore.readWithFilter(filter)));
    }
}
 
开发者ID:secondsun,项目名称:devnexus-android,代码行数:30,代码来源:DevNexusContentProvider.java

示例6: testReadWithFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Test
public void testReadWithFilter() {
    store.save(new Data("foo", "desc of foo"));
    store.save(new Data("bar", "desc of bar"));

    Collection<Data> datas = store.readWithFilter(new ReadFilter());
    Assert.assertNotNull("datas could not be null", datas);
    Assert.assertEquals("datas should 2 data", 2, datas.size());
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:10,代码来源:MemoryStoreTest.java

示例7: testReadWithFilterWhere

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Test
public void testReadWithFilterWhere() throws JSONException {
    store.save(new Data("foo", "desc of foo"));
    store.save(new Data("bar", "desc of bar"));

    ReadFilter filter = new ReadFilter();
    filter.setWhere(new JSONObject("{\"name\":\"bar\"}"));

    Collection<Data> datas = store.readWithFilter(filter);

    Assert.assertNotNull("datas could not be null", datas);
    Assert.assertEquals("datas should 1 data", 1, datas.size());
    Assert.assertEquals("bar", datas.iterator().next().getName());
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:15,代码来源:MemoryStoreTest.java

示例8: testReadWithFilterThrowsExceptionWithNestingJSON

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testReadWithFilterThrowsExceptionWithNestingJSON() throws JSONException {

    ReadFilter filter = new ReadFilter();
    filter.setWhere(new JSONObject("{\"name\":{\"name\":\"bar\"}}"));
    store.readWithFilter(filter);

}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:9,代码来源:MemoryStoreTest.java

示例9: ReadLoader

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
public ReadLoader(Context context, Callback<List<T>> callback,
                  PipeHandler<T> runner, ReadFilter filter, Pipe<T> pipe) {
    super(context, callback);
    this.filter = filter;
    this.runner = runner;
    this.requestingPipe = pipe;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:8,代码来源:ReadLoader.java

示例10: read

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public void read(String idx, Callback<T> callback) {
    ReadFilter filter = new ReadFilter();
    filter.setLinkUri(URI.create(idx));

    int id = Arrays.hashCode(new Object[] { name, filter, callback });
    Bundle bundle = new Bundle();
    bundle.putSerializable(CALLBACK, callback);
    bundle.putSerializable(FILTER, filter);
    bundle.putSerializable(METHOD, Methods.READ_ID);
    manager.initLoader(id, bundle, this);
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:13,代码来源:LoaderAdapter.java

示例11: getHttpProvider

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
private HttpProvider getHttpProvider(ReadFilter filter) {
  if (filter.getLinkUri() == null) {
      return getHttpProvider(parameterProvider.getParameters(filter));
  } else {
      return getHttpProvider(filter.getLinkUri());
  }
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:8,代码来源:RestRunner.java

示例12: getNextFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public ReadFilter getNextFilter(HeaderAndBody result, PageConfig config) {
    ReadFilter filter = new ReadFilter();
    URI nextUri = URI.create(result.getHeader(config.getNextIdentifier()).toString());
    filter.setLinkUri(baseUri.resolve(nextUri));
    return filter;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:8,代码来源:URIPageHeaderParser.java

示例13: getPreviousFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public ReadFilter getPreviousFilter(HeaderAndBody result, PageConfig config) {
    ReadFilter filter = new ReadFilter();
    URI nextUri = URI.create(result.getHeader(config.getPreviousIdentifier()).toString());
    filter.setLinkUri(baseUri.resolve(nextUri));
    return filter;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:8,代码来源:URIPageHeaderParser.java

示例14: getNextFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public ReadFilter getNextFilter(HeaderAndBody result, PageConfig config) {
    ReadFilter filter = new ReadFilter();
    JsonParser parser = new JsonParser();
    JsonElement element = parser.parse(new String(result.getBody()));
    URI nextUri = URI.create(getFromJSON(element, config.getNextIdentifier()));
    filter.setLinkUri(baseUri.resolve(nextUri));
    return filter;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:10,代码来源:URIBodyPageParser.java

示例15: getPreviousFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入依赖的package包/类
@Override
public ReadFilter getPreviousFilter(HeaderAndBody result, PageConfig config) {
    ReadFilter filter = new ReadFilter();
    JsonParser parser = new JsonParser();
    JsonElement element = parser.parse(new String(result.getBody()));
    URI nextUri = URI.create(getFromJSON(element, config.getPreviousIdentifier()));
    filter.setLinkUri(baseUri.resolve(nextUri));
    return filter;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:10,代码来源:URIBodyPageParser.java


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