Example usage for com.fasterxml.jackson.databind.node ArrayNode hashCode

List of usage examples for com.fasterxml.jackson.databind.node ArrayNode hashCode

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node ArrayNode hashCode.

Prototype

public int hashCode()

Source Link

Usage

From source file:net.sf.jasperreports.engine.export.JsonExporter.java

protected void exportWebFonts() throws IOException {
    HtmlResourceHandler fontHandler = getExporterOutput().getFontHandler();
    ReportContext reportContext = getReportContext();

    if (fontHandler != null && reportContext != null
            && reportContext.containsParameter(REPORT_CONTEXT_PARAMETER_WEB_FONTS)) {
        Map<String, HtmlFontFamily> fontsToProcess = (Map<String, HtmlFontFamily>) reportContext
                .getParameterValue(REPORT_CONTEXT_PARAMETER_WEB_FONTS);

        ObjectMapper mapper = new ObjectMapper();
        ArrayNode webFonts = mapper.createArrayNode();

        for (HtmlFontFamily htmlFontFamily : fontsToProcess.values()) {
            ObjectNode objNode = mapper.createObjectNode();
            objNode.put("id", htmlFontFamily.getId());
            objNode.put("path", fontHandler.getResourcePath(htmlFontFamily.getId()));
            webFonts.add(objNode);// ww  w.j a va  2 s . c  om
        }

        if (gotFirstJsonFragment) {
            writer.write(",\n");
        } else {
            gotFirstJsonFragment = true;
        }
        writer.write("\"webfonts_" + (webFonts.hashCode() & 0x7FFFFFFF) + "\": {");

        writer.write("\"id\": \"webfonts_" + (webFonts.hashCode() & 0x7FFFFFFF) + "\",");
        writer.write("\"type\": \"webfonts\",");
        writer.write("\"webfonts\": " + jacksonUtil.getJsonString(webFonts));

        writer.write("}");
    }
}