KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > base > JRBaseHyperlink


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.base;
29
30 import java.io.Serializable JavaDoc;
31
32 import net.sf.jasperreports.engine.JRConstants;
33 import net.sf.jasperreports.engine.JRExpression;
34 import net.sf.jasperreports.engine.JRHyperlink;
35 import net.sf.jasperreports.engine.JRHyperlinkHelper;
36 import net.sf.jasperreports.engine.JRHyperlinkParameter;
37
38 /**
39  * Read-only implementation of {@link JRHyperlink JRHyperlink}.
40  *
41  * @author Lucian Chirita (lucianc@users.sourceforge.net)
42  * @version $Id: JRBaseHyperlink.java 1364 2006-08-31 18:13:20 +0300 (Thu, 31 Aug 2006) lucianc $
43  */

44 public class JRBaseHyperlink implements JRHyperlink, Serializable JavaDoc
45 {
46     
47     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
48     
49     protected String JavaDoc linkType;
50     protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF;
51     protected JRExpression hyperlinkReferenceExpression;
52     protected JRExpression hyperlinkAnchorExpression;
53     protected JRExpression hyperlinkPageExpression;
54     protected JRExpression hyperlinkTooltipExpression;
55     protected JRHyperlinkParameter[] hyperlinkParameters;
56
57     
58     /**
59      * Create an empty hyperlink.
60      */

61     public JRBaseHyperlink()
62     {
63     }
64
65     
66     protected JRBaseHyperlink(JRHyperlink link, JRBaseObjectFactory factory)
67     {
68         factory.put(link, this);
69         
70         linkType = link.getLinkType();
71         hyperlinkTarget = link.getHyperlinkTarget();
72         hyperlinkReferenceExpression = factory.getExpression(link.getHyperlinkReferenceExpression());
73         hyperlinkAnchorExpression = factory.getExpression(link.getHyperlinkAnchorExpression());
74         hyperlinkPageExpression = factory.getExpression(link.getHyperlinkPageExpression());
75         hyperlinkTooltipExpression = factory.getExpression(link.getHyperlinkTooltipExpression());
76         hyperlinkParameters = copyHyperlinkParameters(link, factory);
77     }
78
79     public static JRHyperlinkParameter[] copyHyperlinkParameters(JRHyperlink link, JRBaseObjectFactory factory)
80     {
81         JRHyperlinkParameter[] linkParameters = link.getHyperlinkParameters();
82         JRHyperlinkParameter[] parameters = null;
83         if (linkParameters != null && linkParameters.length > 0)
84         {
85             parameters = new JRHyperlinkParameter[linkParameters.length];
86             for (int i = 0; i < linkParameters.length; i++)
87             {
88                 JRHyperlinkParameter parameter = linkParameters[i];
89                 parameters[i] = factory.getHyperlinkParameter(parameter);
90             }
91         }
92         return parameters;
93     }
94     
95     public JRExpression getHyperlinkAnchorExpression()
96     {
97         return hyperlinkAnchorExpression;
98     }
99
100     public JRExpression getHyperlinkPageExpression()
101     {
102         return hyperlinkPageExpression;
103     }
104
105     public JRHyperlinkParameter[] getHyperlinkParameters()
106     {
107         return hyperlinkParameters;
108     }
109
110     public JRExpression getHyperlinkReferenceExpression()
111     {
112         return hyperlinkReferenceExpression;
113     }
114
115     public byte getHyperlinkTarget()
116     {
117         return hyperlinkTarget;
118     }
119
120     public byte getHyperlinkType()
121     {
122         return JRHyperlinkHelper.getHyperlinkType(this);
123     }
124
125     public String JavaDoc getLinkType()
126     {
127         return linkType;
128     }
129     
130     public JRExpression getHyperlinkTooltipExpression()
131     {
132         return hyperlinkTooltipExpression;
133     }
134
135 }
136
Popular Tags