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