public class AcroCheckboxField extends AcroButtonField
Instances of this class represent individual checkboxes in an interactive forms
.
Refer to AcroButtonField
and AcroFormField
for overview documentation.
In addition to the standard AcroFormField.setValue(String)
function, AcroCheckboxField
instances provide a setValue(boolean)
function, making it easy to set the state of a checkbox form field
without the extra indirection of having to determine what String value needs to be used to set it to the "checked"
state.
Modifier and Type | Field and Description |
---|---|
protected com.snowtide.pdf.PDFTextStreamCallback |
callback |
BUTTON_TYPE_CHECKBOX, BUTTON_TYPE_PUSHBUTTON, BUTTON_TYPE_RADIO_GROUP, DEFAULT_UNSELECTED_VALUE
FIELD_TYPE_BUTTON, FIELD_TYPE_CHOICE, FIELD_TYPE_OTHER, FIELD_TYPE_SIGNATURE, FIELD_TYPE_TEXT
Modifier and Type | Method and Description |
---|---|
boolean |
canChangeValue()
This function always returns true.
|
java.lang.String |
getCheckedValue()
Returns the value that represents the checked state for this checkbox.
|
java.lang.Object |
getDefaultValue()
Returns the default value to which the field reverts when a reset-form action is executed,
as specified in the /DV entry in this field's PDF dictionary.
|
java.lang.String |
getFullName()
Returns the fully-qualified name of this field, which should be unique within a PDF document form.
|
java.lang.String |
getLocalName()
Returns the local name of the field, as specified in the /T entry in this field's PDF dictionary.
|
java.lang.String |
getMappingName()
Returns the 'mapping name' of this field, as specified in the /TM entry in this field's PDF dictionary.
|
java.lang.String |
getName()
Returns the canonical name of this field.
|
java.lang.Object |
getType()
Returns the type of field, as specified in the /FT entry in this field's PDF dictionary.
|
java.lang.String |
getUIName()
Returns the user-friendly name of this field, as specified in the /TU entry in this field's PDF
dictionary.
|
boolean |
hasValueChanged()
Returns true only if this field's value has been changed since being loaded from the PDF document.
|
boolean |
isChecked()
Returns true only if this checkbox is checked (i.e.
|
boolean |
isReadOnly()
Returns true only if this field is designated as read-only.
|
boolean |
setValue(boolean checked)
Sets the value of this checkbox field to be checked (true) or unchecked (false).
|
boolean |
setValue(java.lang.String value)
Sets the value of this checkbox directly.
|
getButtonType, getExportValue, getExportValues, getValue
public java.lang.String getCheckedValue()
public boolean setValue(boolean checked)
Sets the value of this checkbox field to be checked (true) or unchecked (false). If this function call results in the actual value of the checkbox changing, then true will be returned. False will be returned only if:
getCheckedValue()
.public boolean isChecked()
AcroButtonField.getValue()
.equals(getCheckedValue()
)).public boolean setValue(java.lang.String value) throws java.lang.IllegalArgumentException
Sets the value of this checkbox directly. The provided value must be one of: null (unchecks the checkbox),
AcroButtonField.DEFAULT_UNSELECTED_VALUE
(unchecks the checkbox), or the checked value
for this checkbox (which will check the checkbox).
Using the setValue(boolean)
function instead of this one is recommended.
If this function call results in the actual value of the checkbox changing, then true will be returned. False will be returned only if the checkbox field already has the specified value.
setValue
in interface AcroFormField
java.lang.IllegalArgumentException
- - if an invalid value is provided as described above.public boolean canChangeValue()
canChangeValue
in interface AcroFormField
public boolean isReadOnly()
AcroFormField
isReadOnly
in interface AcroFormField
public java.lang.Object getDefaultValue()
AcroFormField
AcroFormField.getValue()
function, and depends upon the
type of this field.getDefaultValue
in interface AcroFormField
public java.lang.String getFullName()
AcroFormField
Returns the fully-qualified name of this field, which should be unique within a PDF document form. Details of how full names are constructed are specified in Section 8.6.2 (Field Names) of the PDF Document Specification.
It suffices to say here that form fields in an interactive AcroForm are defined in a hierarchical manner,
and that their local names
are used to derive a period-delimited
full name that guarantees each name's uniqueness within the parent AcroForm.
getFullName
in interface AcroFormField
public java.lang.String getLocalName()
AcroFormField
FormField.getName()
implementation.getLocalName
in interface AcroFormField
public java.lang.String getMappingName()
AcroFormField
getMappingName
in interface AcroFormField
public java.lang.String getName()
FormField
FormField
instance with a particular name should be available from a Form
instance.public java.lang.Object getType()
AcroFormField
FIELD_TYPE_BUTTON
, then this AcroFormField
is an instance of AcroButtonField
FIELD_TYPE_TEXT
, then this AcroFormField
is an instance of AcroTextField
FIELD_TYPE_CHOICE
, then this AcroFormField
is an instance of AcroChoiceField
FIELD_TYPE_SIGNATURE
, then this AcroFormField
is an instance of AcroSignatureField
FIELD_TYPE_OTHER
, then this AcroFormField
has no specific concrete implementation. This case is reserved for form fields
with new type indicators that may be introduced by Adobe in the future.getType
in interface AcroFormField
public boolean hasValueChanged()
AcroFormField
hasValueChanged
in interface AcroFormField
public java.lang.String getUIName()
AcroFormField
Returns the user-friendly name of this field, as specified in the /TU entry in this field's PDF dictionary. This function can return null if no user-friendly field name is defined.
getUIName
in interface AcroFormField
getUIName
in interface FormField