com.sas.dataselectors.filters
Class AbstractFilterItemSimpleListBase

com.sas.dataselectors.filters.AbstractFilterItemSimpleListBase
All Implemented Interfaces:
SimpleLogicListInterface, java.lang.Iterable, java.util.Collection, java.util.List
Direct Known Subclasses:
FilterItemListToSimpleList, FilterItemRootToAdvancedList, FilterItemRootToSimpleList

public abstract class AbstractFilterItemSimpleListBase
implements SimpleLogicListInterface

This class is abstract implementation to manage a list of test nodes that are created from a filter item. A child class must decide how to populate the list.


Field Summary
protected  FilterItemListInterface _filterItemList
          The filter item list.
protected  java.util.List _filterTestNodeList
          The list of test nodes.
 
Constructor Summary
AbstractFilterItemSimpleListBase(FilterItemListInterface filterItemList)
          Constructor for AbstractFilterItemSimpleListBase.
 
Method Summary
 void add(int index, java.lang.Object element)
          Adds the specified element at the specified position in the list by updating the underlying tree.
 boolean add(java.lang.Object element)
          Ensures that this collection contains the specified element (optional operation).
 boolean addAll(java.util.Collection collection)
          Adds all of the elements in the specified collection to this collection (optional operation).
 boolean addAll(int index, java.util.Collection collection)
          Adds all items from the given collection to this list at the specified index.
protected  void addTestNodeAt(int index, FilterLogicTestNodeInterface testNode)
          Adds the test node to the list at the desired position.
 void clear()
          Removes all of the elements from this collection (optional operation).
abstract  boolean commitChanges()
          Commit any changes to the filter model and apply them to the native model.
 boolean contains(java.lang.Object element)
           
 boolean containsAll(java.util.Collection collection)
          Returns true if this collection contains all of the elements in the specified collection.
 boolean equals(java.lang.Object object)
          Compares the specified object with this collection for equality.
 java.lang.Object get(int index)
          Returns the object at the specified index in the list.
 FilterItemListInterface getFilterItemList()
          The list of source items in the filter model.
abstract  java.lang.Object getRootFilterObject()
          Returns the root filter object in the native model representing the completed filter selection.
protected  java.lang.Object getTestNodeAt(int index)
          Returns the node at the specified index.
 int hashCode()
           
 int indexOf(java.lang.Object object)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object object)
          Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 java.lang.Object remove(int index)
          Removes the object at the specified index from the list.
 boolean remove(java.lang.Object object)
          Removes a single instance of the specified element from this collection, if it is present (optional operation).
 boolean removeAll(java.util.Collection collection)
          Removes all this collection's elements that are also contained in the specified collection (optional operation).
protected  java.lang.Object removeTestNodeAt(int index)
          Removes the node at the specified index of the list.
 boolean retainAll(java.util.Collection p1)
          Retains only the elements in this collection that are contained in the specified collection (optional operation).
 java.lang.Object set(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list by updating the underlying tree.
protected  java.lang.Object setTestNodeAt(int index, FilterLogicTestNodeInterface testNode)
          Assigns the test node to the list at the specified position.
 int size()
           
 java.util.List subList(int startIndex, int endIndex)
          This method would produce a sublist of this list if it were supported.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] p1)
          Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 

Field Detail

_filterTestNodeList

protected java.util.List _filterTestNodeList
The list of test nodes.


_filterItemList

protected FilterItemListInterface _filterItemList
The filter item list.

Constructor Detail

AbstractFilterItemSimpleListBase

public AbstractFilterItemSimpleListBase(FilterItemListInterface filterItemList)
Constructor for AbstractFilterItemSimpleListBase. Because this class is abstract, the constructor can only be used by sub-classes.

Parameters:
filterItemList - the source list of filter items
Method Detail

commitChanges

public abstract boolean commitChanges()
Commit any changes to the filter model and apply them to the native model.

Specified by:
commitChanges in interface SimpleLogicListInterface
Returns:
true if everything succeeded

getRootFilterObject

public abstract java.lang.Object getRootFilterObject()
Description copied from interface: SimpleLogicListInterface
Returns the root filter object in the native model representing the completed filter selection. This method should be called after using the commitChanges() method to construct the native filter.

Specified by:
getRootFilterObject in interface SimpleLogicListInterface
Returns:
the root filter object (a single filter item or a List)
Throws:
java.lang.UnsupportedOperationException - if this is not the case

getFilterItemList

public FilterItemListInterface getFilterItemList()
The list of source items in the filter model.

Specified by:
getFilterItemList in interface SimpleLogicListInterface
Returns:
the filter item list

setTestNodeAt

protected java.lang.Object setTestNodeAt(int index,
                                         FilterLogicTestNodeInterface testNode)
Assigns the test node to the list at the specified position.

Parameters:
index - the index in the list of nodes
testNode - the node to set on the list
Returns:
the node previously assigned to that position

addTestNodeAt

protected void addTestNodeAt(int index,
                             FilterLogicTestNodeInterface testNode)
Adds the test node to the list at the desired position.

Parameters:
index - the index in the list of nodes
testNode - the node to add to the list

removeTestNodeAt

protected java.lang.Object removeTestNodeAt(int index)
Removes the node at the specified index of the list.

Parameters:
index - the index of the node to remove
Returns:
the node at the specified index

getTestNodeAt

protected java.lang.Object getTestNodeAt(int index)
Returns the node at the specified index.

Parameters:
index - the index of the node
Returns:
the node at the specified index

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Inserts the specified element at the specified position in this list by updating the underlying tree.

Specified by:
set in interface java.util.List
Parameters:
index - the index for the element
element - the element to assign to the list
Returns:
the object previously assigned to the list at the specified index
See Also:
List.set(int, Object)

add

public void add(int index,
                java.lang.Object element)
Adds the specified element at the specified position in the list by updating the underlying tree.

Specified by:
add in interface java.util.List
Parameters:
index - the index for the element
element - the element to add to the list
See Also:
List.add(int, Object)

remove

public java.lang.Object remove(int index)
Removes the object at the specified index from the list.

Specified by:
remove in interface java.util.List
Parameters:
index - the index of the object
Returns:
the object removed

get

public java.lang.Object get(int index)
Returns the object at the specified index in the list.

Specified by:
get in interface java.util.List
Parameters:
index - the index of the object
Returns:
the object at the given index

addAll

public boolean addAll(int index,
                      java.util.Collection collection)
Adds all items from the given collection to this list at the specified index.

Specified by:
addAll in interface java.util.List
Parameters:
index - the index in this list to begin inserting elements at
collection - the collection of elements to add to this list
Returns:
TRUE if elements were added to this list

containsAll

public boolean containsAll(java.util.Collection collection)
Returns true if this collection contains all of the elements in the specified collection.

Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.List
Parameters:
collection - the collection to be checked for containment in this collection.
Returns:
true if this collection contains all of the elements in the specified collection
Throws:
java.lang.NullPointerException - if the specified collection is null.
See Also:
Collection.containsAll(Collection)

removeAll

public boolean removeAll(java.util.Collection collection)
Removes all this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List
Parameters:
collection - the elements to be removed from this collection.
Returns:
true if this collection changed as a result of the call
Throws:
java.lang.NullPointerException - if the specified collection is null.
See Also:
Collection.remove(Object), Collection.contains(Object), Collection.removeAll(Collection)

remove

public boolean remove(java.lang.Object object)
Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Parameters:
object - the element to be removed from this collection, if present.
Returns:
true if this collection changed as a result of the call
See Also:
Collection.remove(Object)

add

public boolean add(java.lang.Object element)
Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Parameters:
element - the element whose presence in this collection is to be ensured.
Returns:
true if this collection changed as a result of the call
See Also:
Collection.add(Object)

clear

public void clear()
Removes all of the elements from this collection (optional operation). This collection will be empty after this method returns unless it throws an exception.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
See Also:
Collection.clear()

contains

public boolean contains(java.lang.Object element)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List
Parameters:
element - the element to search for
Returns:
TRUE if this collection contains the given element
See Also:
Collection.contains(Object)

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.List
Returns:
an Iterator for this collection
See Also:
Collection.iterator()

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List
Returns:
a ListIterator for this collection
See Also:
List.listIterator()

listIterator

public java.util.ListIterator listIterator(int index)
Specified by:
listIterator in interface java.util.List
Parameters:
index - the initial position for the new iterator
Returns:
a ListIterator for this collection
See Also:
List.listIterator(int)

retainAll

public boolean retainAll(java.util.Collection p1)
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List
Parameters:
c - elements to be retained in this collection.
Returns:
true if this collection changed as a result of the call
Throws:
java.lang.NullPointerException - if the specified collection is null.
See Also:
remove(Object), contains(Object), Collection.retainAll(Collection)

addAll

public boolean addAll(java.util.Collection collection)
Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Parameters:
c - elements to be inserted into this collection.
Returns:
true if this collection changed as a result of the call
See Also:
add(Object), Collection.addAll(Collection)

subList

public java.util.List subList(int startIndex,
                              int endIndex)
This method would produce a sublist of this list if it were supported.

Specified by:
subList in interface java.util.List
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toIndex - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within this list.
Throws:
java.lang.UnsupportedOperationException - because the method is not supported by this list at this time.

indexOf

public int indexOf(java.lang.Object object)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Specified by:
indexOf in interface java.util.List
Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
See Also:
List.indexOf(Object)

lastIndexOf

public int lastIndexOf(java.lang.Object object)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Specified by:
lastIndexOf in interface java.util.List
Parameters:
o - element to search for.
Returns:
the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.

equals

public boolean equals(java.lang.Object object)
Compares the specified object with this collection for equality.

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class java.lang.Object
Parameters:
o - Object to be compared for equality with this collection.
Returns:
true if the specified object is equal to this collection
See Also:
Object.equals(Object), Set.equals(Object), List.equals(Object), Collection.equals(Object)

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this collection
See Also:
Object.hashCode()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List
Returns:
TRUE if this collection contains no elements, FALSE otherwise
See Also:
Collection.isEmpty()

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Returns:
the number of elements in this collection
See Also:
Collection.size()

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Returns:
an array representation of the contents of this collection
See Also:
Collection.toArray()

toArray

public java.lang.Object[] toArray(java.lang.Object[] p1)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Parameters:
a - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this collection
Throws:
java.lang.ArrayStoreException - the runtime type of the specified array is not a supertype of the runtime type of every element in this collection.
java.lang.NullPointerException - if the specified array is null.
See Also:
Collection.toArray(Object[])



Copyright © 2009 SAS Institute Inc. All Rights Reserved.