org.tinyjee.maven.dim.utils
Class SelectableArrayList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by org.tinyjee.maven.dim.utils.SelectableArrayList<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess
Direct Known Subclasses:
AbstractSelectableJavaEntitiesList

public class SelectableArrayList<E>
extends ArrayList<E>

Implements an array list that allows sub-list selections via regular expressions and / or selectors.

Author:
Juergen_Kellerer, 2011-10-09
See Also:
Serialized Form

Nested Class Summary
static interface SelectableArrayList.Selector<E>
          Defines a selector to be used when selecting a sub-list.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SelectableArrayList()
           
SelectableArrayList(Collection<? extends E> collection)
           
SelectableArrayList(int initialCapacity)
           
 
Method Summary
 SelectableArrayList<E> clone()
           
 SelectableArrayList.Selector<E> createInvertSelector(SelectableArrayList.Selector<E> other)
          Creates a selector that inverts the given selector.
 SelectableArrayList.Selector<E> createOrSelector(SelectableArrayList.Selector<E>... selectors)
          Creates a selector that combines the given selectors with OR (accepts the element if one of the given selectors accepts it).
 SelectableArrayList.Selector<E> createRegularExpressionSelector(String regularExpression)
          Creates a selector that matches the given regular expression against the string representation of the element to select.
 SelectableArrayList<E> select(SelectableArrayList.Selector<E> selector)
          Selects a sub list of all elements that were matched by the given selector.
 SelectableArrayList<E> selectMatching(String... regularExpressions)
          Selects all elements whose string representation matches the one of given regular expressions.
 SelectableArrayList<E> selectMatching(String regularExpression)
          Selects all elements whose string representation matches the given regular expression.
 SelectableArrayList<E> selectNonMatching(String regularExpression)
          Selects all elements whose string representation does NOT match the given regular expression.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

SelectableArrayList

public SelectableArrayList()

SelectableArrayList

public SelectableArrayList(int initialCapacity)

SelectableArrayList

public SelectableArrayList(Collection<? extends E> collection)
Method Detail

clone

public SelectableArrayList<E> clone()
Overrides:
clone in class ArrayList<E>

select

public SelectableArrayList<E> select(SelectableArrayList.Selector<E> selector)
Selects a sub list of all elements that were matched by the given selector.

Parameters:
selector - the selector to use for matching the elements.
Returns:
a sub list of matched elements.

selectMatching

public SelectableArrayList<E> selectMatching(String regularExpression)
Selects all elements whose string representation matches the given regular expression.

Parameters:
regularExpression - the regular expression to match.
Returns:
A sub list of all elements that match the given regular expression.

selectMatching

public SelectableArrayList<E> selectMatching(String... regularExpressions)
Selects all elements whose string representation matches the one of given regular expressions.

Parameters:
regularExpressions - the regular expressions to match using OR.
Returns:
A sub list of all elements that matches one of the given regular expressions.

selectNonMatching

public SelectableArrayList<E> selectNonMatching(String regularExpression)
Selects all elements whose string representation does NOT match the given regular expression.

Parameters:
regularExpression - the regular expression to match.
Returns:
A sub list of all elements that do NOT match the given regular expression.

createOrSelector

public SelectableArrayList.Selector<E> createOrSelector(SelectableArrayList.Selector<E>... selectors)
Creates a selector that combines the given selectors with OR (accepts the element if one of the given selectors accepts it).

Parameters:
selectors - the selectors that match the actual content.
Returns:
a selector that combines the given selectors with OR.

createInvertSelector

public SelectableArrayList.Selector<E> createInvertSelector(SelectableArrayList.Selector<E> other)
Creates a selector that inverts the given selector.

Parameters:
other - the selector to invert.
Returns:
a selector that inverts the given selector.

createRegularExpressionSelector

public SelectableArrayList.Selector<E> createRegularExpressionSelector(String regularExpression)
Creates a selector that matches the given regular expression against the string representation of the element to select.

Parameters:
regularExpression - the regular expression to use for selecting.
Returns:
a selector that matches the given regular expression against the string representation of the element to select.