1 /*
2 * Copyright 2003 - 2013 The eFaps Team
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Revision: $Rev$
17 * Last Changed: $Date$
18 * Last Changed By: $Author$
19 */
20
21
22 package org.efaps.db.search.compare;
23
24 import org.efaps.db.AbstractObjectQuery;
25 import org.efaps.db.search.AbstractQPart;
26 import org.efaps.db.search.QAttribute;
27 import org.efaps.db.search.value.AbstractQValue;
28 import org.efaps.util.EFapsException;
29
30
31 /**
32 * Compare an Attribute with a value.
33 *
34 * @author The eFaps Team
35 * @version $Id$
36 */
37 public abstract class AbstractQAttrCompare
38 extends AbstractQPart
39 {
40 /**
41 * The attribute used for this equal.
42 */
43 private final QAttribute attribute;
44
45 /**
46 * The value the attribute will be compared to.
47 */
48 private final AbstractQValue value;
49
50 /**
51 * Must this compare ignore the case.
52 */
53 private boolean ignoreCase;
54
55 /**
56 * Constructor setting attribute and value.
57 * @param _attribute Attribute to be checked for equal
58 * @param _value value as criteria
59 */
60 public AbstractQAttrCompare(final QAttribute _attribute,
61 final AbstractQValue _value)
62 {
63 this.attribute = _attribute;
64 this.value = _value;
65 }
66
67 /**
68 * Getter method for the instance variable {@link #attribute}.
69 *
70 * @return value of instance variable {@link #attribute}
71 */
72 public QAttribute getAttribute()
73 {
74 return this.attribute;
75 }
76
77 /**
78 * Getter method for the instance variable {@link #value}.
79 *
80 * @return value of instance variable {@link #value}
81 */
82 public AbstractQValue getValue()
83 {
84 return this.value;
85 }
86
87 /**
88 * Getter method for the instance variable {@link #ignoreCase}.
89 *
90 * @return value of instance variable {@link #ignoreCase}
91 */
92 public boolean isIgnoreCase()
93 {
94 return this.ignoreCase;
95 }
96
97 /**
98 * Setter method for instance variable {@link #ignoreCase}.
99 *
100 * @param _ignoreCase value for instance variable {@link #ignoreCase}
101 * @return this
102 */
103 public AbstractQAttrCompare setIgnoreCase(final boolean _ignoreCase)
104 {
105 this.ignoreCase = _ignoreCase;
106 return this;
107 }
108
109 /**
110 * {@inheritDoc}
111 */
112 @Override
113 public AbstractQPart prepare(final AbstractObjectQuery<?> _query,
114 final AbstractQPart _part)
115 throws EFapsException
116 {
117 this.attribute.prepare(_query, this);
118 this.value.prepare(_query, this);
119 return this;
120 }
121 }