コード例 #1
0
 @Override
 public void expandRow(final String rowPosition) {
   ViewNavigator nav = getNewNavigator();
   nav.gotoPos(rowPosition, '.');
   ViewEntry current = nav.getCurrent();
   int noteId = new BigInteger(current.getNoteID(), 16).intValue();
   collapsedIds_.remove(noteId);
   expandedIds_.add(noteId);
   clearCache();
 }
コード例 #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);
  }