001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.base;
029:
030: import java.io.Serializable;
031:
032: import net.sf.jasperreports.engine.JRConstants;
033: import net.sf.jasperreports.engine.JRExpression;
034: import net.sf.jasperreports.engine.JRHyperlink;
035: import net.sf.jasperreports.engine.JRHyperlinkHelper;
036: import net.sf.jasperreports.engine.JRHyperlinkParameter;
037:
038: /**
039: * Read-only implementation of {@link JRHyperlink JRHyperlink}.
040: *
041: * @author Lucian Chirita (lucianc@users.sourceforge.net)
042: * @version $Id: JRBaseHyperlink.java 1364 2006-08-31 15:13:20Z lucianc $
043: */
044: public class JRBaseHyperlink implements JRHyperlink, Serializable {
045:
046: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
047:
048: protected String linkType;
049: protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF;
050: protected JRExpression hyperlinkReferenceExpression;
051: protected JRExpression hyperlinkAnchorExpression;
052: protected JRExpression hyperlinkPageExpression;
053: protected JRExpression hyperlinkTooltipExpression;
054: protected JRHyperlinkParameter[] hyperlinkParameters;
055:
056: /**
057: * Create an empty hyperlink.
058: */
059: public JRBaseHyperlink() {
060: }
061:
062: protected JRBaseHyperlink(JRHyperlink link,
063: JRBaseObjectFactory factory) {
064: factory.put(link, this );
065:
066: linkType = link.getLinkType();
067: hyperlinkTarget = link.getHyperlinkTarget();
068: hyperlinkReferenceExpression = factory.getExpression(link
069: .getHyperlinkReferenceExpression());
070: hyperlinkAnchorExpression = factory.getExpression(link
071: .getHyperlinkAnchorExpression());
072: hyperlinkPageExpression = factory.getExpression(link
073: .getHyperlinkPageExpression());
074: hyperlinkTooltipExpression = factory.getExpression(link
075: .getHyperlinkTooltipExpression());
076: hyperlinkParameters = copyHyperlinkParameters(link, factory);
077: }
078:
079: public static JRHyperlinkParameter[] copyHyperlinkParameters(
080: JRHyperlink link, JRBaseObjectFactory factory) {
081: JRHyperlinkParameter[] linkParameters = link
082: .getHyperlinkParameters();
083: JRHyperlinkParameter[] parameters = null;
084: if (linkParameters != null && linkParameters.length > 0) {
085: parameters = new JRHyperlinkParameter[linkParameters.length];
086: for (int i = 0; i < linkParameters.length; i++) {
087: JRHyperlinkParameter parameter = linkParameters[i];
088: parameters[i] = factory
089: .getHyperlinkParameter(parameter);
090: }
091: }
092: return parameters;
093: }
094:
095: public JRExpression getHyperlinkAnchorExpression() {
096: return hyperlinkAnchorExpression;
097: }
098:
099: public JRExpression getHyperlinkPageExpression() {
100: return hyperlinkPageExpression;
101: }
102:
103: public JRHyperlinkParameter[] getHyperlinkParameters() {
104: return hyperlinkParameters;
105: }
106:
107: public JRExpression getHyperlinkReferenceExpression() {
108: return hyperlinkReferenceExpression;
109: }
110:
111: public byte getHyperlinkTarget() {
112: return hyperlinkTarget;
113: }
114:
115: public byte getHyperlinkType() {
116: return JRHyperlinkHelper.getHyperlinkType(this );
117: }
118:
119: public String getLinkType() {
120: return linkType;
121: }
122:
123: public JRExpression getHyperlinkTooltipExpression() {
124: return hyperlinkTooltipExpression;
125: }
126:
127: }
|