コード例 #1
0
  @Override
  public int size() {
    if (size_ != -1) {
      return size_;
    }
    if (invalid_) {
      return 0;
    }

    try {
      if (searchQuery_ == null || searchQuery_.isEmpty()) {
        ViewNavigator nav = getNavigator();
        size_ = nav == null ? 0 : nav.getCount();
      } else {
        ViewEntryCollection vec = getEntries();
        size_ = vec == null ? 0 : vec.getCount();
      }
    } catch (Exception e) {
      throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
    }
    return size_;
  }
コード例 #2
0
  /* **********************************************************************
   * List methods
   ************************************************************************/
  @Override
  @SuppressWarnings("deprecation")
  public E get(final int index) {
    if (invalid_) {
      return null;
    }

    Map<Integer, E> cache = getCache();
    if (!cache.containsKey(index)) {
      try {
        if (searchQuery_ == null || searchQuery_.isEmpty()) {
          ViewNavigator nav = getNavigator();

          // getNth is top-level only, so let's skip to what we need
          int lastFetchedIndex = 0;
          Map<String, Object> requestScope = getRequestScope();
          String key = "lastFetchedIndex-" + toString();
          if (requestScope.containsKey(key)) {
            lastFetchedIndex = (Integer) requestScope.get(key);
          }
          nav.skip(index - lastFetchedIndex);

          requestScope.put(key, index);

          try {
            // Try to get the current one, which may be null due to an as-yet-unsolved
            // "object has been removed or recycled" error. Check for that and switch to
            // our exception handler to retry
            ViewEntry entry = nav.getCurrent();
            if (entry == null) {
              throw new NullPointerException();
            }
            cache.put(index, createFromViewEntry(entry, columnInfo_));
          } catch (NullPointerException npe) {
            // Then we've probably hit an "Object has been removed or recycled" on the nav

            if (reset_ < 10) {
              reset_++;
              clearCache();
              return get(index);
            }

            System.out.println("=============================== NPE in DominoModelList");
            System.out.println(
                "=============================== Current class: " + getClass().getName());
            System.out.println("=============================== Type: " + getClazz().getName());
            System.out.println("=============================== Desired index: " + index);
            System.out.println("=============================== Current cache: " + cache);
            System.out.println("=============================== Current reported size: " + size());
            throw npe;
          } catch (RuntimeException re) {
            if (String.valueOf(re.getCause()).contains("Argument has been removed or recycled")) {
              if (reset_ < 10) {
                reset_++;
                clearCache();
                return get(index);
              }
            }
            // Otherwise, throw it up
            throw re;
          }
        } else {
          ViewEntryCollection vec = getEntries();
          cache.put(index, createFromViewEntry(vec.getNthEntry(index + 1), columnInfo_));
        }
      } catch (Exception e) {
        throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
      }
    }
    return cache.get(index);
  }
コード例 #3
0
 @Override
 public void stampAll(final String propertyName, final Object value) {
   ViewEntryCollection vec = getEntries();
   vec.stampAll(propertyName, value);
 }