com.sas.dataselectors.filters
Class AbstractSimpleLogicListAdapterBase

com.sas.dataselectors.filters.AbstractSimpleLogicListAdapterBase
All Implemented Interfaces:
FilterLogicListInterface, SimpleLogicListAdapterInterface, SimpleLogicListInterface, java.lang.Iterable, java.util.Collection, java.util.List
Direct Known Subclasses:
BusinessModelFilterItemToAdvancedLogicListAdapter, BusinessQueryFilterItemToSimpleLogicListAdapter, InformationMapFilterItemToSimpleLogicListAdapter

public abstract class AbstractSimpleLogicListAdapterBase
implements java.util.List, SimpleLogicListAdapterInterface

This class extends a filter logic list implementation to provide a base for SimpleLogicListAdapterInterface implementations adding convenient access to a filter's logic as a flat list of logic test nodes.


Field Summary
protected  FilterItemListInterface _filterItemList
           
protected  SimpleLogicListInterface _filterItemSimpleList
           
 
Constructor Summary
AbstractSimpleLogicListAdapterBase()
          Constructor for AbstractSimpleLogicListAdapterBase.
 
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.
 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 element)
          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.
 java.util.List getFilterList()
          Returns the list of filters.
 FilterLogicListInterface getFilterLogicList()
          Returns a FilterLogicListInterface that is the head of the test node list
 java.lang.Object getRootFilterObject()
          Returns the native filter object.
 int hashCode()
           
 int indexOf(java.lang.Object element)
          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 element)
          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 element)
          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).
 boolean retainAll(java.util.Collection collection)
          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.
 void setFilterItemList(FilterItemListInterface filterItemList)
          Sets the filter item list for this adapter.
 void setFilterList(java.util.List values)
          Sets the list of filters.
 void setFilterList(SimpleLogicListInterface model)
          Sets the model containing the list of filters.
 int size()
           
 java.util.List subList(int startIndex, int endIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 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.
 
Methods inherited from class com.sas.dataselectors.filters.DefaultFilterLogicList
getFilterListDescription, getFilterListLabel, setFilterListDescription, setFilterListLabel, toString
 

Field Detail

_filterItemSimpleList

protected SimpleLogicListInterface _filterItemSimpleList

_filterItemList

protected FilterItemListInterface _filterItemList
Constructor Detail

AbstractSimpleLogicListAdapterBase

public AbstractSimpleLogicListAdapterBase()
Constructor for AbstractSimpleLogicListAdapterBase. Because this class is abstract, the constructor may only be called from sub-classes.

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

getFilterLogicList

public FilterLogicListInterface getFilterLogicList()
Returns a FilterLogicListInterface that is the head of the test node list

Specified by:
getFilterLogicList in interface SimpleLogicListAdapterInterface
Returns:
FilterLogicListInterface
See Also:
DefaultFilterLogicList

getFilterItemList

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

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

setFilterItemList

public void setFilterItemList(FilterItemListInterface filterItemList)
Sets the filter item list for this adapter.

Parameters:
filterItemList - the new filter item list

getFilterList

public java.util.List getFilterList()
Returns the list of filters.

Specified by:
getFilterList in interface FilterLogicListInterface
Overrides:
getFilterList in class DefaultFilterLogicList
Returns:
the list of filters

setFilterList

public void setFilterList(SimpleLogicListInterface model)
Sets the model containing the list of filters.

Parameters:
model - the new filter list model

setFilterList

public void setFilterList(java.util.List values)
Sets the list of filters.

Overrides:
setFilterList in class DefaultFilterLogicList
Parameters:
values - the new filter list

getRootFilterObject

public java.lang.Object getRootFilterObject()
Returns the native filter object.

Specified by:
getRootFilterObject in interface SimpleLogicListInterface
Returns:
the root filter object (a single filter item or a List)

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
Overrides:
clear in class DefaultFilterLogicList
See Also:
Collection.clear()

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
Overrides:
add in class DefaultFilterLogicList
Parameters:
index - the index for the element
element - the element to add to the list
See Also:
List.add(int, Object)

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
Overrides:
set in class DefaultFilterLogicList
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)

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
Overrides:
remove in class DefaultFilterLogicList
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
Overrides:
get in class DefaultFilterLogicList
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
Overrides:
addAll in class DefaultFilterLogicList
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
Overrides:
containsAll in class DefaultFilterLogicList
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
Overrides:
removeAll in class DefaultFilterLogicList
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 element)
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
Overrides:
remove in class DefaultFilterLogicList
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
Overrides:
add in class DefaultFilterLogicList
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)

retainAll

public boolean retainAll(java.util.Collection collection)
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
Overrides:
retainAll in class DefaultFilterLogicList
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
Overrides:
addAll in class DefaultFilterLogicList
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)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Specified by:
subList in interface java.util.List
Overrides:
subList in class DefaultFilterLogicList
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.IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex).
See Also:
List.subList(int, int)

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
Overrides:
iterator in class DefaultFilterLogicList
Returns:
an Iterator for this collection
See Also:
Collection.iterator()

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class DefaultFilterLogicList
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
Overrides:
listIterator in class DefaultFilterLogicList
Parameters:
index - the initial position for the new iterator
Returns:
a ListIterator for this collection
See Also:
List.listIterator(int)

contains

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

indexOf

public int indexOf(java.lang.Object element)
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
Overrides:
indexOf in class DefaultFilterLogicList
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)

equals

public boolean equals(java.lang.Object element)
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 DefaultFilterLogicList
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)

isEmpty

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

lastIndexOf

public int lastIndexOf(java.lang.Object element)
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
Overrides:
lastIndexOf in class DefaultFilterLogicList
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.

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Overrides:
size in class DefaultFilterLogicList
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
Overrides:
toArray in class DefaultFilterLogicList
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
Overrides:
toArray in class DefaultFilterLogicList
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[])

hashCode

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



Copyright © 2009 SAS Institute Inc. All Rights Reserved.