com.sas.dataselectors.filters.tree
Class SimpleFilterLogicTree

com.sas.dataselectors.filters.tree.SimpleFilterLogicTree
All Implemented Interfaces:
FilterLogicListInterface, FilterLogicTreeInterface, SimpleFilterLogicInterface, java.io.Serializable, javax.swing.tree.TreeModel

public class SimpleFilterLogicTree
implements SimpleFilterLogicInterface

See Also:
Serialized Form

Field Summary
protected  java.lang.String description
           
protected  java.lang.String label
           
protected  java.util.List testNodes
           
 
Fields inherited from class com.sas.dataselectors.filters.DefaultFilterLogicTree
DEBUG, markGroups, modifiable, modified
 
Fields inherited from interface com.sas.dataselectors.filters.SimpleFilterLogicInterface
ADD_AT_END
 
Constructor Summary
SimpleFilterLogicTree()
           
SimpleFilterLogicTree(FilterLogicBaseNodeInterface root)
           
SimpleFilterLogicTree(FilterLogicBaseNodeInterface root, boolean standardize)
           
SimpleFilterLogicTree(FilterLogicTreeInterface otherTree)
           
 
Method Summary
 boolean addLeaf(int index, FilterLogicTestNodeInterface testNode)
          Add a new test node at the given index in the list of understood test nodes.
 boolean canGroupLeaves(int startIndex, int endIndex)
          Returns TRUE if the leaves (or the groups they're members of) at the given indices can be grouped together.
 FilterLogicTreeInterface copy()
           
 ConditionalRelationType getConditionalRelationType(int index)
          Gets the logical relationship between the leaf at the given index and the leaf at the next index.
 java.util.List getFilterList()
          Returns the list of filter test nodes.
 java.lang.String getFilterListDescription()
          Returns the description for this logic list.
 java.lang.String getFilterListLabel()
          Returns the label for this logic list.
 FilterLogicTestNodeInterface getLeaf(int i)
           
 int getLeafCount()
           
 FilterLogicBaseNodeInterface getNodeByIndex(int index)
           
 boolean groupLeaves(int startIndex, int endIndex)
          Groups the leaves (including any groups they are members of) at the specified locations together (along with any nodes in between them).
 boolean isLeafGrouped(int index)
          Returns TRUE if the leaf at the given index is part of a group.
 boolean isLeafNegated(int index)
          Returns TRUE if the leaf at the given index has been negated, FALSE otherwise.
 boolean moveLeafDown(int index)
          Moves the leaf at the given index down a position in the list of leaves.
 boolean moveLeafUp(int index)
          Moves the leaf at the given index up a position in the list of leaves.
 void refreshFilterList()
          Refreshes the list of leaf nodes in the tree.
 FilterLogicTestNodeInterface removeLeaf(int index)
          Removes the test node at the given index.
 void setConditionalRelationType(int index, ConditionalRelationType value)
          Sets the logical relationship between the leaf at the given index and the leaf at the next index.
 void setFilterListDescription(java.lang.String value)
           
 void setFilterListLabel(java.lang.String value)
           
 boolean setFilterObject(java.lang.Object filterObject)
          Transforms the given filter object (from the native filter model) into a network of filter logic nodes used to represent the filter within the filter selector model.
 FilterLogicTestNodeInterface setLeaf(int index, FilterLogicTestNodeInterface testNode)
          Sets the test node at the given index in the list of understood test nodes.
 void setLeafNegated(int index, boolean value)
          Sets the negation flag for the leaf at the given index.
 boolean splitOnMember(int indexOfMember)
          Splits the inner-most group containing the leaf at the specified index.
 java.lang.String toString()
           
 
Methods inherited from class com.sas.dataselectors.filters.DefaultFilterLogicTree
add, applyAdd, applyAnd, applyDelete, applyGroup, applyMoveDown, applyMoveUp, applyNot, applyOr, applySplit, canGroup, canMoveDown, canMoveDown, canMoveUp, canMoveUp, canSplit, clear, copyChildren, destroy, getConditionalRelationType, getMutableTreeNode, getOuterMostGroupRoot, getQueryStandardization, group, insertNodeInto, isGrouped, isModifiable, isModified, isNegated, moveDown, moveUp, negate, newLogicalConditionNode, newLogicalConditionNode, newNotNode, printTree, removeNode, replaceNode, setModifiable, setNegated, setQueryStandardization, setRoot, split
 
Methods inherited from interface com.sas.dataselectors.filters.SimpleFilterLogicInterface
clear, isModifiable, isModified
 

Field Detail

testNodes

protected java.util.List testNodes

label

protected java.lang.String label

description

protected java.lang.String description
Constructor Detail

SimpleFilterLogicTree

public SimpleFilterLogicTree()

SimpleFilterLogicTree

public SimpleFilterLogicTree(FilterLogicBaseNodeInterface root)
Parameters:
root -

SimpleFilterLogicTree

public SimpleFilterLogicTree(FilterLogicBaseNodeInterface root,
                             boolean standardize)

SimpleFilterLogicTree

public SimpleFilterLogicTree(FilterLogicTreeInterface otherTree)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getFilterListLabel

public java.lang.String getFilterListLabel()
Description copied from interface: FilterLogicListInterface
Returns the label for this logic list.

Specified by:
getFilterListLabel in interface FilterLogicListInterface
Returns:
the label for this list

setFilterListLabel

public void setFilterListLabel(java.lang.String value)

getFilterListDescription

public java.lang.String getFilterListDescription()
Description copied from interface: FilterLogicListInterface
Returns the description for this logic list.

Specified by:
getFilterListDescription in interface FilterLogicListInterface
Returns:
the description for this list

setFilterListDescription

public void setFilterListDescription(java.lang.String value)

getNodeByIndex

public FilterLogicBaseNodeInterface getNodeByIndex(int index)

isLeafGrouped

public boolean isLeafGrouped(int index)
Returns TRUE if the leaf at the given index is part of a group.

Specified by:
isLeafGrouped in interface SimpleFilterLogicInterface
Parameters:
index - the index in the list of understood nodes of the leaf to check
Returns:
boolean TRUE if the leaf is part of a group, FALSE otherwise.

removeLeaf

public FilterLogicTestNodeInterface removeLeaf(int index)
Removes the test node at the given index.

Specified by:
removeLeaf in interface SimpleFilterLogicInterface
Parameters:
index - the index of the test node, in the list of understood nodes, to be removed
Returns:
the removed node closest to the top of the tree

setConditionalRelationType

public void setConditionalRelationType(int index,
                                       ConditionalRelationType value)
Sets the logical relationship between the leaf at the given index and the leaf at the next index. Valid values are "AND" and "OR".

Specified by:
setConditionalRelationType in interface SimpleFilterLogicInterface
Parameters:
index - the index of the first leaf in the pair
value - the logical condition

getConditionalRelationType

public ConditionalRelationType getConditionalRelationType(int index)
Description copied from interface: SimpleFilterLogicInterface
Gets the logical relationship between the leaf at the given index and the leaf at the next index.

Specified by:
getConditionalRelationType in interface SimpleFilterLogicInterface
Parameters:
index - the index of the first leaf in the pair
Returns:
null if there is no relationship assigned, or a ConditionalRelationType instance defining the relationship.

refreshFilterList

public void refreshFilterList()
Refreshes the list of leaf nodes in the tree.

Specified by:
refreshFilterList in interface SimpleFilterLogicInterface

getFilterList

public java.util.List getFilterList()
Description copied from interface: FilterLogicListInterface
Returns the list of filter test nodes.

Specified by:
getFilterList in interface FilterLogicListInterface
Returns:
the list of FilterLogicTestNodeInterface objects

setLeafNegated

public void setLeafNegated(int index,
                           boolean value)
Sets the negation flag for the leaf at the given index. If the leaf is part of a group, the entire group's negation value will be modified.

Specified by:
setLeafNegated in interface SimpleFilterLogicInterface
Parameters:
index - the index of the leaf to modify
value - the new value for the negation flag for that leaf

isLeafNegated

public boolean isLeafNegated(int index)
Description copied from interface: SimpleFilterLogicInterface
Returns TRUE if the leaf at the given index has been negated, FALSE otherwise.

Specified by:
isLeafNegated in interface SimpleFilterLogicInterface
Parameters:
index - the index of the leaf to examine
Returns:
TRUE if the leaf at the given index has been negated, FALSE otherwise.

canGroupLeaves

public boolean canGroupLeaves(int startIndex,
                              int endIndex)
Returns TRUE if the leaves (or the groups they're members of) at the given indices can be grouped together.

Specified by:
canGroupLeaves in interface SimpleFilterLogicInterface
Parameters:
startIndex - the start of the new group
endIndex - the end of the new group
Returns:
TRUE if the leaves (or the groups they're members of) at the given indices can be grouped together.

groupLeaves

public boolean groupLeaves(int startIndex,
                           int endIndex)
Groups the leaves (including any groups they are members of) at the specified locations together (along with any nodes in between them).

Specified by:
groupLeaves in interface SimpleFilterLogicInterface
Parameters:
startIndex - the start of the new group
endIndex - the end of the new group

splitOnMember

public boolean splitOnMember(int indexOfMember)
Splits the inner-most group containing the leaf at the specified index.

Specified by:
splitOnMember in interface SimpleFilterLogicInterface
Parameters:
indexOfMember - the index of a member of the group to be split

moveLeafUp

public boolean moveLeafUp(int index)
Moves the leaf at the given index up a position in the list of leaves. If a leaf is a member of a group, the leaf moves up within the group unless it is the first member of the group, in which case the entire group is moved. If the leaf or group to be moved is next to a group, it moves around the entire group.

Specified by:
moveLeafUp in interface SimpleFilterLogicInterface
Parameters:
index - the index of the leaf to manipulate

moveLeafDown

public boolean moveLeafDown(int index)
Moves the leaf at the given index down a position in the list of leaves. If a leaf is a member of a group, the leaf moves down within the group unless it is the last member of the group, in which case the entire group is moved. If the leaf or group to be moved is next to a group, it moves around the entire group.

Specified by:
moveLeafDown in interface SimpleFilterLogicInterface
Parameters:
index - the index of the leaf to manipulate

setLeaf

public FilterLogicTestNodeInterface setLeaf(int index,
                                            FilterLogicTestNodeInterface testNode)
Sets the test node at the given index in the list of understood test nodes.

Specified by:
setLeaf in interface SimpleFilterLogicInterface
Parameters:
index - the index in the list at which the new node will be set
testNode - the new node to put at the given index
Returns:
the old test node

addLeaf

public boolean addLeaf(int index,
                       FilterLogicTestNodeInterface testNode)
Add a new test node at the given index in the list of understood test nodes. The new node will be inserted at the new index.

Specified by:
addLeaf in interface SimpleFilterLogicInterface
Parameters:
index - the index in the list at which the new node will be inserted
testNode - the new node to add
Returns:
true if the tree changed from this call, false otherwise

getLeafCount

public int getLeafCount()
Specified by:
getLeafCount in interface SimpleFilterLogicInterface
Returns:
the number of leaves present in the filter logic

getLeaf

public FilterLogicTestNodeInterface getLeaf(int i)
Specified by:
getLeaf in interface SimpleFilterLogicInterface
Parameters:
i - the index of the leaf to retrieve
Returns:
the test node at the given index

setFilterObject

public boolean setFilterObject(java.lang.Object filterObject)
Transforms the given filter object (from the native filter model) into a network of filter logic nodes used to represent the filter within the filter selector model.

Specified by:
setFilterObject in interface SimpleFilterLogicInterface
Parameters:
filterObject - the filter object to process
Returns:
TRUE if the tree was modified as a result of calling this method, FALSE otherwise.

copy

public FilterLogicTreeInterface copy()
Specified by:
copy in interface FilterLogicTreeInterface
Overrides:
copy in class DefaultFilterLogicTree



Copyright © 2009 SAS Institute Inc. All Rights Reserved.