class StatisticsModelImpl implements StatisticsModel {

    private final Workspace workspace;
    private final Map<Class, String> reportMap;

    public StatisticsModelImpl(Workspace workspace) {
        this.workspace = workspace;
        reportMap = new HashMap<>();
    }

    @Override
    public Workspace getWorkspace() {
        return workspace;
    }

    public void addReport(Statistics statistics) {
        reportMap.put(statistics.getClass(), statistics.getReport());
    }

    @Override
    public String getReport(Class<? extends Statistics> statisticsClass) {
        return reportMap.get(statisticsClass);
    }

    public void writeXML(XMLStreamWriter writer) throws XMLStreamException {
        writer.writeStartElement("reports");
        for (Map.Entry<Class, String> entry : reportMap.entrySet()) {
            if (entry.getValue() != null && !entry.getValue().isEmpty()) {
                writer.writeStartElement("report");
                String report = entry.getValue();
                report = embedImages(report);
                writer.writeAttribute("class", entry.getKey().getName());
                writer.writeAttribute("value", report);
                writer.writeEndElement();
            }
        }
        writer.writeEndElement();
    }

    public void readXML(XMLStreamReader reader) throws XMLStreamException {
        Collection<? extends StatisticsUI> uis = Lookup.getDefault().lookupAll(StatisticsUI.class);
        Collection<? extends StatisticsBuilder> builders = Lookup.getDefault().lookupAll(StatisticsBuilder.class);

        boolean end = false;
        while (reader.hasNext() && !end) {
            int type = reader.next();

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if ("report".equalsIgnoreCase(name)) {
                        String classStr = reader.getAttributeValue(null, "class");
                        Class reportClass = null;
                        for (StatisticsBuilder builder : builders) {
                            if (builder.getStatisticsClass().getName().equals(classStr)) {
                                reportClass = builder.getStatisticsClass();
                            }
                        }
                        if (reportClass != null) {
                            String report = reader.getAttributeValue(null, "value");
                            report = unembedImages(report);
                            reportMap.put(reportClass, report);
                        }
                    }
                    break;
                case XMLStreamReader.END_ELEMENT:
                    if ("statisticsmodel".equalsIgnoreCase(reader.getLocalName())) {
                        end = true;
                    }
                    break;
            }
        }
    }

    private String unembedImages(String report) {
        StringBuilder builder = new StringBuilder();
        String[] result = report.split("data:image/png;base64");
        if (result.length == 0) {
            return report;
        }
        try {
            TempDir tempDir = TempDirUtils.createTempDir();

            for (int i = 0; i < result.length; i++) {
                if (result[i].contains("</IMG>")) {
                    String next = result[i];
                    int endIndex = next.indexOf('\"');
                    String pngStr = next.substring(0, endIndex);
                    byte[] imageBytes = Base64.decodeBase64(pngStr);
                    String fileName = "image" + i + ".png";
                    File file = tempDir.createFile(fileName);

                    FileOutputStream fos = new FileOutputStream(file);
                    fos.write(imageBytes);

                    String path = "file:" + file.getAbsolutePath();
                    builder.append(path);

                    builder.append(next.substring(endIndex));
                } else {
                    builder.append(result[i]);
                }
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
        return builder.toString();
    }

    private String embedImages(String report) {<FILL_FUNCTION_BODY>}
}

        StringBuilder builder = new StringBuilder();
        String[] result = report.split("file:");
        boolean first = true;
        for (int i = 0; i < result.length; i++) {
            if (result[i].contains("</IMG>")) {
                String next = result[i];
                String[] elements = next.split("\"");
                String filename = elements[0];

                ByteArrayOutputStream out = new ByteArrayOutputStream();

                File file = new File(filename);
                try {
                    BufferedImage image = ImageIO.read(file);
                    ImageIO.write(image, "PNG", out);
                } catch (Exception e) {
                    Exceptions.printStackTrace(e);
                }
                byte[] imageBytes = out.toByteArray();
                String base64String = Base64.encodeBase64String(imageBytes);
                if (!first) {

                    builder.append("\"");
                }
                first = false;
                builder.append("data:image/png;base64,");
                builder.append(base64String);
                for (int j = 1; j < elements.length; j++) {
                    builder.append("\"");
                    builder.append(elements[j]);
                }
            } else {
                builder.append(result[i]);
            }
        }
        return builder.toString();
    
<no_super_class>