class PDTerminalField extends PDField
{
    /**
     * Constructor.
     * 
     * @param acroForm The form that this field is part of.
     */
    protected PDTerminalField(PDAcroForm acroForm)
    {
        super(acroForm);
    }

    /**
     * Constructor.
     * 
     * @param acroForm The form that this field is part of.
     * @param field the PDF object to represent as a field.
     * @param parent the parent node of the node
     */
    PDTerminalField(PDAcroForm acroForm, COSDictionary field, PDNonTerminalField parent)
    {
        super(acroForm, field, parent);
    }

    /**
     * Set the actions of the field.
     * 
     * @param actions The field actions.
     */
    public void setActions(PDFormFieldAdditionalActions actions)
    {
        getCOSObject().setItem(COSName.AA, actions);
    }
    
    @Override
    public int getFieldFlags()
    {<FILL_FUNCTION_BODY>}
    
    @Override
    public String getFieldType()
    {
        String fieldType = getCOSObject().getNameAsString(COSName.FT);
        if (fieldType == null && getParent() != null)
        {
            fieldType = getParent().getFieldType();
        }
        return fieldType;
    }

    @Override
    public void importFDF(FDFField fdfField) throws IOException
    {
        super.importFDF(fdfField);
        
        Integer f = fdfField.getWidgetFieldFlags();
        for (PDAnnotationWidget widget : getWidgets())
        {
            if (f != null)
            {
                widget.setAnnotationFlags(f);
            }
            else
            {
                // these are supposed to be ignored if the F is set.
                Integer setF = fdfField.getSetWidgetFieldFlags();
                int annotFlags = widget.getAnnotationFlags();
                if (setF != null)
                {
                    annotFlags = annotFlags | setF;
                    widget.setAnnotationFlags(annotFlags);
                }

                Integer clrF = fdfField.getClearWidgetFieldFlags();
                if (clrF != null)
                {
                    // we have to clear the bits of the document fields for every bit that is
                    // set in this field.
                    //
                    // Example:
                    // docF = 1011
                    // clrF = 1101
                    // clrFValue = 0010;
                    // newValue = 1011 & 0010 which is 0010
                    int clrFValue = clrF;
                    clrFValue ^= 0xFFFFFFFFL;
                    annotFlags = annotFlags & clrFValue;
                    widget.setAnnotationFlags(annotFlags);
                }
            }
        }
    }

    @Override
    FDFField exportFDF() throws IOException
    {
        FDFField fdfField = new FDFField();
        fdfField.setPartialFieldName(getPartialName());
        fdfField.setValue(getCOSObject().getDictionaryObject(COSName.V));

        // fixme: the old code which was here assumed that Kids were PDField instances,
        //        which is never true. They're annotation widgets.
        
        return fdfField;
    }

    /**
     * Returns the widget annotations associated with this field.
     *
     * @return The list of widget annotations. Be aware that this list is <i>not</i> backed by the
     * actual widget collection of the field, so adding or deleting has no effect on the PDF
     * document until you call {@link #setWidgets(java.util.List) setWidgets()} with the modified
     * list.
     */
    @Override
    public List<PDAnnotationWidget> getWidgets()
    {
        List<PDAnnotationWidget> widgets = new ArrayList<>();
        COSArray kids = getCOSObject().getCOSArray(COSName.KIDS);
        if (kids == null)
        {
            // the field itself is a widget
            widgets.add(new PDAnnotationWidget(getCOSObject()));
        }
        else if (!kids.isEmpty())
        {
            // there are multiple widgets
            for (int i = 0; i < kids.size(); i++)
            {
                COSBase kid = kids.getObject(i);
                if (kid instanceof COSDictionary)
                {
                    widgets.add(new PDAnnotationWidget((COSDictionary)kid));
                }
            }
        }
        return widgets;
    }

    /**
     * Sets the field's widget annotations.
     *
     * @param children The list of widget annotations.
     */
    public void setWidgets(List<PDAnnotationWidget> children)
    {
        COSArray kidsArray = new COSArray(children);
        getCOSObject().setItem(COSName.KIDS, kidsArray);
        for (PDAnnotationWidget widget : children)
        {
            widget.getCOSObject().setItem(COSName.PARENT, this);
        }
    }
    
    /**
     * Applies a value change to the field. Generates appearances if required and raises events.
     * 
     * @throws IOException if the appearance couldn't be generated
     */
    protected final void applyChange() throws IOException
    {
        constructAppearances();
        // if we supported JavaScript we would raise a field changed event here
    }
    
    /**
     * Constructs appearance streams and appearance dictionaries for all widget annotations.
     * Subclasses should not call this method directly but via {@link #applyChange()}.
     * 
     * @throws IOException if the appearance couldn't be generated
     */
    abstract void constructAppearances() throws IOException;
}

        int retval = 0;
        COSInteger ff = (COSInteger) getCOSObject().getDictionaryObject(COSName.FF);
        if (ff != null)
        {
            retval = ff.intValue();
        }
        else if (getParent() != null)
        {
            retval = getParent().getFieldFlags();
        }
        return retval;
    
<methods>public org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm getAcroForm() ,public org.apache.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions getActions() ,public java.lang.String getAlternateFieldName() ,public org.apache.pdfbox.cos.COSDictionary getCOSObject() ,public abstract int getFieldFlags() ,public abstract java.lang.String getFieldType() ,public java.lang.String getFullyQualifiedName() ,public java.lang.String getMappingName() ,public org.apache.pdfbox.pdmodel.interactive.form.PDNonTerminalField getParent() ,public java.lang.String getPartialName() ,public abstract java.lang.String getValueAsString() ,public abstract List<org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget> getWidgets() ,public boolean isNoExport() ,public boolean isReadOnly() ,public boolean isRequired() ,public void setAlternateFieldName(java.lang.String) ,public void setFieldFlags(int) ,public void setMappingName(java.lang.String) ,public void setNoExport(boolean) ,public void setPartialName(java.lang.String) ,public void setReadOnly(boolean) ,public void setRequired(boolean) ,public abstract void setValue(java.lang.String) throws java.io.IOException,public java.lang.String toString() <variables>private static final int FLAG_NO_EXPORT,private static final int FLAG_READ_ONLY,private static final int FLAG_REQUIRED,private final non-sealed org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm acroForm,private final non-sealed org.apache.pdfbox.cos.COSDictionary dictionary,private final non-sealed org.apache.pdfbox.pdmodel.interactive.form.PDNonTerminalField parent