public SubreportFillPart(SubreportPartComponent subreportPart, JRFillObjectFactory factory) { this.subreportPart = subreportPart; this.expressionEvaluator = factory.getExpressionEvaluator(); this.returnValues = new FillReturnValues(subreportPart.getReturnValues(), factory, factory.getReportFiller()); this.returnValuesSource = new AbstractVariableReturnValueSourceContext() { @Override public Object getValue(CommonReturnValue returnValue) { return subreportFiller.getVariableValue(((VariableReturnValue)returnValue).getFromVariable()); } @Override public JRVariable getToVariable(String name) { return fillContext.getFiller().getVariable(name); } @Override public JRVariable getFromVariable(String name) { return subreportFiller.getVariable(name); } }; }
/** * */ public JRBaseVariable getVariable(JRVariable variable) { JRBaseVariable baseVariable = null; if (variable != null) { baseVariable = (JRBaseVariable)get(variable); if (baseVariable == null) { baseVariable = new JRBaseVariable(variable, this); } } return baseVariable; }
/** * */ protected JRBaseVariable(JRVariable variable, JRBaseObjectFactory factory) { factory.put(variable, this); name = variable.getName(); valueClassName = variable.getValueClassName(); incrementerFactoryClassName = variable.getIncrementerFactoryClassName(); resetTypeValue = variable.getResetTypeValue(); incrementTypeValue = variable.getIncrementTypeValue(); calculationValue = variable.getCalculationValue(); isSystemDefined = variable.isSystemDefined(); expression = factory.getExpression(variable.getExpression()); initialValueExpression = factory.getExpression(variable.getInitialValueExpression()); resetGroup = factory.getGroup(variable.getResetGroup()); incrementGroup = factory.getGroup(variable.getIncrementGroup()); }
/** * */ private void writeVariable(JRVariable variable) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_variable); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, variable.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_class, variable.getValueClassName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_resetType, variable.getResetTypeValue(), ResetTypeEnum.REPORT); if (variable.getResetGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_resetGroup, variable.getResetGroup().getName()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementType, variable.getIncrementTypeValue(), IncrementTypeEnum.NONE); if (variable.getIncrementGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_incrementGroup, variable.getIncrementGroup().getName()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, variable.getCalculationValue(), CalculationEnum.NOTHING); writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, variable.getIncrementerFactoryClassName()); writeExpression(JRXmlConstants.ELEMENT_variableExpression, variable.getExpression(), false); writeExpression(JRXmlConstants.ELEMENT_initialValueExpression, variable.getInitialValueExpression(), false); writer.closeElement(); }
/** * */ private void writeVariable( JRVariable variable, String variableName) { if(variable != null) { String resetGroupName = getGroupName( variable.getResetGroup()); String incrementGroupName = getGroupName( variable.getIncrementGroup()); write( "JRDesignVariable " + variableName + " = new JRDesignVariable();\n"); write( variableName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(variable.getName())); write( variableName + ".setValueClassName(\"{0}\");\n", variable.getValueClassName()); write( variableName + ".setResetType({0});\n", variable.getResetTypeValue(), ResetTypeEnum.REPORT); write( variableName + ".setResetGroup({0});\n", resetGroupName); write( variableName + ".setIncrementType({0});\n", variable.getIncrementTypeValue(), IncrementTypeEnum.NONE); write( variableName + ".setIncrementGroup({0});\n", incrementGroupName); write( variableName + ".setCalculation({0});\n", variable.getCalculationValue(), CalculationEnum.NOTHING); write( variableName + ".setIncrementerFactoryClass({0}.class);\n", JRStringUtil.escapeJavaStringLiteral(variable.getIncrementerFactoryClassName())); writeExpression( variable.getExpression(), variableName, "Expression"); writeExpression( variable.getInitialValueExpression(), variableName, "InitialValueExpression"); flush(); } }
protected JRSourceCompileTask( JasperDesign jasperDesign, String unitName, JRExpressionCollector expressionCollector, Map<String, ? extends JRParameter> parametersMap, Map<String, JRField> fieldsMap, Map<String, JRVariable> variablesMap, JRVariable[] variables, boolean onlyDefaultEvaluation ) { this.jasperDesign = jasperDesign; this.unitName = unitName; this.expressionCollector = expressionCollector; this.parametersMap = parametersMap; this.fieldsMap = fieldsMap; this.variablesMap = variablesMap; this.variables = variables; this.expressions = expressionCollector.getCompiledExpressions(); this.onlyDefaultEvaluation = onlyDefaultEvaluation; }
private static JRDesignVariable createPageCountVariable() { JRDesignExpression expression; JRDesignVariable variable; variable = new JRDesignVariable(); variable.setName(JRVariable.PAGE_COUNT); variable.setValueClass(Integer.class); variable.setResetType(ResetTypeEnum.PAGE); variable.setCalculation(CalculationEnum.COUNT); variable.setSystemDefined(true); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(1)"); variable.setExpression(expression); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(0)"); variable.setInitialValueExpression(expression); return variable; }
private static JRDesignVariable createColumnNumberVariable() { JRDesignExpression expression; JRDesignVariable variable; variable = new JRDesignVariable(); variable.setName(JRVariable.COLUMN_NUMBER); variable.setValueClass(Integer.class); //variable.setResetType(JRVariable.RESET_TYPE_COLUMN); variable.setResetType(ResetTypeEnum.PAGE); variable.setCalculation(CalculationEnum.SYSTEM); variable.setSystemDefined(true); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); //expression.setText("($V{COLUMN_NUMBER} != null)?(Integer.valueOf($V{COLUMN_NUMBER}.intValue() + 1)):(Integer.valueOf(1))"); expression.setText("new java.lang.Integer(1)"); variable.setInitialValueExpression(expression); return variable; }
private static JRDesignVariable createPageNumberVariable() { JRDesignVariable variable = new JRDesignVariable(); variable.setName(JRVariable.PAGE_NUMBER); variable.setValueClass(Integer.class); //variable.setResetType(JRVariable.RESET_TYPE_PAGE); variable.setResetType(ResetTypeEnum.REPORT); variable.setCalculation(CalculationEnum.SYSTEM); variable.setSystemDefined(true); JRDesignExpression expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); //expression.setText("($V{PAGE_NUMBER} != null)?(Integer.valueOf($V{PAGE_NUMBER}.intValue() + 1)):(Integer.valueOf(1))"); expression.setText("new java.lang.Integer(1)"); variable.setInitialValueExpression(expression); return variable; }
private static JRDesignVariable createColumnCountVariable() { JRDesignVariable variable; JRDesignExpression expression; variable = new JRDesignVariable(); variable.setName(JRVariable.COLUMN_COUNT); variable.setValueClass(Integer.class); variable.setResetType(ResetTypeEnum.COLUMN); variable.setCalculation(CalculationEnum.COUNT); variable.setSystemDefined(true); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(1)"); variable.setExpression(expression); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(0)"); variable.setInitialValueExpression(expression); return variable; }
private static JRDesignVariable createReportCountVariable() { JRDesignVariable variable = new JRDesignVariable(); variable.setName(JRVariable.REPORT_COUNT); variable.setValueClass(Integer.class); variable.setResetType(ResetTypeEnum.REPORT); variable.setCalculation(CalculationEnum.COUNT); variable.setSystemDefined(true); JRDesignExpression expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(1)"); variable.setExpression(expression); expression = new JRDesignExpression(); //expression.setValueClass(Integer.class); expression.setText("new java.lang.Integer(0)"); variable.setInitialValueExpression(expression); return variable; }
/** * Removes a variable from the dataset. * * @param variable the variable to be removed * @return the variable to be removed */ public JRVariable removeVariable(JRVariable variable) { if (variable != null) { int idx = variablesList.indexOf(variable); if (idx >= 0) { variablesList.remove(idx); variablesMap.remove(variable.getName()); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_VARIABLES, variable, idx); } } return variable; }
private void setVariables(JRDataset dataset, JRFillObjectFactory factory) { JRVariable[] jrVariables = dataset.getVariables(); if (jrVariables != null && jrVariables.length > 0) { List<JRFillVariable> variableList = new ArrayList<JRFillVariable>(jrVariables.length * 3); variablesMap = new HashMap<String,JRFillVariable>(); for (int i = 0; i < jrVariables.length; i++) { addVariable(jrVariables[i], variableList, factory); } setVariables(variableList); } }
private JRVariable createHelperVariable(JRVariable variable, String nameSuffix, CalculationEnum calculation) { JRDesignVariable helper = new JRDesignVariable(); helper.setName(variable.getName() + nameSuffix); helper.setValueClassName(variable.getValueClassName()); helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName()); helper.setResetType(variable.getResetTypeValue()); helper.setResetGroup(variable.getResetGroup()); helper.setIncrementType(variable.getIncrementTypeValue()); helper.setIncrementGroup(variable.getIncrementGroup()); helper.setCalculation(calculation); helper.setSystemDefined(true); helper.setExpression(variable.getExpression()); return helper; }
private JRVariable createDistinctCountHelperVariable(JRVariable variable) { JRDesignVariable helper = new JRDesignVariable(); helper.setName(variable.getName() + "_DISTINCT_COUNT"); helper.setValueClassName(variable.getValueClassName()); helper.setIncrementerFactoryClassName(JRDistinctCountIncrementerFactory.class.getName()); helper.setResetType(ResetTypeEnum.REPORT); if (variable.getIncrementTypeValue() != IncrementTypeEnum.NONE) { helper.setResetType(ResetTypeEnum.getByValue(variable.getIncrementTypeValue().getValue())); } helper.setResetGroup(variable.getIncrementGroup()); helper.setCalculation(CalculationEnum.NOTHING); helper.setSystemDefined(true); helper.setExpression(variable.getExpression()); return helper; }
/** * */ public JRFillVariable getVariable(JRVariable variable) { JRFillVariable fillVariable = null; if (variable != null) { fillVariable = (JRFillVariable)get(variable); if (fillVariable == null) { fillVariable = new JRFillVariable(variable, this); } } return fillVariable; }
/** * Set the listener (only where they are not already set) to listen the changes * to a dataset and discard the cached interpreter for that dataset when they happen. * The listeners are set on both the dataset and his children * * @param parentDataset */ private static void setDatasetListners(JRDesignDataset parentDataset){ addEventIfnecessary(parentDataset, parentDataset); for(JRVariable var : parentDataset.getVariables()){ if (var instanceof JRChangeEventsSupport) addEventIfnecessary((JRChangeEventsSupport)var, parentDataset); } for(JRSortField sortField : parentDataset.getSortFields()){ if (sortField instanceof JRChangeEventsSupport) addEventIfnecessary((JRChangeEventsSupport)sortField, parentDataset); } for(JRParameter parameter : parentDataset.getParameters()){ if (parameter instanceof JRChangeEventsSupport) addEventIfnecessary((JRChangeEventsSupport)parameter, parentDataset); } for(JRField field : parentDataset.getFields()){ if (field instanceof JRChangeEventsSupport) addEventIfnecessary((JRChangeEventsSupport)field, parentDataset); } }
@Override public void execute() { oldIndex = jrDataset.getVariablesList().indexOf(jrVariable); try { int i = 0; for (JRVariable v : jrDataset.getVariablesList()) { if (v.isSystemDefined()) i++; else break; } newIndex = Math.max(newIndex, i); jrDataset.removeVariable(jrVariable); if (newIndex < 0 || newIndex > jrDataset.getVariablesList().size()) jrDataset.addVariable(jrVariable); else jrDataset.addVariable(newIndex, jrVariable); } catch (JRException e) { e.printStackTrace(); } }
@Override public void propertyChange(PropertyChangeEvent evt) { if (JRDesignGroup.PROPERTY_NAME.equals(evt.getPropertyName())) { // Temporary fix for the Community Bug #2991 // Should be done on JR-side. Let's keep the cache map of groups in sync. JRDesignGroup jrGroup = (JRDesignGroup) getValue(); JasperDesign design = getJasperDesign(); if (design != null){ design.getGroupsMap().remove(evt.getOldValue()); design.getGroupsMap().put(jrGroup.getName(), jrGroup); //JRDesignDataset dataset = ModelUtils.getDataset(this); JRVariable groupVar = getJasperDesign().getVariablesMap().get(evt.getOldValue() + "_COUNT"); if (groupVar != null){ //This should launch the propertyChange event on the variable so the map is updated also for it ((JRDesignVariable)groupVar).setName(jrGroup.getName() + "_COUNT"); } } } super.propertyChange(evt); }
public ExpObject(Object obj) { if (obj instanceof JRField) { this.name = ((JRField) obj).getName(); this.type = TYPE_FIELD; this.classType = ((JRField) obj).getValueClassName(); } else if (obj instanceof JRParameter) { this.name = ((JRParameter) obj).getName(); this.type = TYPE_PARAM; this.classType = ((JRParameter) obj).getValueClassName(); } else if (obj instanceof JRVariable) { this.name = ((JRVariable) obj).getName(); this.type = TYPE_VARIABLE; this.classType = ((JRVariable) obj).getValueClassName(); } else { this.name = "" + obj; } }
public String getGroupMeasureName() { Object obj = jComboBoxGroup.getSelectedItem(); if (obj instanceof JRField) { return ((JRField)obj).getName(); } else if (obj instanceof JRParameter) { return ((JRParameter)obj).getName(); } else if (obj instanceof JRVariable) { return ((JRVariable)obj).getName(); } return ""+obj; }
public String getExpressionClass(String groupByType) { Object obj = jComboBoxGroup.getSelectedItem(); if (groupByType !=null && !groupByType.equals(I18n.getString("GroupPanel.Function.Unique")) ) { return "java.lang.String"; } if (obj instanceof JRField) { return ((JRField)obj).getValueClassName(); } else if (obj instanceof JRParameter) { return ((JRParameter)obj).getValueClassName(); } else if (obj instanceof JRVariable) { return ((JRVariable)obj).getValueClassName(); } return "java.lang.String"; }
public ExpObject(Object obj) { if (obj instanceof JRField) { this.name = ((JRField)obj).getName(); this.type = TYPE_FIELD; this.classType = ((JRField)obj).getValueClassName(); } else if (obj instanceof JRParameter) { this.name = ((JRParameter)obj).getName(); this.type = TYPE_PARAM; this.classType = ((JRParameter)obj).getValueClassName(); } else if (obj instanceof JRVariable) { this.name = ((JRVariable)obj).getName(); this.type = TYPE_VARIABLE; this.classType = ((JRVariable)obj).getValueClassName(); } else { this.name = "" + obj; } }
public List<CompletionItem> getExpressionContextVariables() { List<CompletionItem> list = new ArrayList<CompletionItem>(); ExpressionContext ec = ExpressionContext.getGlobalContext(); if (ec == null) return list; for (JRDesignDataset dataset : ec.getDatasets()) { JRVariable[] variables = dataset.getVariables(); for (int i=0; i<variables.length; ++i) { list.add(CompletionItem.create("$V{" + variables[i].getName() + "}", "<font color=\"#ababab\">" +getPrintableTypeName(variables[i].getValueClassName()), null,Type.CONSTANT,0)); } } for (JRDesignCrosstab crosstab : ec.getCrosstabs()) { addCrosstabVariables(crosstab, list); } return list; }
/** * Creates an object from a subreport copied value XML element. * * @param atts the element attributes * @return a {@link JRDesignSubreportReturnValue JRDesignSubreportReturnValue} object */ @Override public Object createObject(Attributes atts) { JRXmlLoader xmlLoader = (JRXmlLoader) digester.peek(digester.getCount() - 1); JasperDesign design = (JasperDesign) digester.peek(digester.getCount() - 2); JRDesignSubreportReturnValue returnValue = new JRDesignSubreportReturnValue(); String variableName = atts.getValue(JRXmlConstants.ATTRIBUTE_toVariable); JRVariable variable = design.getVariablesMap().get(variableName); if (variable == null) { xmlLoader.addError(new JRValidationException("Unknown variable " + variableName, returnValue)); } returnValue.setSubreportVariable(atts.getValue(JRXmlConstants.ATTRIBUTE_subreportVariable)); returnValue.setToVariable(variableName); CalculationEnum calculation = CalculationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_calculation)); if (calculation != null) { returnValue.setCalculation(calculation); } String incrementerFactoryClass = atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass); if (incrementerFactoryClass != null) { returnValue.setIncrementerFactoryClassName(incrementerFactoryClass); } return returnValue; }
/** * @param atts the element attributes * @return a {@link DesignExpressionReturnValue DesignExpressionReturnValue} object */ @Override public Object createObject(Attributes atts) { JRXmlLoader xmlLoader = (JRXmlLoader) digester.peek(digester.getCount() - 1); JasperDesign design = (JasperDesign) digester.peek(digester.getCount() - 2); DesignExpressionReturnValue returnValue = new DesignExpressionReturnValue(); String variableName = atts.getValue(JRXmlConstants.ATTRIBUTE_toVariable); JRVariable variable = design.getVariablesMap().get(variableName); if (variable == null) { xmlLoader.addError(new JRValidationException("Unknown variable " + variableName, returnValue)); } returnValue.setToVariable(variableName); CalculationEnum calculation = CalculationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_calculation)); if (calculation != null) { returnValue.setCalculation(calculation); } String incrementerFactoryClass = atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass); if (incrementerFactoryClass != null) { returnValue.setIncrementerFactoryClassName(incrementerFactoryClass); } return returnValue; }
protected final void generateInitVarsMethod(StringBuilder sb) throws JRException { Iterator<JRVariable> varIt = null; if (variables != null && variables.length > 0) { varIt = Arrays.asList(variables).iterator(); } else { List<JRVariable> emptyList = Collections.emptyList(); varIt = emptyList.iterator(); } generateInitVarsMethod(sb, varIt, 0); }
/** * */ private void generateInitVarsMethod(StringBuilder sb, Iterator<JRVariable> it, int index) throws JRException { sb.append(" /**\n"); sb.append(" *\n"); sb.append(" */\n"); sb.append(" private void initVars"); if(index > 0) { sb.append(index); } sb.append("(Map vm)\n"); sb.append(" {\n"); for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++) { String variableName = (it.next()).getName(); sb.append(" variable_"); sb.append(JRStringUtil.getJavaIdentifier(variableName)); sb.append(" = (JRFillVariable)vm.get(\""); sb.append(JRStringUtil.escapeJavaStringLiteral(variableName)); sb.append("\");\n"); } if(it.hasNext()) { sb.append(" initVars"); sb.append(index + 1); sb.append("(vm);\n"); } sb.append(" }\n"); sb.append("\n"); sb.append("\n"); if(it.hasNext()) { generateInitVarsMethod(sb, it, index + 1); } }
/** * */ public void setCountVariable(JRVariable countVariable) { Object old = this.countVariable; this.countVariable = countVariable; getEventSupport().firePropertyChange(PROPERTY_COUNT_VARIABLE, old, this.countVariable); }
private static JRDesignVariable createMasterCurrentPageVariable() { JRDesignVariable variable = new JRDesignVariable(); variable.setName(JRVariable.MASTER_CURRENT_PAGE); variable.setValueClass(Integer.class); variable.setResetType(ResetTypeEnum.REPORT); variable.setCalculation(CalculationEnum.SYSTEM); variable.setSystemDefined(true); return variable; }
private static JRDesignVariable createMasterTotalPagesVariable() { JRDesignVariable variable = new JRDesignVariable(); variable.setName(JRVariable.MASTER_TOTAL_PAGES); variable.setValueClass(Integer.class); variable.setResetType(ResetTypeEnum.REPORT); variable.setCalculation(CalculationEnum.SYSTEM); variable.setSystemDefined(true); return variable; }
@Override public JRVariable[] getVariables() { JRVariable[] variablesArray = new JRVariable[variablesList.size()]; variablesList.toArray(variablesArray); return variablesArray; }
/** * Inserts a variable at specified position into the dataset. * * @param index the variable position * @param variable the variable to insert * @param system whether the variable should be inserted before user defined variables * or at the end of the variables list * @throws JRException */ protected void addVariable(int index, JRDesignVariable variable, boolean system) throws JRException { if (variablesMap.containsKey(variable.getName())) { throw new JRException( EXCEPTION_MESSAGE_KEY_DUPLICATE_VARIABLE, new Object[]{variable.getName()}); } if (system) { // add the variable before the first non-system variable ListIterator<JRVariable> it = variablesList.listIterator(); while (it.hasNext()) { JRVariable var = it.next(); if (!var.isSystemDefined()) { it.previous(); break; } } it.add(variable); index = it.previousIndex(); } else { variablesList.add(index, variable); } variablesMap.put(variable.getName(), variable); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_VARIABLES, variable, index); }
/** * */ protected JRFillVariable( JRVariable variable, JRFillObjectFactory factory ) { factory.put(variable, this); parent = variable; resetGroup = factory.getGroup(variable.getResetGroup()); incrementGroup = factory.getGroup(variable.getIncrementGroup()); helperVariables = new JRFillVariable[JRCalculable.HELPER_SIZE]; }
/** * Gets the incrementer to be used for this copied value. */ public JRIncrementer getIncrementer() { if (incrementer == null) { String incrementerFactoryClassName = getIncrementerFactoryClassName(); JRIncrementerFactory incrementerFactory; if (incrementerFactoryClassName == null) { JRVariable toVariable = filler.getVariable(getToVariable()); incrementerFactory = JRDefaultIncrementerFactory.getFactory(toVariable.getValueClass()); } else { try { Class<?> incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName); incrementerFactory = JRIncrementerFactoryCache.getInstance(incrementerFactoryClass); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_INCREMENTER_CLASS_NOT_FOUND, new Object[]{incrementerFactoryClassName}, e); } } incrementer = incrementerFactory.getIncrementer(getCalculation().getValue()); } return incrementer; }
/** * Initializes the calculator. * * @param dataset the dataset this calculator is used for * @throws JRException */ protected void init(JRFillDataset dataset) throws JRException { this.dataset = dataset; parsm = dataset.parametersMap; fldsm = dataset.fieldsMap; varsm = dataset.variablesMap; variables = dataset.variables; groups = dataset.groups; datasets = dataset.elementDatasets; pageNumber = varsm.get(JRVariable.PAGE_NUMBER); columnNumber = varsm.get(JRVariable.COLUMN_NUMBER); WhenResourceMissingTypeEnum whenResourceMissingType = dataset.getWhenResourceMissingTypeValue(); boolean ignoreNPE = JRPropertiesUtil.getInstance(getFillDataset().getJasperReportsContext()) .getBooleanProperty( getFillDataset(), JREvaluator.PROPERTY_IGNORE_NPE, true ); evaluator.init(parsm, fldsm,varsm, whenResourceMissingType, ignoreNPE); legacyBandEvaluationEnabled = JRPropertiesUtil.getInstance(getFillDataset().getJasperReportsContext()) .getBooleanProperty( PROPERTY_LEGACY_BAND_EVALUATION_ENABLED ); }
protected void setMasterPageVariables(int currentPageIndex, int totalPages) { JRFillVariable masterCurrentPage = getVariable(JRVariable.MASTER_CURRENT_PAGE); if (masterCurrentPage != null) { masterCurrentPage.setValue(currentPageIndex + 1); } JRFillVariable masterTotalPages = getVariable(JRVariable.MASTER_TOTAL_PAGES); if (masterTotalPages != null) { masterTotalPages.setValue(totalPages); } }
protected void initReturnValues(JRFillObjectFactory factory) { if (log.isDebugEnabled()) { log.debug("init return values"); } returnValues = new FillReturnValues(parentDatasetRun.getReturnValues(), factory, filler); returnValuesContext = new AbstractVariableReturnValueSourceContext() { @Override public Object getValue(CommonReturnValue returnValue) { return dataset.getVariableValue(((VariableReturnValue)returnValue).getFromVariable()); } @Override public JRVariable getToVariable(String name) { //FIXME should we look for the variable in expressionEvaluator.getFillDataset()? return filler.getVariable(name); } @Override public JRVariable getFromVariable(String name) { return dataset.getVariable(name); } }; }
private void copyVariables(JRCrosstab crosstab, JRBaseObjectFactory factory) { JRVariable[] vars = crosstab.getVariables(); if (vars != null) { variables = new JRVariable[vars.length]; for (int i = 0; i < vars.length; i++) { variables[i] = factory.getVariable(vars[i]); } } }
/** * Returns the variables of this crosstab indexed by name. * * @return the variables of this crosstab indexed by name */ public Map<String, JRVariable> getVariablesMap() { JRVariable[] variables = getVariables(); Map<String, JRVariable> variablesMap = new HashMap<String, JRVariable>(); for (int i = 0; i < variables.length; i++) { variablesMap.put(variables[i].getName(), variables[i]); } return variablesMap; }