Class ColumnBasedTableFilter<R>

  • Type Parameters:
    R - the row type of the table
    All Implemented Interfaces:
    TableFilter<R>

    public class ColumnBasedTableFilter<R>
    extends java.lang.Object
    implements TableFilter<R>
    A TableFilter that filters based on column values

    This class maintains a list of ColumnConstraintSet objects that are logically combined to determine if the overall filter accepts the given row object. Each ColumnConstraint has an associated LogicOperation which determines how its result are combined with the constraint set before it. (The first ConstraintSets LogicOperation is not used). AND operations have higher precedence than the OR operations.

    • Constructor Detail

      • ColumnBasedTableFilter

        public ColumnBasedTableFilter​(RowObjectTableModel<R> model)
        Constructs a new empty ColumnBasedTableFilter
        Parameters:
        model - the table model
    • Method Detail

      • acceptsRow

        public boolean acceptsRow​(R rowObject)
        Description copied from interface: TableFilter
        Returns true if this filter matches the given row (data)
        Specified by:
        acceptsRow in interface TableFilter<R>
        Parameters:
        rowObject - the current row object
        Returns:
        true if the element at the given row matches this filter.
      • getName

        public java.lang.String getName()
        Returns the name of this filter.

        Names are used for saving filters, so unless they are saved they typically don't have a name.

        Returns:
        the name of this filter.
      • setName

        public void setName​(java.lang.String name)
        Sets the name of this filter.
        Parameters:
        name - the new name for this filter.
      • addConstraintSet

        public <T> void addConstraintSet​(LogicOperation logicalOp,
                                         int columnIndex,
                                         java.util.List<ColumnConstraint<T>> constraints)
        Adds a new constraintSet to this ColumnBasedTableFilter
        Parameters:
        logicalOp - The logic operation (AND or OR) for how the new ConstraintSet's result will be combined with the previous ConstraintSet's result.
        columnIndex - the model index of the column whose values must past the given constraint filters.
        constraints - a list of ColumnConstraints where at least one must pass for the constraintSet to pass.
      • isSubFilterOf

        public boolean isSubFilterOf​(TableFilter<?> tableFilter)
        Description copied from interface: TableFilter
        Returns true if this filter is a more specific version of the given filter.

        For example, if this filter is a 'starts with' text filter, with the value of 'bobo', then if the given filter is also a 'starts with' filter, with a value of 'bob', then this filter is considered a sub-filter of the given sub-filter.

        Specified by:
        isSubFilterOf in interface TableFilter<R>
        Parameters:
        tableFilter - the filter to check
        Returns:
        true if this filter is a sub-filter of the given filter
      • hasColumnFilter

        public boolean hasColumnFilter​(int columnModelIndex)
        Description copied from interface: TableFilter
        Returns true if the there is a column filter on the column specified
        Specified by:
        hasColumnFilter in interface TableFilter<R>
        Parameters:
        columnModelIndex - the model index of the column to test for column filters.
        Returns:
        true if the there is a column filter on the column specified.
      • getConstraintSets

        public java.util.List<ColumnConstraintSet<R,​?>> getConstraintSets()
        Return the list of ConstraintSets in this TableFilter
        Returns:
        the list of ConstraintSets in this TableFilter
      • save

        public SaveState save()
        Serializes this filter into a SaveState object.
        Returns:
        the SaveState serialized version of this filter.
      • restore

        public <T> void restore​(SaveState saveState,
                                java.lang.Object dataSource)
        Restore this filter from the given saveState.
        Parameters:
        saveState - that contains the serialized filter data
        dataSource - the Table's DataSource which some objects might need to restore themselves.
      • getHtmlRepresentation

        public java.lang.String getHtmlRepresentation()
        Returns an HTML description of this filter.

        Note: the HTML string returned does NOT start with the HTML tag so that it can be combined with other text.

        Returns:
        an HTML description of this filter.
      • getToolTip

        public java.lang.String getToolTip​(int columnIndex)
        Return a tooltip that describes the effect of this filter for a specific filter.
        Parameters:
        columnIndex - the model index of the column to get a filter description of.
        Returns:
        a tooltip that describes this filter for a specific column.
      • toString

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • isEquivalent

        public boolean isEquivalent​(ColumnBasedTableFilter<?> other)
        Checks if the given ColumnBasedTableFilter is the same as this one except for its name.
        Parameters:
        other - the other filter to check for equivalence.
        Returns:
        true if the other filter is the same as this one except for its name
      • isSaved

        public boolean isSaved()
        Returns true if this filter has been saved (i.e. has a name)
        Returns:
        true if this filter has been saved (i.e. has a name)