1 28 package net.sf.jasperreports.engine.fill; 29 30 import net.sf.jasperreports.engine.JRException; 31 import net.sf.jasperreports.engine.JRExpression; 32 import net.sf.jasperreports.engine.JRHyperlink; 33 import net.sf.jasperreports.engine.JRHyperlinkParameter; 34 import net.sf.jasperreports.engine.JRPrintHyperlink; 35 import net.sf.jasperreports.engine.JRPrintHyperlinkParameter; 36 import net.sf.jasperreports.engine.JRPrintHyperlinkParameters; 37 import net.sf.jasperreports.engine.base.JRBasePrintHyperlink; 38 39 40 46 public class JRFillHyperlinkHelper 47 { 48 49 59 public static JRPrintHyperlinkParameters evaluateHyperlinkParameters( 60 JRHyperlink hyperlink, 61 JRFillExpressionEvaluator expressionEvaluator, 62 byte evaluationType) throws JRException 63 { 64 JRHyperlinkParameter[] hyperlinkParameters = hyperlink.getHyperlinkParameters(); 65 JRPrintHyperlinkParameters printParameters; 66 if (hyperlinkParameters == null) 67 { 68 printParameters = null; 69 } 70 else 71 { 72 printParameters = new JRPrintHyperlinkParameters(); 73 for (int i = 0; i < hyperlinkParameters.length; i++) 74 { 75 JRHyperlinkParameter hyperlinkParameter = hyperlinkParameters[i]; 76 JRExpression valueExpression = hyperlinkParameter.getValueExpression(); 77 Class valueClass; 78 Object value; 79 if (valueExpression == null) 80 { 81 value = null; 82 valueClass = Object .class; 83 } 84 else 85 { 86 value = expressionEvaluator.evaluate(valueExpression, evaluationType); 87 valueClass = valueExpression.getValueClass(); 88 } 89 90 JRPrintHyperlinkParameter printParam = new JRPrintHyperlinkParameter(hyperlinkParameter.getName(), valueClass.getName(), value); 91 printParameters.addParameter(printParam); 92 } 93 } 94 return printParameters; 95 } 96 97 98 107 public static JRPrintHyperlink evaluateHyperlink(JRHyperlink hyperlink, 108 JRFillExpressionEvaluator expressionEvaluator, 109 byte evaluationType) throws JRException 110 { 111 JRBasePrintHyperlink printHyperlink = new JRBasePrintHyperlink(); 112 printHyperlink.setLinkType(hyperlink.getLinkType()); 113 printHyperlink.setHyperlinkTarget(hyperlink.getHyperlinkTarget()); 114 printHyperlink.setHyperlinkReference((String ) expressionEvaluator.evaluate(hyperlink.getHyperlinkReferenceExpression(), evaluationType)); 115 printHyperlink.setHyperlinkAnchor((String ) expressionEvaluator.evaluate(hyperlink.getHyperlinkAnchorExpression(), evaluationType)); 116 printHyperlink.setHyperlinkPage((Integer ) expressionEvaluator.evaluate(hyperlink.getHyperlinkPageExpression(), evaluationType)); 117 printHyperlink.setHyperlinkTooltip((String ) expressionEvaluator.evaluate(hyperlink.getHyperlinkTooltipExpression(), evaluationType)); 118 printHyperlink.setHyperlinkParameters(evaluateHyperlinkParameters(hyperlink, expressionEvaluator, evaluationType)); 119 return printHyperlink; 120 } 121 } 122 | Popular Tags |