PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/google/appengine/datanucleus/query/StreamingMergeJoinResult.java

http://datanucleus-appengine.googlecode.com/
Java | 77 lines | 36 code | 12 blank | 29 comment | 1 complexity | 04ebf8e23985ed6fe405dbfaaffc0d91 MD5 | raw file
 1/**********************************************************************
 2Copyright (c) 2009 Google Inc.
 3
 4Licensed under the Apache License, Version 2.0 (the "License");
 5you may not use this file except in compliance with the License.
 6You may obtain a copy of the License at
 7
 8http://www.apache.org/licenses/LICENSE-2.0
 9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15**********************************************************************/
16package com.google.appengine.datanucleus.query;
17
18import com.google.appengine.api.datastore.Entity;
19
20import com.google.appengine.datanucleus.Utils;
21
22import java.util.AbstractList;
23import java.util.Iterator;
24import java.util.ListIterator;
25import java.util.NoSuchElementException;
26
27/**
28 * An {@link AbstractList} implementation that streams merge join entity results.
29 *
30 * @author Max Ross <maxr@google.com>
31 */
32class StreamingMergeJoinResult extends AbstractList<Entity> {
33
34  /** Delegate for lazy loading of results. */
35  private final LazyResult<Entity> lazyResult;
36
37  /**
38   * Constructs a StreamingMergeJoinResult.
39   * @param lazyEntities The result of the query.
40   */
41  public StreamingMergeJoinResult(Iterable<Entity> lazyEntities) {
42    this.lazyResult = new LazyResult<Entity>(lazyEntities, Utils.<Entity>identity(), false);
43  }
44
45  @Override
46  public boolean equals(Object o) {
47    return this == o;
48  }
49
50  @Override
51  public Entity get(int index) {
52    return lazyResult.get(index);
53  }
54
55  /**
56   * @throws NoSuchElementException if there are no more elements
57   * to resolve.
58   */
59  void resolveNext() {
60    lazyResult.resolveNext();
61  }
62
63  @Override
64  public Iterator<Entity> iterator() {
65    return lazyResult.listIterator();
66  }
67
68  @Override
69  public ListIterator<Entity> listIterator() {
70    return lazyResult.listIterator();
71  }
72
73  @Override
74  public int size() {
75    return lazyResult.size();
76  }
77}