@Override public boolean add(ITEM e) { if ( ! permitAddAfterFreeze) throwIfFrozen(); return super.add(e); }
@Override public boolean remove(Object o) { throwIfFrozen(); return super.remove(o); }
@Override public boolean addAll(Collection<? extends ITEM> a) { if ( ! permitAddAfterFreeze) throwIfFrozen(); return super.addAll(a); }
public HitGroup clone() { HitGroup hitGroupClone = (HitGroup) super.clone(); hitGroupClone.hits = new ListenableArrayList<>(this.hits.size()); hitGroupClone.unmodifiableHits = Collections.unmodifiableList(hitGroupClone.hits); for (Iterator<Hit> i = this.hits.iterator(); i.hasNext();) { Hit hitClone = i.next().clone(); hitGroupClone.hits.add(hitClone); } if (this.errorHit!=null) { // Find the cloned error and assign it for (Hit hit : hitGroupClone.asList()) { if (hit instanceof DefaultErrorHit) hitGroupClone.errorHit=(DefaultErrorHit)hit; } } if (this.getFilledInternal()!=null) { hitGroupClone.setFilledInternal(new HashSet<>(this.getFilledInternal())); } return hitGroupClone; }
@Override public ITEM set(int index, ITEM e) { throwIfFrozen(); return super.set(index, e); }
@Override public ITEM set(int index, ITEM e) { ITEM result = super.set(index, e); notifyListeners(); return result; }
/** * Remove the first <code>offset</code> <i>concrete</i> hits in this group, * and hits beyond <code>offset+numHits</code> */ public void trim(int offset, int numHits) { updateHits(); ensureSorted(); int highBound = numHits + offset; // Largest offset +1 int currentIndex = -1; for (Iterator<Hit> i = hits.iterator(); i.hasNext();) { Hit hit = i.next(); if (hit.isAuxiliary()) continue; currentIndex++; if (currentIndex < offset || currentIndex >= highBound) { i.remove(); handleRemovedHit(hit); } } }
@Override public void addDataListener(Runnable runnable) { hits.addListener(runnable); }
@Override public void clear() { throwIfFrozen(); super.clear(); }
/** * Returns the hit at the given (0-base) index in this group of hit * (without searching any subgroups). * * @param index the index into this list * @throws IndexOutOfBoundsException if there is no hit at the given index */ public Hit get(int index) { updateHits(); ensureSorted(); return hits.get(index); }
/** * Inserts the given hit at the specified index in this group. */ public void set(int index, Hit hit) { updateHits(); if (hit instanceof ErrorHit) { // Merge instead add(hit); return; } handleNewHit(hit); Hit oldHit = hits.set(index, hit); if (oldHit!=null) handleRemovedHit(oldHit); }
@Override public boolean addAll(Collection<? extends ITEM> a) { boolean result = super.addAll(a); notifyListeners(); return result; }
/** * Removes a hit from this group or any subgroup. * * @param uri the uri of the hit to remove. * @return the hit removed, or null if not found. */ public Hit remove(URI uri) { for (Iterator<Hit> it = hits.iterator(); it.hasNext(); ) { Hit hit = it.next(); if (uri.equals(hit.getId())) { it.remove(); handleRemovedHit(hit); return hit; } else if (hit instanceof HitGroup) { Hit removed = ((HitGroup)hit).remove(uri); if (removed != null) { return removed; } } } return null; }
@Override public void add(int index, ITEM e) { throwIfFrozen(); super.add(index, e); }
@Override public ITEM remove(int index) { throwIfFrozen(); return super.remove(index); }
@Override public boolean add(ITEM e) { boolean result = super.add(e); notifyListeners(); return result; }
@Override public boolean addAll(int index, Collection<? extends ITEM> a) { throwIfFrozen(); return super.addAll(index, a); }
/** * Adds a hit to this group in the specified index, * all existing hits on this index and higher will have their index increased by one. * * <b>Note:</b> If the group was sorted, it will still be considered sorted after this call. */ public void add(int index, Hit hit) { if (hit instanceof ErrorHit) { // Merge instead add(hit); return; } boolean wasSorted = hitsSorted; handleNewHit(hit); hits.add(index, hit); hitsSorted = wasSorted; }
/** * Removes a hit from this group (not considering the hits of any subgroup) * * @param index the position of the hit to remove * @return the hit removed * @throws IndexOutOfBoundsException if there is no hit at the given position */ public Hit remove(int index) { updateHits(); Hit hit = hits.remove(index); handleRemovedHit(hit); return hit; }
@Override public void add(int index, ITEM e) { super.add(index, e); notifyListeners(); }