KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > controlx > search > SearchControl


1 /**
2  * Copyright 2005 obinary ag. All rights reserved.
3  * See license distributed with this file and available
4  * online at http://www.magnolia.info/dms-license.html
5  */

6
7 package info.magnolia.cms.gui.controlx.search;
8
9 import info.magnolia.cms.gui.controlx.impl.AbstractControl;
10 import info.magnolia.cms.gui.query.SearchQueryExpression;
11 import info.magnolia.cms.gui.query.StringSearchQueryParameter;
12
13 import org.apache.commons.lang.StringUtils;
14
15
16 /**
17  * This is a real control instance
18  * @author Philipp Bracher
19  * @version $Revision: 6341 $ ($Author: philipp $)
20  */

21 public class SearchControl extends AbstractControl {
22
23     public static final String JavaDoc RENDER_TYPE = "searchControl";
24
25     private SearchControlDefinition definition;
26
27     private String JavaDoc value;
28
29     private String JavaDoc constraint;
30
31     public SearchControl() {
32         this.setRenderType(RENDER_TYPE);
33     }
34
35     /**
36      * @param definition
37      * @param value
38      * @param constraint
39      */

40     public SearchControl(SearchControlDefinition definition, String JavaDoc value, String JavaDoc condition) {
41         this();
42         this.definition = definition;
43         this.value = value;
44         this.constraint = condition;
45     }
46
47     /**
48      * @return Returns the constraint.
49      */

50     public String JavaDoc getConstraint() {
51         return constraint;
52     }
53
54     /**
55      * @param constraint The constraint to set.
56      */

57     public void setConstraint(String JavaDoc condition) {
58         this.constraint = condition;
59     }
60
61     /**
62      * @return Returns the definition.
63      */

64     public SearchControlDefinition getDefinition() {
65         return definition;
66     }
67
68     /**
69      * @param definition The definition to set.
70      */

71     public void setDefinition(SearchControlDefinition definition) {
72         this.definition = definition;
73     }
74
75     /**
76      * @return Returns the value.
77      */

78     public String JavaDoc getValue() {
79         return value;
80     }
81
82     /**
83      * @param value The value to set.
84      */

85     public void setValue(String JavaDoc value) {
86         this.value = value;
87     }
88
89     /**
90      * @return
91      */

92     public SearchQueryExpression getExpression() {
93         String JavaDoc value = this.getValue().toString();
94         if (StringUtils.isNotEmpty(value)) {
95             return new StringSearchQueryParameter(this.getDefinition().getColumn(), value, this.getConstraint());
96         }
97         return null;
98     }
99
100 }
101
Popular Tags