Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/sample/addressbook/controller/components/search/SearchRange.java


1   /*
2    * SearchRange.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.sample.addressbook.controller.components.search;
11  
12  import java.io.Serializable;
13  
14  import com.sample.addressbook.controller.components.search.SearchFilter;
15  
16  
17  /**
18   * Specifies the inclusive range of items to place in a search result.
19   *
20   * @author  Trevor Milne
21   *
22   */
23  
24  public class SearchRange implements SearchFilter, Serializable
25  {
26    /** The lower bound of the range. */
27    private int lowerBound;
28  
29    /** The upper bound of the range. */
30    private int upperBound;
31  
32    /* Construction. */
33  
34    /**
35     * Creates an instance.
36     *
37     * @param    setLowerBound        The lower bound.
38     * @param    setUpperBound        The upper bound.
39     *
40     */
41  
42    public SearchRange(int setLowerBound, int setUpperBound)
43    {
44      lowerBound = setLowerBound;
45      upperBound = setUpperBound;
46    }
47  
48    /**
49     * Returns the lower bound of the range.
50     *
51     * @return                  The lower bound.
52     *
53     */
54  
55    public int getLowerBound()
56    {
57      return lowerBound;
58    }
59  
60    /**
61     * Returns the upper bound of the range.
62     *
63     * @return                  The upper bound.
64     *
65     */
66  
67    public int getUpperBound()
68    {
69      return upperBound;
70    }
71  
72    /**
73     * Returns true if the item is in the range.
74     *
75     * @param    number            The item number.
76     *
77     * @return                  True if the item is in the range, false otherwise.
78     *
79     */
80  
81    public boolean isRetained(int number)
82    {
83      return ((number >= lowerBound) && (number <= upperBound));
84    }
85  
86    /**
87     * Returns true if the item number is excluded from the search result.
88     *
89     * @param    number            The item number.
90     *
91     * @return                  True if the item is not in the result, false otherwise.
92     *
93     */
94  
95    public boolean isFiltered(int number)
96    {
97      return (!isRetained(number));
98    }
99  }
100