class XfdfReader implements SimpleXMLDocHandler, FieldReader {

    // stuff used during parsing to handle state
    private boolean foundRoot = false;
    private Stack<String> fieldNames = new Stack<>();
    private Stack<String> fieldValues = new Stack<>();

    // storage for the field list and their values
    private Map<String, String> fields;
    /**
     * Storage for field values if there's more than one value for a field.
     *
     * @since 2.1.4
     */
    private Map<String, List<String>> listFields;

    // storage for the path to referenced PDF, if any
    private String fileSpec;

    /**
     * Reads an XFDF form.
     *
     * @param filename the file name of the form
     * @throws IOException on error
     */
    public XfdfReader(String filename) throws IOException {
        try (FileInputStream fin = new FileInputStream(filename)) {
            SimpleXMLParser.parse(this, fin);
        }
    }

    /**
     * Reads an XFDF form.
     *
     * @param xfdfIn the byte array with the form
     * @throws IOException on error
     */
    public XfdfReader(byte[] xfdfIn) throws IOException {
        SimpleXMLParser.parse(this, new ByteArrayInputStream(xfdfIn));
    }

    @Override
    public Map<String, String> getAllFields() {
        return fields;
    }

    /**
     * Gets the field value.
     *
     * @param name the fully qualified field name
     * @return the field's value
     */
    public String getField(String name) {
        return fields.get(name);
    }

    /**
     * Gets the field value or <CODE>null</CODE> if the field does not exist or has no value defined.
     *
     * @param name the fully qualified field name
     * @return the field value or <CODE>null</CODE>
     */
    @Override
    public String getFieldValue(String name) {
        return fields.get(name);
    }

    /**
     * Gets the field values for a list or <CODE>null</CODE> if the field does not exist or has no value defined.
     *
     * @param name the fully qualified field name
     * @return the field values or <CODE>null</CODE>
     * @since 2.1.4
     */
    @Override
    public List<String> getListValues(String name) {
        return listFields.get(name);
    }

    /**
     * Gets the PDF file specification contained in the FDF.
     *
     * @return the PDF file specification contained in the FDF
     */
    public String getFileSpec() {
        return fileSpec;
    }

    /**
     * Called when a start tag is found.
     *
     * @param tag the tag name
     * @param h   the tag's attributes
     */
    @Override
    public void startElement(String tag, Map<String, String> h) {
        if (!foundRoot) {
            if (!tag.equals("xfdf")) {
                throw new RuntimeException(MessageLocalization.getComposedMessage("root.element.is.not.xfdf.1", tag));
            } else {
                foundRoot = true;
            }
        }

        switch (tag) {
            case "xfdf":
                // intentionally left blank
                break;
            case "f":
                fileSpec = h.get("href");
                break;
            case "fields":
                fields = new HashMap<>();    // init it!

                listFields = new HashMap<>();
                break;
            case "field":
                String fName = h.get("name");
                fieldNames.push(fName);
                break;
            case "value":
                fieldValues.push("");
                break;
        }
    }

    /**
     * Called when an end tag is found.
     *
     * @param tag the tag name
     */
    @Override
    public void endElement(String tag) {<FILL_FUNCTION_BODY>}

    /**
     * Called when the document starts to be parsed.
     */
    public void startDocument() {
        fileSpec = "";
    }

    /**
     * Called after the document is parsed.
     */
    public void endDocument() {

    }

    /**
     * Called when a text element is found.
     *
     * @param str the text element, probably a fragment.
     */
    public void text(String str) {
        if (fieldNames.isEmpty() || fieldValues.isEmpty()) {
            return;
        }

        String val = fieldValues.pop();
        val += str;
        fieldValues.push(val);
    }
}

        if (tag.equals("value")) {
            StringBuilder fName = new StringBuilder();
            for (int k = 0; k < fieldNames.size(); ++k) {
                fName.append(".").append(fieldNames.elementAt(k));
            }
            if (fName.toString().startsWith(".")) {
                fName = new StringBuilder(fName.substring(1));
            }
            String fVal = fieldValues.pop();
            String old = fields.put(fName.toString(), fVal);
            if (old != null) {
                List<String> l = listFields.get(fName.toString());
                if (l == null) {
                    l = new ArrayList<>();
                    l.add(old);
                }
                l.add(fVal);
                listFields.put(fName.toString(), l);
            }
        } else if (tag.equals("field")) {
            if (!fieldNames.isEmpty()) {
                fieldNames.pop();
            }
        }
    
<no_super_class>