1 /***
2 * InclusionComparisonOperator.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2002 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.filters;
27
28 import java.security.InvalidParameterException;
29 import java.util.Hashtable;
30
31 import org.jcreme.enumerations.Enumeration;
32
33 /***
34 * This enumeration contains the operators that can be used in a list context to
35 * test the inclusion. As a subclass of the ComparisonOperator enumeration,
36 * values of this class are also registered as elements of the
37 * ComparisonOperator enumeration.
38 *
39 * @author $Author: dbregeon $
40 * @version $Revision: 1.3 $
41 */
42 public class InclusionComparisonOperator extends ComparisonOperator {
43 static final long serialVersionUID = -8021294863659066911L;
44
45 /***
46 * The InclusionComparisonOperator instances by their name.
47 */
48 private static final Hashtable fromName = new Hashtable();
49
50 /***
51 * The name for the 'IN' enumeration value.
52 */
53 public static final String S_IN = "IN";
54
55 /***
56 * The 'IN' enumeration value.
57 */
58 public static final InclusionComparisonOperator IN = new InclusionComparisonOperator(
59 S_IN);
60
61 /***
62 * The name for the 'NOT IN' enumeration value.
63 */
64 public static final String S_NOT_IN = "NOT IN";
65
66 /***
67 * The 'NOT IN' enumeration value.
68 */
69 public static final InclusionComparisonOperator NOT_IN = new InclusionComparisonOperator(
70 S_NOT_IN);
71
72 /***
73 * Creates new InclusionComparisonOperator
74 *
75 * @param name
76 * the name of this enumerated value. It cannot be null.
77 * @throws InvalidParameterException
78 * if name is null.
79 */
80 protected InclusionComparisonOperator(String name)
81 throws InvalidParameterException {
82 super(name);
83 addAsComparisonOperator(this);
84 }
85
86 /***
87 * This method is for internal use only.
88 *
89 * @return the Hashtable that links the enumerated values names with the
90 * actual enumerated value.
91 */
92 protected Hashtable getFromName() {
93 return fromName;
94 }
95
96 /***
97 * This method retrieves an InclusionComparisonOperator instance from its
98 * name.
99 *
100 * @param name
101 * the name of the InclusionComparisonOperator instance.
102 * @return the InclusionComparisonOperator that has this name. Null if no
103 * value corresponding to this name was found.
104 */
105 public static InclusionComparisonOperator getInclusionComparisonOperator(
106 final String name) {
107 InclusionComparisonOperator result = null;
108 if (name != null) {
109 result = (InclusionComparisonOperator) fromName.get(name);
110 }
111 return result;
112 }
113
114 /***
115 * This methods gives the instances of this class.
116 *
117 * @return all the instances of this class.
118 */
119 public static InclusionComparisonOperator[] getInclusionComparisonOperators() {
120 return (InclusionComparisonOperator[]) fromName.values().toArray(
121 new InclusionComparisonOperator[0]);
122 }
123
124 /***
125 * This method enables to retrieve all the possible values of an Enumeration
126 * class.
127 *
128 * @return the values for this class.
129 */
130 public static Enumeration[] getValues() {
131 return getInclusionComparisonOperators();
132 }
133 }