/** * Add a filter to end of the filter list. */ public void addFilter(Filter<E> newFilter) { filterList.add(newFilter); }
/** * Attach an appender. If the appender is already in the list in won't be * added again. */ public void addAppender(Appender<E> newAppender) { if (newAppender == null) { throw new IllegalArgumentException("Null argument disallowed"); } appenderList.addIfAbsent(newAppender); }
/** * Clear the filter chain */ public void clearAllFilters() { filterList.clear(); }
private void refreshCopyIfNecessary() { if (!isFresh()) { refreshCopy(); } }
@Override public void add(int index, E element) { underlyingList.add(index, element); markAsStale(); }
@SuppressWarnings("unchecked") @Override public <T> T[] toArray(T[] a) { refreshCopyIfNecessary(); return (T[]) ourCopy; }
/** * Call the <code>doAppend</code> method on all attached appenders. */ public int appendLoopOnAppenders(E e) { int size = 0; final Appender<E>[] appenderArray = appenderList.asTypedArray(); final int len = appenderArray.length; for (int i = 0; i < len; i++) { appenderArray[i].doAppend(e); size++; } return size; }
@Test public void basicToArrayTyped() { cowaList.add(1); Integer[] result = cowaList.asTypedArray(); assertArrayEquals(new Integer[] { 1 }, result); }
/** * Remove the appender passed as parameter form the list of attached * appenders. */ public boolean detachAppender(Appender<E> appender) { if (appender == null) { return false; } boolean result; result = appenderList.remove(appender); return result; }
/** * Get all attached appenders as an Enumeration. If there are no attached * appenders <code>null</code> is returned. * * @return Iterator An iterator of attached appenders. */ public Iterator<Appender<E>> iteratorForAppenders() { return appenderList.iterator(); }
@Override public boolean add(E e) { boolean result = underlyingList.add(e); markAsStale(); return result; }
private void refreshCopyIfNecessary() { if (!isFresh()) { refreshCopy(); } }
@Override public Object[] toArray() { refreshCopyIfNecessary(); return ourCopy; }
/** * Call the <code>doAppend</code> method on all attached appenders. */ public int appendLoopOnAppenders(E e) { int size = 0; final Appender<E>[] appenderArray = appenderList.asTypedArray(); final int len = appenderArray.length; for (int i = 0; i < len; i++) { appenderArray[i].doAppend(e); size++; } return size; }
/** * Remove the appender passed as parameter form the list of attached * appenders. */ public boolean detachAppender(Appender<E> appender) { if (appender == null) { return false; } boolean result; result = appenderList.remove(appender); return result; }
/** * Get all attached appenders as an Enumeration. If there are no attached * appenders <code>null</code> is returned. * * @return Iterator An iterator of attached appenders. */ public Iterator<Appender<E>> iteratorForAppenders() { return appenderList.iterator(); }
@Override public boolean remove(Object o) { boolean result = underlyingList.remove(o); markAsStale(); return result; }
private void refreshCopyIfNecessary() { if (!isFresh()) { refreshCopy(); } }