public FDFDictionary()

in pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java [74:230]


    public FDFDictionary(Element fdfXML)
    {
        this();
        NodeList nodeList = fdfXML.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++)
        {
            Node node = nodeList.item(i);
            if (node instanceof Element)
            {
                Element child = (Element) node;
                switch (child.getTagName())
                {
                    case "f":
                        PDSimpleFileSpecification fs = new PDSimpleFileSpecification();
                        fs.setFile(child.getAttribute("href"));
                        setFile(fs);
                        break;
                    case "ids":
                        COSArray ids = new COSArray();
                        String original = child.getAttribute("original");
                        String modified = child.getAttribute("modified");
                        try
                        {
                            ids.add(COSString.parseHex(original));
                        }
                        catch (IOException e)
                        {
                            LOG.warn(() ->
                                    "Error parsing ID entry for attribute 'original' [" + 
                                            original + "]. ID entry ignored.",
                                    e);
                        }
                        try
                        {
                            ids.add(COSString.parseHex(modified));
                        }
                        catch (IOException e)
                        {
                            LOG.warn(() ->
                                    "Error parsing ID entry for attribute 'modified' [ + " + 
                                            modified + "]. ID entry ignored.", 
                                    e);
                        }
                        setID(ids);
                        break;
                    case "fields":
                        NodeList fields = child.getChildNodes();
                        List<FDFField> fieldList = new ArrayList<>();
                        for (int f = 0; f < fields.getLength(); f++)
                        {
                            Node currentNode = fields.item(f);
                            if (currentNode instanceof Element
                                    && ((Element) currentNode).getTagName().equals("field"))
                            {
                                try
                                {
                                    fieldList.add(new FDFField((Element) fields.item(f)));
                                }
                                catch (IOException e)
                                {
                                    LOG.warn(() -> "Error parsing field entry [" + 
                                            currentNode.getNodeValue() + "]. Field ignored.",
                                            e);
                                }
                            }
                        }
                        setFields(fieldList);
                        break;
                    case "annots":
                        NodeList annots = child.getChildNodes();
                        List<FDFAnnotation> annotList = new ArrayList<>();
                        for (int j = 0; j < annots.getLength(); j++)
                        {
                            Node annotNode = annots.item(j);
                            if (annotNode instanceof Element)
                            {
                                // the node name defines the annotation type
                                Element annot = (Element) annotNode;
                                String annotationName = annot.getNodeName();
                                try
                                {
                                    switch (annotationName)
                                    {
                                        case "text":
                                            annotList.add(new FDFAnnotationText(annot));
                                            break;
                                        case "caret":
                                            annotList.add(new FDFAnnotationCaret(annot));
                                            break;
                                        case "freetext":
                                            annotList.add(new FDFAnnotationFreeText(annot));
                                            break;
                                        case "fileattachment":
                                            annotList.add(new FDFAnnotationFileAttachment(annot));
                                            break;
                                        case "highlight":
                                            annotList.add(new FDFAnnotationHighlight(annot));
                                            break;
                                        case "ink":
                                            annotList.add(new FDFAnnotationInk(annot));
                                            break;
                                        case "line":
                                            annotList.add(new FDFAnnotationLine(annot));
                                            break;
                                        case "link":
                                            annotList.add(new FDFAnnotationLink(annot));
                                            break;
                                        case "circle":
                                            annotList.add(new FDFAnnotationCircle(annot));
                                            break;
                                        case "square":
                                            annotList.add(new FDFAnnotationSquare(annot));
                                            break;
                                        case "polygon":
                                            annotList.add(new FDFAnnotationPolygon(annot));
                                            break;
                                        case "polyline":
                                            annotList.add(new FDFAnnotationPolyline(annot));
                                            break;
                                        case "sound":
                                            annotList.add(new FDFAnnotationSound(annot));
                                            break;
                                        case "squiggly":
                                            annotList.add(new FDFAnnotationSquiggly(annot));
                                            break;
                                        case "stamp":
                                            annotList.add(new FDFAnnotationStamp(annot));
                                            break;
                                        case "strikeout":
                                            annotList.add(new FDFAnnotationStrikeOut(annot));
                                            break;
                                        case "underline":
                                            annotList.add(new FDFAnnotationUnderline(annot));
                                            break;
                                        default:
                                            LOG.warn("Unknown or unsupported annotation type '{}'",
                                                    annotationName);
                                            break;
                                    }
                                }
                                catch (IOException e)
                                {
                                    LOG.warn(() ->
                                            "Error parsing annotation information [" +
                                            annot.getNodeValue() + "]. Annotation ignored",
                                            e);
                                }
                            }
                        }
                        setAnnotations(annotList);
                        break;
                    default:
                        break;
                }
            }
        }
    }