1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.dao.search;
16  
17  import com.liferay.portal.kernel.util.HtmlUtil;
18  import com.liferay.portal.kernel.util.StringBundler;
19  import com.liferay.portal.kernel.util.Validator;
20  
21  import javax.servlet.jsp.PageContext;
22  
23  /**
24   * <a href="TextSearchEntry.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class TextSearchEntry extends SearchEntry {
29  
30      public TextSearchEntry(String align, String valign, String name) {
31          this(align, valign, DEFAULT_COLSPAN, name, null);
32      }
33  
34      public TextSearchEntry(
35          String align, String valign, int colspan, String name) {
36  
37          this(align, valign, colspan, name, null);
38      }
39  
40      public TextSearchEntry(
41          String align, String valign, String name, String href) {
42  
43          this(align, valign, DEFAULT_COLSPAN, name, href, null, null);
44      }
45  
46      public TextSearchEntry(
47          String align, String valign, int colspan, String name, String href) {
48  
49          this(align, valign, colspan, name, href, null, null);
50      }
51  
52      public TextSearchEntry(
53          String align, String valign, String name, String href, String target,
54          String title) {
55  
56          this(align, valign, DEFAULT_COLSPAN, name, href, target, title);
57      }
58  
59      public TextSearchEntry(
60          String align, String valign, int colspan, String name, String href,
61          String target, String title) {
62  
63          super(align, valign, colspan);
64  
65          _name = name;
66          _href = href;
67          _target = target;
68          _title = title;
69      }
70  
71      public String getName() {
72          return _name;
73      }
74  
75      public void setName(String name) {
76          _name = name;
77      }
78  
79      public String getHref() {
80          return _href;
81      }
82  
83      public void setHref(String href) {
84          _href = href;
85      }
86  
87      public String getTarget() {
88          return _target;
89      }
90  
91      public void setTarget(String target) {
92          _target = target;
93      }
94  
95      public String getTitle() {
96          return _title;
97      }
98  
99      public void setTitle(String title) {
100         _title = title;
101     }
102 
103     public void print(PageContext pageContext) throws Exception {
104         if (_href == null) {
105             pageContext.getOut().print(_name);
106         }
107         else {
108             StringBundler sb = new StringBundler();
109 
110             sb.append("<a href=\"");
111             sb.append(HtmlUtil.escapeAttribute(_href));
112             sb.append("\"");
113 
114             if (Validator.isNotNull(_target)) {
115                 sb.append(" target=\"");
116                 sb.append(_target);
117                 sb.append("\"");
118             }
119 
120             if (Validator.isNotNull(_title)) {
121                 sb.append(" title=\"");
122                 sb.append(_title);
123                 sb.append("\"");
124             }
125 
126             sb.append(">");
127             sb.append(_name);
128             sb.append("</a>");
129 
130             pageContext.getOut().print(sb.toString());
131         }
132     }
133 
134     public Object clone() {
135         return new TextSearchEntry(
136             getAlign(), getValign(), getColspan(), getName(), getHref(),
137             getTarget(), getTitle());
138     }
139 
140     private String _name;
141     private String _href;
142     private String _target;
143     private String _title;
144 
145 }