Java 类net.sf.jasperreports.engine.JRExpression 实例源码

项目:jasperreports    文件:JRFillCrosstab.java   
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;
}
项目:jasperreports    文件:TableReport.java   
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;
}
项目:jasperreports    文件:JRApiWriter.java   
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();
    }
}
项目:jasperreports    文件:JRFillCrosstab.java   
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;
}
项目:jasperreports    文件:JRGroovyGenerator.java   
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");
}
项目:jasperreports    文件:JRBshEvaluator.java   
/**
 *
 */
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)});
    }
}
项目:jasperreports    文件:JRDesignTextField.java   
/**
 * 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);
}
项目:jasperreports    文件:JRDesignCandlestickPlot.java   
/**
 *
 */
public void setRangeAxisMaxValueExpression(JRExpression rangeAxisMaxValueExpression)
{
    Object old = this.rangeAxisMaxValueExpression;
    this.rangeAxisMaxValueExpression = rangeAxisMaxValueExpression;
    getEventSupport().firePropertyChange(PROPERTY_RANGE_AXIS_MAXVALUE_EXPRESSION, old, this.rangeAxisMaxValueExpression);
}
项目:jasperreports    文件:JRXmlDigesterFactory.java   
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);
}
项目:jasperreports    文件:JRDesignBand.java   
/**
 *
 */
public void setPrintWhenExpression(JRExpression expression)
{
    Object old = this.printWhenExpression;
    this.printWhenExpression = expression;
    getEventSupport().firePropertyChange(PROPERTY_PRINT_WHEN_EXPRESSION, old, this.printWhenExpression);
}
项目:jasperreports    文件:JRDesignSubreport.java   
/**
 *
 */
public void setExpression(JRExpression expression)
{
    Object old = this.expression;
    this.expression = expression;
    getEventSupport().firePropertyChange(PROPERTY_EXPRESSION, old, this.expression);
}
项目:jasperreports    文件:JRCrosstabExpressionEvaluator.java   
@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);
}
项目:jasperreports    文件:MultiAxisDataService.java   
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;
}
项目:jasperreports    文件:JRFillDataset.java   
/**
 * 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);
            }
        }
    }
}
项目:jasperreports    文件:JRDesignTextField.java   
/**
 *
 */
public void setAnchorNameExpression(JRExpression anchorNameExpression)
{
    Object old = this.anchorNameExpression;
    this.anchorNameExpression = anchorNameExpression;
    getEventSupport().firePropertyChange(PROPERTY_ANCHOR_NAME_EXPRESSION, old, this.anchorNameExpression);
}
项目:jasperreports    文件:JRDesignAreaPlot.java   
@Override
public void setValueAxisLabelExpression(JRExpression valueAxisLabelExpression)
{
    Object old = this.valueAxisLabelExpression;
    this.valueAxisLabelExpression = valueAxisLabelExpression;
    getEventSupport().firePropertyChange(PROPERTY_VALUE_AXIS_LABEL_EXPRESSION, old, this.valueAxisLabelExpression);
}
项目:jasperreports    文件:JRVerifier.java   
public void verifyExpression(JRExpression expression, Object parent, String mandatoryMessage)
{
    if (expression == null)
    {
        if (mandatoryMessage != null)
        {
            addBrokenRule(mandatoryMessage, parent);
        }
    }
}
项目:jasperreports    文件:BarcodeXmlWriter.java   
@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);
    }
}
项目:jasperreports    文件:JRDesignGroup.java   
/**
 *
 */
public void setExpression(JRExpression expression)
{
    Object old = this.expression;
    this.expression = expression;
    getEventSupport().firePropertyChange(PROPERTY_EXPRESSION, old, this.expression);
}
项目:jasperreports    文件:JRDesignChart.java   
/**
 *
 */
public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression)
{
    Object old = this.hyperlinkPageExpression;
    this.hyperlinkPageExpression = hyperlinkPageExpression;
    getEventSupport().firePropertyChange(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION, old, this.hyperlinkPageExpression);
}
项目:jasperreports    文件:JRDesignChart.java   
/**
 *
 */
public void setHyperlinkWhenExpression(JRExpression hyperlinkWhenExpression)
{
    Object old = this.hyperlinkWhenExpression;
    this.hyperlinkWhenExpression = hyperlinkWhenExpression;
    getEventSupport().firePropertyChange(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION, old, this.hyperlinkWhenExpression);
}
项目:jasperreports    文件:JRDesignTimeSeriesPlot.java   
/**
 *
 */
public void setRangeAxisMinValueExpression(JRExpression rangeAxisMinValueExpression)
{
    Object old = this.rangeAxisMinValueExpression;
    this.rangeAxisMinValueExpression = rangeAxisMinValueExpression;
    getEventSupport().firePropertyChange(PROPERTY_RANGE_AXIS_MINVALUE_EXPRESSION, old, this.rangeAxisMinValueExpression);
}
项目:jasperreports    文件:JRXmlBaseWriter.java   
@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);
    }
}
项目:jasperreports    文件:JRBaseChart.java   
@Override
public JRExpression getHyperlinkWhenExpression()
{
    return hyperlinkWhenExpression;
}
项目:jasperreports    文件:JRFillHighLowDataset.java   
@Override
public JRExpression getDateExpression()
{
    return ((JRHighLowDataset)parent).getDateExpression();
}
项目:jasperreports    文件:JRHorizontalFiller.java   
/**
 *
 */
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
}
项目:jasperreports    文件:DefaultChartTheme.java   
/**
 *
 */
protected final Object evaluateExpression(JRExpression expression) throws JRException
{
    return chartContext.evaluateExpression(expression);
}
项目:jasperreports    文件:JRFillLinePlot.java   
@Override
public JRExpression getDomainAxisMinValueExpression()
{
    return ((JRLinePlot)parent).getDomainAxisMinValueExpression();
}
项目:jasperreports    文件:JRFillGanttSeries.java   
@Override
public JRExpression getLabelExpression()
{
    return parent.getLabelExpression();
}
项目:jasperreports    文件:JRBaseTimeSeries.java   
@Override
public JRExpression getSeriesExpression()
{
    return seriesExpression;
}
项目:jasperreports    文件:JRFillCandlestickPlot.java   
@Override
public JRExpression getTimeAxisLabelExpression()
{
    return ((JRCandlestickPlot)parent).getTimeAxisLabelExpression();
}
项目:jasperreports    文件:JRFillDatasetRun.java   
@Override
public JRExpression getDataSourceExpression()
{
    return dataSourceExpression;
}
项目:jasperreports    文件:FillChartSettings.java   
/**
 * @see net.sf.jasperreports.engine.JRHyperlink#getHyperlinkWhenExpression()
 */
@Override
public JRExpression getHyperlinkWhenExpression() {

    return parent.getHyperlinkWhenExpression();
}
项目:jasperreports    文件:FillXYSeries.java   
@Override
public JRExpression getXValueExpression()
{
    return parent.getXValueExpression();
}
项目:jasperreports    文件:JRFillChart.java   
@Override
public JRExpression getHyperlinkAnchorExpression()
{
    return ((JRChart)parent).getHyperlinkAnchorExpression();
}
项目:jasperreports    文件:JRDesignSubreport.java   
@Override
public JRExpression getExpression()
{
    return this.expression;
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Returns a collection of all report expressions.
 */
public Collection<JRExpression> getExpressions()
{
    return JRExpressionCollector.collectExpressions(DefaultJasperReportsContext.getInstance(), this);
}
项目:jasperreports    文件:JRDesignImage.java   
@Override
public JRExpression getExpression()
{
    return expression;
}
项目:jasperreports    文件:SimpleChartTheme.java   
/**
 *
 */
protected final String evaluateTextExpression(JRExpression expression) throws JRException
{
    return getChartContext().evaluateTextExpression(expression);
}
项目:jasperreports    文件:JRBaseLinePlot.java   
@Override
public JRExpression getDomainAxisMinValueExpression(){
    return domainAxisMinValueExpression;
}