private BucketDefinition createServiceBucket(JRCrosstabGroup group, int groupIndex, byte evaluation) throws JRException { JRCrosstabBucket bucket = group.getBucket(); Comparator<Object> comparator = null; JRExpression comparatorExpression = bucket.getComparatorExpression(); if (comparatorExpression != null) { comparator = (Comparator<Object>) evaluateExpression(comparatorExpression, evaluation); } BucketOrderer orderer = createOrderer(group, groupIndex, comparator); BucketDefinition bucketDefinition = new BucketDefinition(bucket.getValueClass(), orderer, comparator, bucket.getOrder(), group.getTotalPositionValue()); Boolean mergeHeaderCells = group.getMergeHeaderCells(); // by default the header cells are merged bucketDefinition.setMergeHeaderCells(mergeHeaderCells == null || mergeHeaderCells); return bucketDefinition; }
protected JRExpression getColumnHeaderLabelExpression(Cell header) { List<JRChild> detailElements = header == null ? null : header.getChildren(); // only consider cells with a single text fields if (detailElements == null || detailElements.size() != 1) { return null; } JRChild detailElement = detailElements.get(0); if (detailElement instanceof JRTextField) { return ((JRTextField) detailElement).getExpression(); } if (detailElement instanceof JRStaticText) { return builtinEvaluatorFactory.createConstantExpression(((JRStaticText)detailElement).getText()); } return null; }
public void writeExpression( JRExpression expression, String parentName, String expressionSuffix, String defaultClassName) { if (expression != null) { String expressionName = parentName + expressionSuffix; write( "JRDesignExpression " + expressionName + " = new JRDesignExpression();\n"); write( expressionName + ".setId({0, number, #});\n", expression.getId()); write( expressionName + ".setType({0});\n", expression.getType()); write( expressionName + ".setText(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(expression.getText())); write( parentName + ".set" + expressionSuffix + "(" + expressionName + ");\n"); flush(); } }
protected BucketOrderer createOrderer(JRCrosstabGroup group, int groupIndex, Comparator<Object> bucketComparator) { BucketOrderer orderer = null; if (group instanceof JRCrosstabRowGroup && orderByColumnInfo != null && orderByColumnInfo.getOrder() != null // ordering by column only applies to nesting groups is they are not already ordered && (groupIndex == rowGroups.length - 1 || group.getBucket().getOrder() == BucketOrder.NONE)) { orderer = new OrderByColumnOrderer(orderByColumnInfo); } if (orderer == null) { JRCrosstabBucket bucket = group.getBucket(); JRExpression orderByExpression = bucket.getOrderByExpression(); if (orderByExpression != null && bucket.getOrder() != BucketOrder.NONE) { if (log.isDebugEnabled()) { log.debug("using order by expression to order group " + group.getName()); } // when we have an order by expression, the comparator is applied to order values Comparator<Object> orderValueComparator = BucketDefinition.createOrderComparator(bucketComparator, bucket.getOrder()); orderer = new BucketExpressionOrderer(orderByExpression, orderValueComparator); } } return orderer; }
protected void writeExpression(StringBuilder expressionBuffer, JRExpression expression, byte evaluationType) { expressionBuffer.append("if (id == "); expressionBuffer.append(sourceTask.getExpressionId(expression)); expressionBuffer.append(")\n"); expressionBuffer.append(" {\n"); expressionBuffer.append(" value = ("); expressionBuffer.append(this.generateExpression(expression, evaluationType)); expressionBuffer.append(");\n"); expressionBuffer.append(" }\n"); }
/** * */ public <T> void verify(Collection<T> expressions) throws JRException { try { interpreter.eval("bshEvaluator = createBshEvaluator()"); if (expressions != null) { for(Iterator<T> it = expressions.iterator(); it.hasNext();) { JRExpression expression = (JRExpression)it.next(); interpreter.eval("bshEvaluator.evaluateOld(" + expression.getId() + ")"); } } } catch(TargetError te) { //ignore } catch(EvalError e) { throw new JRException( EXCEPTION_MESSAGE_KEY_EXPRESSIONS_TESTING_ERROR, new Object[]{e.getMessage(), e.getErrorLineNumber(), extractLineContent(e)}); } }
/** * Sets the expression which will be used to generate the hyperlink tooltip. * * @param hyperlinkTooltipExpression the expression which will be used to generate the hyperlink tooltip * @see #getHyperlinkTooltipExpression() */ public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) { Object old = this.hyperlinkTooltipExpression; this.hyperlinkTooltipExpression = hyperlinkTooltipExpression; getEventSupport().firePropertyChange(JRDesignHyperlink.PROPERTY_HYPERLINK_TOOLTIP_EXPRESSION, old, this.hyperlinkTooltipExpression); }
/** * */ public void setRangeAxisMaxValueExpression(JRExpression rangeAxisMaxValueExpression) { Object old = this.rangeAxisMaxValueExpression; this.rangeAxisMaxValueExpression = rangeAxisMaxValueExpression; getEventSupport().firePropertyChange(PROPERTY_RANGE_AXIS_MAXVALUE_EXPRESSION, old, this.rangeAxisMaxValueExpression); }
protected static void addGenericElementRules(Digester digester) { String genericElementPattern = "*/" + JRXmlConstants.ELEMENT_genericElement; digester.addFactoryCreate(genericElementPattern, JRGenericElementFactory.class); digester.addSetNext(genericElementPattern, "addElement", JRDesignElement.class.getName()); String genericElementTypePattern = genericElementPattern + "/" + JRXmlConstants.ELEMENT_genericElementType; digester.addFactoryCreate(genericElementTypePattern, JRGenericElementTypeFactory.class); digester.addSetNext(genericElementTypePattern, "setGenericType", JRGenericElementType.class.getName()); String genericElementParameterPattern = genericElementPattern + "/" + JRXmlConstants.ELEMENT_genericElementParameter; digester.addFactoryCreate(genericElementParameterPattern, JRGenericElementParameterFactory.class); digester.addSetNext(genericElementParameterPattern, "addParameter", JRGenericElementParameter.class.getName()); String genericElementParameterExpressionPattern = genericElementParameterPattern + "/" + JRXmlConstants.ELEMENT_genericElementParameter_valueExpression; @SuppressWarnings("deprecation") Class<?> depArbitraryExprFactory = JRExpressionFactory.ArbitraryExpressionFactory.class; digester.addFactoryCreate(genericElementParameterExpressionPattern, depArbitraryExprFactory); digester.addSetNext(genericElementParameterExpressionPattern, "setValueExpression", JRExpression.class.getName()); digester.addCallMethod(genericElementParameterExpressionPattern, "setText", 0); }
/** * */ public void setPrintWhenExpression(JRExpression expression) { Object old = this.printWhenExpression; this.printWhenExpression = expression; getEventSupport().firePropertyChange(PROPERTY_PRINT_WHEN_EXPRESSION, old, this.printWhenExpression); }
/** * */ public void setExpression(JRExpression expression) { Object old = this.expression; this.expression = expression; getEventSupport().firePropertyChange(PROPERTY_EXPRESSION, old, this.expression); }
@Override public Object evaluate(JRExpression expression, byte evaluationType) throws JRException { if (evaluationType != JRExpression.EVALUATION_DEFAULT) { throw new JRException( EXCEPTION_MESSAGE_KEY_EVALUATION_TYPE_NOT_SUPPORTED, (Object[])null ); } return evaluator.evaluate(expression); }
protected Object evaluateBucketValue(JRCalculator calculator, DataAxisLevel level) throws JRExpressionEvalException { DataLevelBucket bucket = level.getBucket(); Object mainValue = calculator.evaluate(bucket.getExpression()); JRExpression labelExpression = bucket.getLabelExpression(); List<DataLevelBucketProperty> bucketProperties = bucket.getBucketProperties(); Object bucketValue; if (labelExpression == null && (bucketProperties == null || bucketProperties.isEmpty())) { bucketValue = mainValue; } else { String label = labelExpression == null ? null : (String) calculator.evaluate(labelExpression); Object[] propertyValues; if (bucketProperties == null || bucketProperties.isEmpty()) { propertyValues = null; } else { // evaluate property values //FIXME avoid evaluating these for each record propertyValues = new Object[bucketProperties.size()]; for (ListIterator<DataLevelBucketProperty> it = bucketProperties.listIterator(); it.hasNext();) { DataLevelBucketProperty bucketProperty = it.next(); propertyValues[it.previousIndex()] = calculator.evaluate(bucketProperty.getExpression()); } } // wrap the main value and property values together bucketValue = new ValuePropertiesWrapper(mainValue, label, propertyValues); } return bucketValue; }
/** * Sets the parameter values from the values map. * * @param parameterValues the values map * @throws JRException */ private void evaluateParameterValues(ParameterEvaluationTimeEnum evaluationTime, Map<String,Object> parameterValues) throws JRException { if (parameters != null && parameters.length > 0) { ParameterEvaluationTimeEnum defaultEvaluationTime = getDefaultParameterEvaluationTime(); for (int i = 0; i < parameters.length; i++) { JRFillParameter parameter = parameters[i]; String paramName = parameter.getName(); ParameterEvaluationTimeEnum paramEvalTime = parameter.getEvaluationTime() == null ? defaultEvaluationTime : parameter.getEvaluationTime(); if ( !parameterValues.containsKey(paramName) //cheaper to test this first && !parameter.isSystemDefined() //cheaper to test this first && evaluationTime == paramEvalTime && (!isIncludedInDataCache(parameter) || cachedDataset == null) ) { Object value = calculator.evaluate(parameter.getDefaultValueExpression(), JRExpression.EVALUATION_DEFAULT); if (value != null) { parameterValues.put(paramName, value); } setParameter(parameter, value); } } } }
/** * */ public void setAnchorNameExpression(JRExpression anchorNameExpression) { Object old = this.anchorNameExpression; this.anchorNameExpression = anchorNameExpression; getEventSupport().firePropertyChange(PROPERTY_ANCHOR_NAME_EXPRESSION, old, this.anchorNameExpression); }
@Override public void setValueAxisLabelExpression(JRExpression valueAxisLabelExpression) { Object old = this.valueAxisLabelExpression; this.valueAxisLabelExpression = valueAxisLabelExpression; getEventSupport().firePropertyChange(PROPERTY_VALUE_AXIS_LABEL_EXPRESSION, old, this.valueAxisLabelExpression); }
public void verifyExpression(JRExpression expression, Object parent, String mandatoryMessage) { if (expression == null) { if (mandatoryMessage != null) { addBrokenRule(mandatoryMessage, parent); } } }
@SuppressWarnings("deprecation") protected void writeExpression(String name, JRExpression expression, boolean writeClass) throws IOException { if(versionComparator.compare(version, JRConstants.VERSION_4_1_1) >= 0 ) { xmlWriteHelper.writeExpression(name, expression); } else { xmlWriteHelper.writeExpression(name, expression, writeClass); } }
/** * */ public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) { Object old = this.hyperlinkPageExpression; this.hyperlinkPageExpression = hyperlinkPageExpression; getEventSupport().firePropertyChange(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION, old, this.hyperlinkPageExpression); }
/** * */ public void setHyperlinkWhenExpression(JRExpression hyperlinkWhenExpression) { Object old = this.hyperlinkWhenExpression; this.hyperlinkWhenExpression = hyperlinkWhenExpression; getEventSupport().firePropertyChange(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION, old, this.hyperlinkWhenExpression); }
/** * */ public void setRangeAxisMinValueExpression(JRExpression rangeAxisMinValueExpression) { Object old = this.rangeAxisMinValueExpression; this.rangeAxisMinValueExpression = rangeAxisMinValueExpression; getEventSupport().firePropertyChange(PROPERTY_RANGE_AXIS_MINVALUE_EXPRESSION, old, this.rangeAxisMinValueExpression); }
@SuppressWarnings("deprecation") protected void writeExpression(String name, JRExpression expression, boolean writeClass) throws IOException { if(isNewerVersionOrEqual(JRConstants.VERSION_4_1_1)) { writer.writeExpression(name, expression); } else { writer.writeExpression(name, expression, writeClass); } }
@Override public JRExpression getHyperlinkWhenExpression() { return hyperlinkWhenExpression; }
@Override public JRExpression getDateExpression() { return ((JRHighLowDataset)parent).getDateExpression(); }
/** * */ private void fillSummaryNoLastFooterNewPage() throws JRException { // do nothing about groupFooterPositionElementRange because the following fillColumnFooter will do fillColumnFooters(JRExpression.EVALUATION_DEFAULT); fillPageFooter(JRExpression.EVALUATION_DEFAULT); summary.evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT); if (summary.isToPrint()) { resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, true); resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT); resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT); scriptlet.callBeforePageInit(); calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE); scriptlet.callAfterPageInit(); addPage(false); if (isSummaryWithPageHeaderAndFooter) { fillPageHeader(JRExpression.EVALUATION_DEFAULT); } summary.evaluate(JRExpression.EVALUATION_DEFAULT); JRPrintBand printBand = summary.fill(pageHeight - bottomMargin - offsetY - (isSummaryWithPageHeaderAndFooter?pageFooter.getHeight():0)); if (summary.willOverflow() && summary.isSplitPrevented() && !summary.isSplitTypePreventInhibited()) { if (isSummaryWithPageHeaderAndFooter) { fillPageFooter(JRExpression.EVALUATION_DEFAULT); } resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, true); resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT); resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT); scriptlet.callBeforePageInit(); calculator.initializeVariables(ResetTypeEnum.PAGE, IncrementTypeEnum.PAGE); scriptlet.callAfterPageInit(); addPage(false); if (isSummaryWithPageHeaderAndFooter) { fillPageHeader(JRExpression.EVALUATION_DEFAULT); } printBand = summary.refill( JRExpression.EVALUATION_DEFAULT, pageHeight - bottomMargin - offsetY - (isSummaryWithPageHeaderAndFooter?pageFooter.getHeight():0) ); } fillBand(printBand); offsetY += printBand.getHeight(); isCrtRecordOnPage = true; isCrtRecordOnColumn = true; /* */ fillSummaryOverflow(); } //DONE }
/** * */ protected final Object evaluateExpression(JRExpression expression) throws JRException { return chartContext.evaluateExpression(expression); }
@Override public JRExpression getDomainAxisMinValueExpression() { return ((JRLinePlot)parent).getDomainAxisMinValueExpression(); }
@Override public JRExpression getLabelExpression() { return parent.getLabelExpression(); }
@Override public JRExpression getSeriesExpression() { return seriesExpression; }
@Override public JRExpression getTimeAxisLabelExpression() { return ((JRCandlestickPlot)parent).getTimeAxisLabelExpression(); }
@Override public JRExpression getDataSourceExpression() { return dataSourceExpression; }
/** * @see net.sf.jasperreports.engine.JRHyperlink#getHyperlinkWhenExpression() */ @Override public JRExpression getHyperlinkWhenExpression() { return parent.getHyperlinkWhenExpression(); }
@Override public JRExpression getXValueExpression() { return parent.getXValueExpression(); }
@Override public JRExpression getHyperlinkAnchorExpression() { return ((JRChart)parent).getHyperlinkAnchorExpression(); }
@Override public JRExpression getExpression() { return this.expression; }
/** * Returns a collection of all report expressions. */ public Collection<JRExpression> getExpressions() { return JRExpressionCollector.collectExpressions(DefaultJasperReportsContext.getInstance(), this); }
@Override public JRExpression getExpression() { return expression; }
/** * */ protected final String evaluateTextExpression(JRExpression expression) throws JRException { return getChartContext().evaluateTextExpression(expression); }
@Override public JRExpression getDomainAxisMinValueExpression(){ return domainAxisMinValueExpression; }