1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.kernel.dao.search;
21  
22  import com.liferay.portal.kernel.util.Validator;
23  
24  import javax.servlet.jsp.PageContext;
25  
26  /**
27   * <a href="TextSearchEntry.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   *
31   */
32  public class TextSearchEntry extends SearchEntry {
33  
34      public TextSearchEntry(String align, String valign, String name) {
35          this(align, valign, DEFAULT_COLSPAN, name, null);
36      }
37  
38      public TextSearchEntry(
39          String align, String valign, int colspan, String name) {
40  
41          this(align, valign, colspan, name, null);
42      }
43  
44      public TextSearchEntry(
45          String align, String valign, String name, String href) {
46  
47          this(align, valign, DEFAULT_COLSPAN, name, href, null, null);
48      }
49  
50      public TextSearchEntry(
51          String align, String valign, int colspan, String name, String href) {
52  
53          this(align, valign, colspan, name, href, null, null);
54      }
55  
56      public TextSearchEntry(
57          String align, String valign, String name, String href, String target,
58          String title) {
59  
60          this(align, valign, DEFAULT_COLSPAN, name, href, target, title);
61      }
62  
63      public TextSearchEntry(
64          String align, String valign, int colspan, String name, String href,
65          String target, String title) {
66  
67          super(align, valign, colspan);
68  
69          _name = name;
70          _href = href;
71          _target = target;
72          _title = title;
73      }
74  
75      public String getName() {
76          return _name;
77      }
78  
79      public void setName(String name) {
80          _name = name;
81      }
82  
83      public String getHref() {
84          return _href;
85      }
86  
87      public void setHref(String href) {
88          _href = href;
89      }
90  
91      public String getTarget() {
92          return _target;
93      }
94  
95      public void setTarget(String target) {
96          _target = target;
97      }
98  
99      public String getTitle() {
100         return _title;
101     }
102 
103     public void setTitle(String title) {
104         _title = title;
105     }
106 
107     public void print(PageContext pageContext) throws Exception {
108         if (_href == null) {
109             pageContext.getOut().print(_name);
110         }
111         else {
112             StringBuilder sb = new StringBuilder();
113 
114             sb.append("<a href=\"");
115             sb.append(_href);
116             sb.append("\"");
117 
118             if (Validator.isNotNull(_target)) {
119                 sb.append(" target=\"");
120                 sb.append(_target);
121                 sb.append("\"");
122             }
123 
124             if (Validator.isNotNull(_title)) {
125                 sb.append(" title=\"");
126                 sb.append(_title);
127                 sb.append("\"");
128             }
129 
130             sb.append(">");
131             sb.append(_name);
132             sb.append("</a>");
133 
134             pageContext.getOut().print(sb.toString());
135         }
136     }
137 
138     public Object clone() {
139         return new TextSearchEntry(
140             getAlign(), getValign(), getColspan(), getName(), getHref(),
141             getTarget(), getTitle());
142     }
143 
144     private String _name;
145     private String _href;
146     private String _target;
147     private String _title;
148 
149 }