1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.dao.search;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.Validator;
19  
20  import javax.servlet.jsp.PageContext;
21  
22  /**
23   * <a href="TextSearchEntry.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class TextSearchEntry extends SearchEntry {
28  
29      public TextSearchEntry(String align, String valign, String name) {
30          this(align, valign, DEFAULT_COLSPAN, name, null);
31      }
32  
33      public TextSearchEntry(
34          String align, String valign, int colspan, String name) {
35  
36          this(align, valign, colspan, name, null);
37      }
38  
39      public TextSearchEntry(
40          String align, String valign, String name, String href) {
41  
42          this(align, valign, DEFAULT_COLSPAN, name, href, null, null);
43      }
44  
45      public TextSearchEntry(
46          String align, String valign, int colspan, String name, String href) {
47  
48          this(align, valign, colspan, name, href, null, null);
49      }
50  
51      public TextSearchEntry(
52          String align, String valign, String name, String href, String target,
53          String title) {
54  
55          this(align, valign, DEFAULT_COLSPAN, name, href, target, title);
56      }
57  
58      public TextSearchEntry(
59          String align, String valign, int colspan, String name, String href,
60          String target, String title) {
61  
62          super(align, valign, colspan);
63  
64          _name = name;
65          _href = href;
66          _target = target;
67          _title = title;
68      }
69  
70      public String getName() {
71          return _name;
72      }
73  
74      public void setName(String name) {
75          _name = name;
76      }
77  
78      public String getHref() {
79          return _href;
80      }
81  
82      public void setHref(String href) {
83          _href = href;
84      }
85  
86      public String getTarget() {
87          return _target;
88      }
89  
90      public void setTarget(String target) {
91          _target = target;
92      }
93  
94      public String getTitle() {
95          return _title;
96      }
97  
98      public void setTitle(String title) {
99          _title = title;
100     }
101 
102     public void print(PageContext pageContext) throws Exception {
103         if (_href == null) {
104             pageContext.getOut().print(_name);
105         }
106         else {
107             StringBundler sb = new StringBundler();
108 
109             sb.append("<a href=\"");
110             sb.append(_href);
111             sb.append("\"");
112 
113             if (Validator.isNotNull(_target)) {
114                 sb.append(" target=\"");
115                 sb.append(_target);
116                 sb.append("\"");
117             }
118 
119             if (Validator.isNotNull(_title)) {
120                 sb.append(" title=\"");
121                 sb.append(_title);
122                 sb.append("\"");
123             }
124 
125             sb.append(">");
126             sb.append(_name);
127             sb.append("</a>");
128 
129             pageContext.getOut().print(sb.toString());
130         }
131     }
132 
133     public Object clone() {
134         return new TextSearchEntry(
135             getAlign(), getValign(), getColspan(), getName(), getHref(),
136             getTarget(), getTitle());
137     }
138 
139     private String _name;
140     private String _href;
141     private String _target;
142     private String _title;
143 
144 }