Java 类net.sf.jasperreports.engine.util.JRStringUtil 实例源码

项目:jasperreports    文件:JsonQLQueryExecuter.java   
@Override
protected String getParameterReplacement(String parameterName)
{
    Object parameterValue = getParameterValue(parameterName);

    if (parameterValue == null) {
        return null;
    }

    Class<?> valueClass= parameterValue.getClass();

    if (Number.class.isAssignableFrom(valueClass) || Boolean.class.equals(valueClass)) {
        return String.valueOf(parameterValue);
    }

    StringBuilder sb = new StringBuilder("\"");
    sb.append(JRStringUtil.escapeJavaStringLiteral(String.valueOf(parameterValue)));
    sb.append("\"");

    return sb.toString();
}
项目:jasperreports    文件:JRAbstractCompiler.java   
protected static String getUnitName(JRReport report, JRDataset dataset, String nameSuffix)
{
    String className;
    if (dataset.isMainDataset())
    {
        className = report.getName();
    }
    else
    {
        className = report.getName() + "_" + dataset.getName();
    }

    className = JRStringUtil.getJavaIdentifier(className) + nameSuffix;

    return className;
}
项目:jasperreports    文件:TableBuilder.java   
/**
 *
 */
public void exportText(JRPrintText text, JRExporterGridCell gridCell, boolean shrinkToFit, boolean wrapText, boolean isIgnoreTextFormatting)
{
    buildCellHeader((isIgnoreTextFormatting ? null : styleCache.getCellStyle(gridCell, shrinkToFit, wrapText)), gridCell.getColSpan(), gridCell.getRowSpan());

    bodyWriter.write("<text:p text:style-name=\"");
    bodyWriter.write(styleCache.getParagraphStyle(text, isIgnoreTextFormatting));
    bodyWriter.write("\">");
    documentBuilder.insertPageAnchor(this);
    if (text.getAnchorName() != null)
    {
        exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName()));
    }

    exportTextContents(text);

    bodyWriter.write("</text:p>\n");

    buildCellFooter();
}
项目:jasperreports    文件:JROdsExporter.java   
@Override
public void exportText(
    JRPrintText text, 
    JRExporterGridCell gridCell,
    int colIndex, 
    int rowIndex
    ) throws JRException
{
    tableBuilder.exportText(text, gridCell, isShrinkToFit(text), isWrapText(text), isIgnoreTextFormatting(text));
    XlsReportConfiguration configuration = getCurrentItemConfiguration();
    if (!configuration.isIgnoreAnchors() && text.getAnchorName() != null)
    {
        String cellAddress = "$&apos;" + tableBuilder.getTableName() + "&apos;." + getCellAddress(rowIndex, colIndex);
        int lastCol = Math.max(0, colIndex + gridCell.getColSpan() -1);
        String cellRangeAddress = getCellAddress(rowIndex + gridCell.getRowSpan() - 1, lastCol);
        namedExpressions.append("<table:named-range table:name=\""+ JRStringUtil.xmlEncode(text.getAnchorName()) +"\" table:base-cell-address=\"" + cellAddress +"\" table:cell-range-address=\"" + cellAddress +":" +cellRangeAddress +"\"/>\n");
    }
}
项目:jasperreports    文件:JRXlsAbstractMetadataExporter.java   
/**
 * 
 */
protected void setColumnNames()
{
    String[] columnNamesArray = getCurrentItemConfiguration().getColumnNames();

    hasDefinedColumns = (columnNamesArray != null && columnNamesArray.length > 0);

    columnNames = new ArrayList<String>();
    columnNamesMap = new HashMap<String, Integer>();

    List<String> columnNamesList = JRStringUtil.split(columnNamesArray, ",");
    if (columnNamesList != null)
    {
        for (String columnName : columnNamesList)
        {
            if (!columnNamesMap.containsKey(columnName))
            {
                columnNames.add(columnName);
                columnNamesMap.put(columnName, columnNames.size());
            }
        }
    }
}
项目:jasperreports    文件:PptxRunHelper.java   
/**
 *
 */
public void export(JRStyle style, Map<Attribute,Object> attributes, String text, Locale locale, String invalidCharReplacement)
{
    if (text != null)
    {
        StringTokenizer tkzer = new StringTokenizer(text, "\n", true);
        while(tkzer.hasMoreTokens())
        {
            String token = tkzer.nextToken();
            if ("\n".equals(token))
            {
                write("<a:br/>");
            }
            else
            {
                write("      <a:r>\n");
                exportProps("a:rPr", getAttributes(style), attributes, locale);
                //write("<a:t xml:space=\"preserve\">");
                write("<a:t>");
                write(JRStringUtil.xmlEncode(token, invalidCharReplacement));//FIXMEODT try something nicer for replace
                write("</a:t>\n");
                write("      </a:r>\n");
            }
        }
    }
}
项目:jasperreports    文件:JRFillTextElement.java   
protected String processMarkupText(String text)
{
    text = JRStringUtil.replaceCRwithLF(text);

    if (text != null)
    {
        String markup = getMarkup();
        if (
            !JRCommonText.MARKUP_NONE.equals(markup)
            && !JRCommonText.MARKUP_STYLED_TEXT.equals(markup)
            )
        {
            text = getMarkupProcessor(markup).convert(text);
        }
    }

    return text;
}
项目:jasperreports    文件:HeaderToolbarElementUtils.java   
public static void copyTextElementStyle(EditTextElementData textElementData, JRDesignTextElement textElement, Locale locale) {
    textElementData.setFontName(JRStringUtil.htmlEncode(textElement.getFontName()));
    textElementData.setFontSize(NumberFormat.getNumberInstance(locale).format(textElement.getFontsize()));
    textElementData.setFloatFontSize(textElement.getFontsize());
    textElementData.setFontBold(textElement.isBold());
    textElementData.setFontItalic(textElement.isItalic());
    textElementData.setFontUnderline(textElement.isUnderline());
    textElementData.setFontColor(JRColorUtil.getColorHexa(textElement.getForecolor()));
    textElementData.setFontBackColor(JRColorUtil.getColorHexa(textElement.getBackcolor()));
    textElementData.setFontHAlign(textElement.getHorizontalTextAlign().getName());
    textElementData.setMode(textElement.getModeValue().getName());

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        textElementData.setFormatPattern(JRStringUtil.htmlEncode(((JRDesignTextField) textElement).getPattern()));
    }
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private Map<String, ColumnInfo> getAllColumnNames(JRGenericPrintElement element, 
        JasperReportsContext jasperReportsContext, Map<String, Object> contextMap) {
    int prefixLength = HeaderToolbarElement.PARAM_COLUMN_LABEL_PREFIX.length();
    Map<String, ColumnInfo> columnNames = new HashMap<String, ColumnInfo>();
    for (String paramName : element.getParameterNames()) {
        if (paramName.startsWith(HeaderToolbarElement.PARAM_COLUMN_LABEL_PREFIX)) {
            String columnName = (String) element.getParameterValue(paramName);
            String[] tokens = paramName.substring(prefixLength).split("\\|");
            if (columnName == null || columnName.trim().length() == 0) {
                columnName = "Column_" + tokens[0];
            }
            columnNames.put(tokens[0], new ColumnInfo(tokens[0], JRStringUtil.htmlEncode(columnName), tokens[1], false, Boolean.valueOf(tokens[2])));
        }
    }
    return columnNames;
}
项目:jasperreports    文件:FillXYChart.java   
protected void evaluateChart(byte evaluation) throws JRException
{
    chartTitle = JRStringUtil.getString(fillContext.evaluate(chart.getChartTitleExpression(), evaluation));
    xAxisTitle = JRStringUtil.getString(fillContext.evaluate(chart.getXAxisTitleExpression(), evaluation));
    yAxisTitle = JRStringUtil.getString(fillContext.evaluate(chart.getYAxisTitleExpression(), evaluation));

    dataset.evaluateDatasetRun(evaluation);
}
项目:jasperreports    文件:JRXmlWriter.java   
public void writeProperties(JRPropertiesHolder propertiesHolder) throws IOException
{
    if (propertiesHolder.hasProperties())
    {
        JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap();
        String[] propertyNames = propertiesMap.getPropertyNames();
        if (propertyNames != null && propertyNames.length > 0)
        {
            for(int i = 0; i < propertyNames.length; i++)
            {
                String propertyName = propertyNames[i];
                if (isPropertyToWrite(propertiesHolder, propertyName))
                {
                    writer.startElement(JRXmlConstants.ELEMENT_property, getNamespace());
                    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, propertyName);
                    String value = propertiesMap.getProperty(propertyName);
                    if (value != null)
                    {
                        String encodedValue = JRStringUtil.encodeXmlAttribute(value);
                        if (
                            isNewerVersionOrEqual(JRConstants.VERSION_6_4_0)
                            && encodedValue.length() != value.length()
                            )
                        {
                            writer.writeCDATA(value);
                        }
                        else
                        {
                            writer.addAttribute(JRXmlConstants.ATTRIBUTE_value, encodedValue);
                        }
                    }
                    writer.closeElement();
                }
            }
        }
    }
}
项目:jasperreports    文件:JRClassGenerator.java   
protected final void generateDeclarations(StringBuilder sb)
{
    if (parametersMap != null && parametersMap.size() > 0)
    {
        Collection<String> parameterNames = parametersMap.keySet();
        for (Iterator<String> it = parameterNames.iterator(); it.hasNext();)
        {
            sb.append("    private JRFillParameter parameter_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(" = null;\n");
        }
    }

    if (fieldsMap != null && fieldsMap.size() > 0)
    {
        Collection<String> fieldNames = fieldsMap.keySet();
        for (Iterator<String> it = fieldNames.iterator(); it.hasNext();)
        {
            sb.append("    private JRFillField field_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(" = null;\n");
        }
    }

    if (variables != null && variables.length > 0)
    {
        for (int i = 0; i < variables.length; i++)
        {
            sb.append("    private JRFillVariable variable_");
            sb.append(JRStringUtil.getJavaIdentifier(variables[i].getName()));
            sb.append(" = null;\n");
        }
    }
}
项目:jasperreports    文件:JRClassGenerator.java   
/**
 *
 */
private void generateInitParamsMethod(StringBuilder sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    private void initParams");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(Map pm)\n");
    sb.append("    {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String parameterName = it.next();
        sb.append("        parameter_");
        sb.append(JRStringUtil.getJavaIdentifier(parameterName));
        sb.append(" = (JRFillParameter)pm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(parameterName));
        sb.append("\");\n");
    }
    if(it.hasNext())
    {
        sb.append("        initParams");
        sb.append(index + 1);
        sb.append("(pm);\n");
    }
    sb.append("    }\n");
    sb.append("\n");
    sb.append("\n");

    if(it.hasNext())
    {
        generateInitParamsMethod(sb, it, index + 1);
    }
}
项目:jasperreports    文件:JRClassGenerator.java   
/**
 *
 */
private void generateInitFieldsMethod(StringBuilder sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    private void initFields");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(Map fm)\n");
    sb.append("    {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String fieldName = it.next();
        sb.append("        field_");
        sb.append(JRStringUtil.getJavaIdentifier(fieldName));
        sb.append(" = (JRFillField)fm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(fieldName));
        sb.append("\");\n");
    }
    if(it.hasNext())
    {
        sb.append("        initFields");
        sb.append(index + 1);
        sb.append("(fm);\n");
    }
    sb.append("    }\n");
    sb.append("\n");
    sb.append("\n");

    if(it.hasNext())
    {
        generateInitFieldsMethod(sb, it, index + 1);
    }
}
项目:jasperreports    文件:JRClassGenerator.java   
/**
 *
 */
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);
    }
}
项目:jasperreports    文件:TableBuilder.java   
/**
 *
 */
protected void writeText(String text)
{
    if (text != null)
    {
        bodyWriter.write(Utility.replaceNewLineWithLineBreak(JRStringUtil.xmlEncode(text, documentBuilder.getInvalidCharReplacement())));//FIXMEODT try something nicer for replace
    }
}
项目:jasperreports    文件:TableBuilder.java   
/**
     *
     */
    protected void writeHyperlink(JRPrintHyperlink link, String href, boolean isText)
    {
        if(isText)
        {
            bodyWriter.write("<text:a xlink:href=\"");
        }
        else
        {
            bodyWriter.write("<draw:a xlink:type=\"simple\" xlink:href=\"");
        }
        bodyWriter.write(JRStringUtil.xmlEncode(href));
        bodyWriter.write("\"");


        String target = getHyperlinkTarget(link);//FIXMETARGET
        if (target != null)
        {
            bodyWriter.write(" office:target-frame-name=\"");
            bodyWriter.write(target);
            bodyWriter.write("\"");
            if(target.equals("_blank"))
            {
                bodyWriter.write(" xlink:show=\"new\"");
            }
        }
/*
 * tooltips are unavailable for the moment
 *
        if (link.getHyperlinkTooltip() != null)
        {
            bodyWriter.write(" xlink:title=\"");
            bodyWriter.write(JRStringUtil.xmlEncode(link.getHyperlinkTooltip()));
            bodyWriter.write("\"");
        }
*/
        bodyWriter.write(">");
    }
项目:jasperreports    文件:XlsxDrawingRelsHelper.java   
/**
 * 
 */
private void exportHyperlink(int index, String href)
{
    write(" <Relationship Id=\"rIdLnk" 
        + index + "\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"" 
        + JRStringUtil.xmlEncode(href) + "\" TargetMode=\"External\"/>\n");
}
项目:jasperreports    文件:XlsxSheetRelsHelper.java   
/**
 * 
 */
private void exportHyperlink(int index, String href)
{
    write(" <Relationship Id=\"rIdLnk" 
        + index + "\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"" 
        + JRStringUtil.xmlEncode(href) + "\" TargetMode=\"External\"/>\n");
}
项目:jasperreports    文件:XlsxRunHelper.java   
/**
 *
 */
public void export(JRStyle style, Map<Attribute,Object> attributes, String text, Locale locale, String invalidCharReplacement, boolean isStyledText)
{
    if (text != null)
    {
        write("<r>\n");
        if (isStyledText)
        {
            exportProps(getAttributes(style), attributes, locale);
        }
        write("<t xml:space=\"preserve\">");
        write(JRStringUtil.xmlEncode(text, invalidCharReplacement));
        write("</t></r>\n");
    }
}
项目:jasperreports    文件:JRXlsxExporter.java   
protected void insertPageAnchor(int colIndex, int rowIndex)
{
    if(!getCurrentItemConfiguration().isIgnoreAnchors() && startPage)
    {
        String anchorPage = JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (sheetIndex - sheetsBeforeCurrentReport);
        String ref = "'" + JRStringUtil.xmlEncode(currentSheetName) + "'!$A$1";     // + XlsxCellHelper.getColumIndexLetter(colIndex) + "$" + (rowIndex + 1);
        definedNames.append("<definedName name=\"" + getDefinedName(anchorPage) +"\">"+ ref +"</definedName>\n");
        startPage = false;
    }
}
项目:jasperreports    文件:XlsxWorkbookHelper.java   
/**
 * 
 */
public void exportSheet(int index, String name, Map<String, Integer> sheetMapping)
{
    String sheetName = JRStringUtil.xmlEncode(name);
    sheetMapping.put(sheetName, index-1);
    write("  <sheet name=\"" + sheetName + "\" sheetId=\"" + index + "\" r:id=\"rId" + index + "\"/>\n");
}
项目:jasperreports    文件:PptxSlideRelsHelper.java   
/**
 * 
 */
private void exportHyperlink(int index, String href)
{
    write(" <Relationship Id=\"rIdLnk" 
        + index + "\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"" 
        + JRStringUtil.xmlEncode(href) + "\" TargetMode=\"External\"/>\n");
}
项目:jasperreports    文件:JRCsvMetadataExporter.java   
@Override
protected void initReport() 
{
    super.initReport();

    CsvMetadataReportConfiguration configuration = getCurrentItemConfiguration();

    columnNames = JRStringUtil.split(configuration.getColumnNames(), ",");

    isFirstRow = true;
}
项目:jasperreports    文件:JRXmlExporter.java   
protected void exportProperties(JRPropertiesHolder propertiesHolder) throws IOException
{
    if (propertiesHolder.hasProperties())
    {
        JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap();
        String[] propertyNames = propertiesMap.getPropertyNames();
        if (propertyNames != null && propertyNames.length > 0)
        {
            for(int i = 0; i < propertyNames.length; i++)
            {
                xmlWriter.startElement(JRXmlConstants.ELEMENT_property);
                xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, propertyNames[i]);
                String value = propertiesMap.getProperty(propertyNames[i]);
                if (value != null)
                {
                    String encodedValue = JRStringUtil.encodeXmlAttribute(value);
                    if (
                        isNewerVersionOrEqual(JRConstants.VERSION_6_4_0)
                        && encodedValue.length() != value.length()
                        )
                    {
                        xmlWriter.writeCDATA(value);
                    }
                    else
                    {
                        xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_value, encodedValue);
                    }
                }
                xmlWriter.closeElement();
            }
        }
    }
}
项目:jasperreports    文件:JRXlsAbstractExporter.java   
/**
 * 
 */
protected void setSheetNames()
{
    String[] sheetNamesArray = getCurrentItemConfiguration().getSheetNames();

    List<String> sheetNamesList = JRStringUtil.split(sheetNamesArray, "/");
    sheetNames = sheetNamesList == null ? null : (String[]) sheetNamesList.toArray(new String[sheetNamesList.size()]);
}
项目:jasperreports    文件:JRGroovyGenerator.java   
protected final void generateDeclarations(StringBuilder sb)
{
    if (parametersMap != null && parametersMap.size() > 0)
    {
        Collection<String> parameterNames = parametersMap.keySet();
        for (Iterator<String> it = parameterNames.iterator(); it.hasNext();)
        {
            sb.append("    private JRFillParameter parameter_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(" = null;\n");
        }
    }

    if (fieldsMap != null && fieldsMap.size() > 0)
    {
        Collection<String> fieldNames = fieldsMap.keySet();
        for (Iterator<String> it = fieldNames.iterator(); it.hasNext();)
        {
            sb.append("    private JRFillField field_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(" = null;\n");
        }
    }

    if (variables != null && variables.length > 0)
    {
        for (int i = 0; i < variables.length; i++)
        {
            sb.append("    private JRFillVariable variable_");
            sb.append(JRStringUtil.getJavaIdentifier(variables[i].getName()));
            sb.append(" = null;\n");
        }
    }
}
项目:jasperreports    文件:JRGroovyGenerator.java   
/**
 *
 */
private void generateInitParamsMethod(StringBuilder sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    void initParams");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(Map pm)\n");
    sb.append("    {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String parameterName = it.next();
        sb.append("        parameter_");
        sb.append(JRStringUtil.getJavaIdentifier(parameterName));
        sb.append(" = (JRFillParameter)pm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(parameterName));
        sb.append("\");\n");
    }
    if(it.hasNext())
    {
        sb.append("        initParams");
        sb.append(index + 1);
        sb.append("(pm);\n");
    }
    sb.append("    }\n");
    sb.append("\n");
    sb.append("\n");

    if(it.hasNext())
    {
        generateInitParamsMethod(sb, it, index + 1);
    }
}
项目:jasperreports    文件:JRGroovyGenerator.java   
/**
 *
 */
private void generateInitFieldsMethod(StringBuilder sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    void initFields");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(Map fm)\n");
    sb.append("    {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String fieldName = it.next();
        sb.append("        field_");
        sb.append(JRStringUtil.getJavaIdentifier(fieldName));
        sb.append(" = (JRFillField)fm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(fieldName));
        sb.append("\");\n");
    }
    if(it.hasNext())
    {
        sb.append("        initFields");
        sb.append(index + 1);
        sb.append("(fm);\n");
    }
    sb.append("    }\n");
    sb.append("\n");
    sb.append("\n");

    if(it.hasNext())
    {
        generateInitFieldsMethod(sb, it, index + 1);
    }
}
项目:jasperreports    文件:JRGroovyGenerator.java   
/**
 *
 */
private void generateInitVarsMethod(StringBuilder sb, Iterator<JRVariable> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    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);
    }
}
项目:jasperreports    文件:JavaScriptCompilerBase.java   
@Override
public void visitResourceChunk(JRExpressionChunk chunk)
{
    String key = chunk.getText();
    script.append(JavaScriptEvaluatorScope.EVALUATOR_VAR);
    script.append(".str('");
    script.append(JRStringUtil.escapeJavaScript(key));
    script.append("')");
}
项目:jasperreports    文件:BarcodeEvaluator.java   
protected void evaluateBaseBarcode(Barcode4jComponent barcodeComponent)
{
    evaluateBaseBarcode((BarcodeComponent)barcodeComponent);

    String pattern = JRStringUtil.getString(evaluateExpression(barcodeComponent.getPatternExpression()));
    if (pattern != null) 
    {
        barcodeBean.setPattern(pattern);
    }
}
项目:jasperreports    文件:BarcodeEvaluator.java   
@Override
protected void evaluateEANCode128(EAN128Component ean128)
{
    evaluateBaseBarcode(ean128);
    String template = JRStringUtil.getString(evaluateExpression(ean128.getTemplateExpression()));
    if (template != null) 
    {
        ((EAN128Bean)barcodeBean).setTemplate(template);
    }
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private void setColumnHeaderData(String sortColumnLabel, Integer columnIndex, CommandTarget target, Map<String, Object> contextMap,
        JasperReportsContext jasperReportsContext, ReportContext reportContext, Locale locale) {
    if (target != null){
        JRIdentifiable identifiable = target.getIdentifiable();
        JRDesignComponentElement componentElement = identifiable instanceof JRDesignComponentElement ? (JRDesignComponentElement)identifiable : null;
        StandardTable table = componentElement == null ? null : (StandardTable)componentElement.getComponent();

        List<BaseColumn> tableColumns = TableUtil.getAllColumns(table);

        if (columnIndex != null) {
            StandardColumn column = (StandardColumn) tableColumns.get(columnIndex);

            JRDesignTextElement textElement = TableUtil.getCellElement(JRDesignTextElement.class, column.getColumnHeader(), true);

            if (textElement != null) {
                EditTextElementData textElementData = new EditTextElementData();

                textElementData.setHeadingName(JRStringUtil.htmlEncode(sortColumnLabel));
                textElementData.setColumnIndex(columnIndex);
                JRDesignTextElement styledElement = resolveElementStyle(textElement, reportContext, target);
                HeaderToolbarElementUtils.copyTextElementStyle(textElementData, styledElement, locale);

                contextMap.put("colHeaderData", JacksonUtil.getInstance(jasperReportsContext).getJsonString(textElementData));
            }
        }
    }
}
项目:jasperreports    文件:EditTextElementCommand.java   
private void applyColumnHeaderData(EditTextElementData textElementData, JRDesignTextElement textElement, boolean execute) {
    if (EditTextElementData.APPLY_TO_HEADING.equals(textElementData.getApplyTo())) {
        if (textElement instanceof JRDesignTextField) {
            JRDesignTextField designTextField = (JRDesignTextField)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = (designTextField.getExpression()).getText();
                }
                ((JRDesignExpression)designTextField.getExpression()).setText("\"" + JRStringUtil.escapeJavaStringLiteral(textElementData.getHeadingName()) + "\"");
            } else {
                ((JRDesignExpression)designTextField.getExpression()).setText(oldText);
            }

        } else if (textElement instanceof JRDesignStaticText){
            JRDesignStaticText staticText = (JRDesignStaticText)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = staticText.getText();
                }
                staticText.setText(textElementData.getHeadingName());
            } else {
                staticText.setText(oldText);
            }
        }
    }

    textElement.setFontName(textElementData.getFontName());
    textElement.setFontSize(textElementData.getFloatFontSize());
    textElement.setBold(textElementData.getFontBold());
    textElement.setItalic(textElementData.getFontItalic());
    textElement.setUnderline(textElementData.getFontUnderline());
    textElement.setForecolor(textElementData.getFontColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontColor(), textElement.getForecolor()) : null);
    textElement.setHorizontalTextAlign(HorizontalTextAlignEnum.getByName(textElementData.getFontHAlign()));
    textElement.setBackcolor(textElementData.getFontBackColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontBackColor(), Color.white) : null);
    textElement.setMode(ModeEnum.getByName(textElementData.getMode()));

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        ((JRDesignTextField) textElement).setPattern(textElementData.getFormatPattern());
    }
}
项目:jasperreports-scala    文件:JRScalaGenerator.java   
protected final void generateDeclarations(StringBuffer sb)
{
    if (parametersMap != null && parametersMap.size() > 0)
    {
        Collection<String> parameterNames = parametersMap.keySet();
        for (Iterator<String> it = parameterNames.iterator(); it.hasNext();)
        {
            sb.append("    private var parameter_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(":JRFillParameter = null;\n");
        }
    }

    if (fieldsMap != null && fieldsMap.size() > 0)
    {
        Collection<String> fieldNames = fieldsMap.keySet();
        for (Iterator<String> it = fieldNames.iterator(); it.hasNext();)
        {
            sb.append("    private var field_");
            sb.append(JRStringUtil.getJavaIdentifier(it.next()));
            sb.append(":JRFillField = null;\n");
        }
    }

    if (variables != null && variables.length > 0)
    {
        for (int i = 0; i < variables.length; i++)
        {
            sb.append("    private var variable_");
            sb.append(JRStringUtil.getJavaIdentifier(variables[i].getName()));
            sb.append(":JRFillVariable = null;\n");
        }
    }
}
项目:jasperreports-scala    文件:JRScalaGenerator.java   
/**
 *
 */
private void generateInitParamsMethod(StringBuffer sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    def initParams");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(pm:java.util.Map[_,_]) = {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String parameterName = it.next();
        sb.append("        parameter_");
        sb.append(JRStringUtil.getJavaIdentifier(parameterName));
        sb.append(" = pm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(parameterName));
        sb.append("\").asInstanceOf[JRFillParameter]\n");
    }
    if(it.hasNext())
    {
        sb.append("        initParams");
        sb.append(index + 1);
        sb.append("(pm);\n");
    }
    sb.append("    }\n");
    sb.append(LF);
    sb.append(LF);

    if(it.hasNext())
    {
        generateInitParamsMethod(sb, it, index + 1);
    }
}
项目:jasperreports-scala    文件:JRScalaGenerator.java   
/**
 *
 */
private void generateInitFieldsMethod(StringBuffer sb, Iterator<String> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    def initFields");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(fm:java.util.Map[_,_]) = {\n");
    for (int i = 0; i < EXPR_MAX_COUNT_PER_METHOD && it.hasNext(); i++)
    {
        String fieldName = it.next();
        sb.append("        field_");
        sb.append(JRStringUtil.getJavaIdentifier(fieldName));
        sb.append(" = fm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(fieldName));
        sb.append("\").asInstanceOf[JRFillField]\n");
    }
    if(it.hasNext())
    {
        sb.append("        initFields");
        sb.append(index + 1);
        sb.append("(fm);\n");
    }
    sb.append("    }\n");
    sb.append(LF);
    sb.append(LF);

    if(it.hasNext())
    {
        generateInitFieldsMethod(sb, it, index + 1);
    }
}
项目:jasperreports-scala    文件:JRScalaGenerator.java   
/**
 *
 */
private void generateInitVarsMethod(StringBuffer sb, Iterator<JRVariable> it, int index) throws JRException
{
    sb.append("    /**\n");
    sb.append("     *\n");
    sb.append("     */\n");
    sb.append("    def initVars");
    if(index > 0)
    {
        sb.append(index);
    }
    sb.append("(vm:java.util.Map[_,_]) = {\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(" = vm.get(\"");
        sb.append(JRStringUtil.escapeJavaStringLiteral(variableName));
        sb.append("\").asInstanceOf[JRFillVariable]\n");
    }
    if(it.hasNext())
    {
        sb.append("        initVars");
        sb.append(index + 1);
        sb.append("(vm);\n");
    }
    sb.append("    }\n");
    sb.append(LF);
    sb.append(LF);

    if(it.hasNext())
    {
        generateInitVarsMethod(sb, it, index + 1);
    }
}
项目:dynamicreports-jasper    文件:GeoMapFillComponent.java   
private void evaluateGeoMap(byte evaluation) throws JRException {
    showLegend = geoMapComponent.getShowLegend();
    dataMode = geoMapComponent.getDataMode();
    region = JRStringUtil.getString(fillContext.evaluate(geoMapComponent.getRegionExpression(), evaluation));
    valueLabel = JRStringUtil.getString(fillContext.evaluate(geoMapComponent.getValueLabelExpression(), evaluation));
    colors = geoMapComponent.getColors();

    dataset.evaluateDatasetRun(evaluation);
    dataset.finishDataset();
}