KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > design > JRDesignHyperlink


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.design;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.List JavaDoc;
33
34 import net.sf.jasperreports.engine.JRConstants;
35 import net.sf.jasperreports.engine.JRExpression;
36 import net.sf.jasperreports.engine.JRHyperlink;
37 import net.sf.jasperreports.engine.JRHyperlinkHelper;
38 import net.sf.jasperreports.engine.JRHyperlinkParameter;
39 import net.sf.jasperreports.engine.base.JRBaseHyperlink;
40
41
42 /**
43  * Stand-alone implementation of {@link JRHyperlink JRHyperlink}
44  * which should be used for report design purposes.
45  *
46  * @author Lucian Chirita (lucianc@users.sourceforge.net)
47  * @version $Id: JRDesignHyperlink.java 1368 2006-09-01 15:01:52 +0300 (Fri, 01 Sep 2006) lucianc $
48  */

49 public class JRDesignHyperlink extends JRBaseHyperlink
50 {
51     
52     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
53     
54     private List JavaDoc hyperlinkParameters;
55     
56     public JRDesignHyperlink()
57     {
58         hyperlinkParameters = new ArrayList JavaDoc();
59     }
60
61     
62     /**
63      * Sets the link type as a built-in hyperlink type.
64      *
65      * @param hyperlinkType the built-in hyperlink type
66      * @see #getLinkType()
67      */

68     public void setHyperlinkType(byte hyperlinkType)
69     {
70         setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
71     }
72
73     
74     /**
75      * Sets the hyperlink target.
76      *
77      * @param hyperlinkTarget the hyperlink target, one of
78      * <ul>
79      * <li>{@link JRHyperlink#HYPERLINK_TARGET_SELF JRHyperlink.HYPERLINK_TARGET_SELF}</li>
80      * <li>{@link JRHyperlink#HYPERLINK_TARGET_BLANK JRHyperlink.HYPERLINK_TARGET_BLANK}</li>
81      * </ul>
82      * @see #getHyperlinkTarget()
83      */

84     public void setHyperlinkTarget(byte hyperlinkTarget)
85     {
86         this.hyperlinkTarget = hyperlinkTarget;
87     }
88
89
90     /**
91      * Sets the expression that will generate the hyperlink reference URL
92      * or the referred document location.
93      * <p>
94      * This expression is used when the hyperlink type is
95      * {@link JRHyperlink#HYPERLINK_TYPE_REFERENCE JRHyperlink.HYPERLINK_TYPE_REFERENCE},
96      * {@link JRHyperlink#HYPERLINK_TYPE_REMOTE_ANCHOR JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR} or
97      * {@link JRHyperlink#HYPERLINK_TYPE_REMOTE_PAGE JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE}.
98      * The type of the expression should be <code>java.lang.String</code>
99      * </p>
100      *
101      * @param hyperlinkReferenceExpression the reference expression
102      * @see #getHyperlinkReferenceExpression()
103      */

104     public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression)
105     {
106         this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
107     }
108
109
110     /**
111      * Sets the expression that will generate the referred anchor.
112      * <p>
113      * This expression is used when the hyperlink type is
114      * {@link JRHyperlink#HYPERLINK_TYPE_LOCAL_ANCHOR JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR} or
115      * {@link JRHyperlink#HYPERLINK_TYPE_REMOTE_ANCHOR JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR}.
116      * The type of the expression should be <code>java.lang.String</code>
117      * </p>
118      *
119      * @param hyperlinkAnchorExpression the anchor expression
120      * @see #getHyperlinkAnchorExpression()
121      */

122     public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression)
123     {
124         this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
125     }
126
127
128     /**
129      * Sets the expression that will generate the referred page.
130      * <p>
131      * This expression is used when the hyperlink type is
132      * {@link JRHyperlink#HYPERLINK_TYPE_LOCAL_PAGE JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE} or
133      * {@link JRHyperlink#HYPERLINK_TYPE_REMOTE_PAGE JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE}.
134      * The type of the expression should be <code>java.lang.Integer</code>
135      * </p>
136      *
137      * @param hyperlinkPageExpression the page expression
138      * @see #getHyperlinkPageExpression()
139      */

140     public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression)
141     {
142         this.hyperlinkPageExpression = hyperlinkPageExpression;
143     }
144
145
146     /**
147      * Sets the hyperlink type.
148      * <p>
149      * The type can be one of the built-in types
150      * (Reference, LocalAnchor, LocalPage, RemoteAnchor, RemotePage),
151      * or can be an arbitrary type.
152      * </p>
153      * @param type the hyperlink type
154      */

155     public void setLinkType(String JavaDoc type)
156     {
157         this.linkType = type;
158     }
159
160
161     public JRHyperlinkParameter[] getHyperlinkParameters()
162     {
163         JRHyperlinkParameter[] parameters;
164         if (hyperlinkParameters.isEmpty())
165         {
166             parameters = null;
167         }
168         else
169         {
170             parameters = new JRHyperlinkParameter[hyperlinkParameters.size()];
171             hyperlinkParameters.toArray(parameters);
172         }
173         return parameters;
174     }
175     
176     
177     /**
178      * Returns the list of custom hyperlink parameters.
179      *
180      * @return the list of custom hyperlink parameters
181      */

182     public List JavaDoc getHyperlinkParametersList()
183     {
184         return hyperlinkParameters;
185     }
186     
187     
188     /**
189      * Adds a custom hyperlink parameter.
190      *
191      * @param parameter the parameter to add
192      */

193     public void addHyperlinkParameter(JRHyperlinkParameter parameter)
194     {
195         hyperlinkParameters.add(parameter);
196     }
197     
198
199     /**
200      * Removes a custom hyperlink parameter.
201      *
202      * @param parameter the parameter to remove
203      */

204     public void removeHyperlinkParameter(JRHyperlinkParameter parameter)
205     {
206         hyperlinkParameters.remove(parameter);
207     }
208     
209     
210     /**
211      * Removes a custom hyperlink parameter.
212      * <p>
213      * If multiple parameters having the specified name exist, all of them
214      * will be removed
215      * </p>
216      *
217      * @param parameterName the parameter name
218      */

219     public void removeHyperlinkParameter(String JavaDoc parameterName)
220     {
221         for (Iterator JavaDoc it = hyperlinkParameters.iterator(); it.hasNext();)
222         {
223             JRHyperlinkParameter parameter = (JRHyperlinkParameter) it.next();
224             if (parameter.getName() != null && parameter.getName().equals(parameterName))
225             {
226                 it.remove();
227             }
228         }
229     }
230
231     
232     /**
233      * Sets the expression which will be used to generate the hyperlink tooltip.
234      * The type of the expression should be <code>java.lang.String</code>.
235      *
236      * @param hyperlinkTooltipExpression the expression which will be used to generate the hyperlink tooltip
237      * @see #getHyperlinkTooltipExpression()
238      */

239     public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression)
240     {
241         this.hyperlinkTooltipExpression = hyperlinkTooltipExpression;
242     }
243     
244 }
245
Popular Tags