1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2005 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
16 */
17 package ch.elca.el4j.services.search.criterias;
18
19 import ch.elca.el4j.util.codingsupport.Reject;
20
21
22 /**
23 * Abstract parent class for Criteria implementations.
24 *
25 * @svnLink $Revision: 3873 $;$Date: 2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/main/java/ch/elca/el4j/services/search/criterias/AbstractCriteria.java $
26 *
27 * @author Martin Zeltner (MZE)
28 */
29 public abstract class AbstractCriteria implements Criteria {
30 /**
31 * Is the field the criteria is made for.
32 */
33 private String m_field;
34
35 /**
36 * Is the value of this criteria.
37 */
38 private Object m_value;
39
40 /**
41 * Default constructor for remoting protocols like hessian added.
42 */
43 protected AbstractCriteria() { }
44
45 /**
46 * Constructor.
47 *
48 * @param field Is the field the criteria is made for.
49 * @param value Is the value of this criteria.
50 */
51 protected AbstractCriteria(String field, Object value) {
52 Reject.ifEmpty(field);
53 Reject.ifNull(value);
54 m_field = field;
55 m_value = value;
56 }
57
58 /**
59 * @return Returns the field.
60 */
61 public final String getField() {
62 return m_field;
63 }
64
65 /**
66 * @return Returns the value.
67 */
68 public final Object getValue() {
69 return m_value;
70 }
71
72 /**
73 * @return Returns the string value of this criteria.
74 */
75 public final String getStringValue() {
76 return (String) getValue();
77 }
78
79 /**
80 * @return Returns the boolean value of this criteria.
81 */
82 public final Boolean getBooleanValue() {
83 return (Boolean) getValue();
84 }
85
86 /**
87 * @return Returns the integer value of this criteria.
88 */
89 public final Integer getIntegerValue() {
90 return (Integer) getValue();
91 }
92
93 /**
94 * @return Returns the long value of this criteria.
95 */
96 public final Long getLongValue() {
97 return (Long) getValue();
98 }
99
100 /**
101 * @return Returns the short value of this criteria.
102 */
103 public final Short getShortValue() {
104 return (Short) getValue();
105 }
106
107 /**
108 * @return Returns the byte value of this criteria.
109 */
110 public final Byte getByteValue() {
111 return (Byte) getValue();
112 }
113
114 /**
115 * @return Returns the double value of this criteria.
116 */
117 public final Double getDoubleValue() {
118 return (Double) getValue();
119 }
120
121 /**
122 * @return Returns the float value of this criteria.
123 */
124 public final Float getFloatValue() {
125 return (Float) getValue();
126 }
127 }