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