/*
 * @(#)BoundFilter.java    1.0   2 May 2006
 *
 * Copyright 2006
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.filter;

/**
 * <P>Abstract superclass for filters that represent
 * an inclusive or exclusive bounded range.</P>
 *
 * @author  Jeff Raab
 * @version 2.2
 * @since   1.0
 */
public abstract class BoundFilter 
    extends NumericFilter
{
    /** Bound property name for the inclusive property. */
    public static final String INCLUSIVE = "inclusive";

    /** Whether or not the range is inclusive. */
    protected boolean inclusive = true;
    
    //////////////////
    // Constructors //
    //////////////////
    
    /**
     * Constructs an inclusive or exclusive range.
     *
     * @param isInclusive whether or not the range is inclusive
     */
    public BoundFilter(boolean isInclusive) {
        setInclusive(isInclusive);
    }

    ////////////////
    // Public API //
    ////////////////

    /**
     * Sets whether or not the range is inclusive.
     *
     * @param isInclusive whether or not the range is inclusive
     * @see #isInclusive()
     */
    public void setInclusive(boolean isInclusive) {
        boolean oldInc = isInclusive();
        
        inclusive = isInclusive;
        
        // if the property has changed
        if (isInclusive() != oldInc) {
        
            // notify listeners of property change
            changeAdapter.firePropertyChange(
                INCLUSIVE,
                oldInc,
                isInclusive());
        }                
    }

    /**
     * Returns whether or not the range is inclusive.
     *
     * @see #setInclusive(boolean)
     */
    public boolean isInclusive() {
        return inclusive;
    }
}
