1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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   */
35  public class TextSearchEntry extends SearchEntry {
36  
37      public TextSearchEntry(String align, String valign, String name) {
38          this(align, valign, DEFAULT_COLSPAN, name, null);
39      }
40  
41      public TextSearchEntry(
42          String align, String valign, int colspan, String name) {
43  
44          this(align, valign, colspan, name, null);
45      }
46  
47      public TextSearchEntry(
48          String align, String valign, String name, String href) {
49  
50          this(align, valign, DEFAULT_COLSPAN, name, href, null, null);
51      }
52  
53      public TextSearchEntry(
54          String align, String valign, int colspan, String name, String href) {
55  
56          this(align, valign, colspan, name, href, null, null);
57      }
58  
59      public TextSearchEntry(
60          String align, String valign, String name, String href, String target,
61          String title) {
62  
63          this(align, valign, DEFAULT_COLSPAN, name, href, target, title);
64      }
65  
66      public TextSearchEntry(
67          String align, String valign, int colspan, String name, String href,
68          String target, String title) {
69  
70          super(align, valign, colspan);
71  
72          _name = name;
73          _href = href;
74          _target = target;
75          _title = title;
76      }
77  
78      public String getName() {
79          return _name;
80      }
81  
82      public void setName(String name) {
83          _name = name;
84      }
85  
86      public String getHref() {
87          return _href;
88      }
89  
90      public void setHref(String href) {
91          _href = href;
92      }
93  
94      public String getTarget() {
95          return _target;
96      }
97  
98      public void setTarget(String target) {
99          _target = target;
100     }
101 
102     public String getTitle() {
103         return _title;
104     }
105 
106     public void setTitle(String title) {
107         _title = title;
108     }
109 
110     public void print(PageContext pageContext) throws Exception {
111         if (_href == null) {
112             pageContext.getOut().print(_name);
113         }
114         else {
115             StringBuilder sb = new StringBuilder();
116 
117             sb.append("<a href=\"");
118             sb.append(_href);
119             sb.append("\"");
120 
121             if (Validator.isNotNull(_target)) {
122                 sb.append(" target=\"");
123                 sb.append(_target);
124                 sb.append("\"");
125             }
126 
127             if (Validator.isNotNull(_title)) {
128                 sb.append(" title=\"");
129                 sb.append(_title);
130                 sb.append("\"");
131             }
132 
133             sb.append(">");
134             sb.append(_name);
135             sb.append("</a>");
136 
137             pageContext.getOut().print(sb.toString());
138         }
139     }
140 
141     public Object clone() {
142         return new TextSearchEntry(
143             getAlign(), getValign(), getColspan(), getName(), getHref(),
144             getTarget(), getTitle());
145     }
146 
147     private String _name;
148     private String _href;
149     private String _target;
150     private String _title;
151 
152 }