public abstract class PDChoice extends PDVariableText
QUADDING_CENTERED, QUADDING_LEFT, QUADDING_RIGHT
Constructor and Description |
---|
PDChoice(PDAcroForm acroForm) |
Modifier and Type | Method and Description |
---|---|
List<String> |
getDefaultValue()
Returns the default values, or an empty List.
|
List<String> |
getOptions()
This will get the option values "Opt".
|
List<String> |
getOptionsDisplayValues()
This will get the display values from the options.
|
List<String> |
getOptionsExportValues()
This will get the export values from the options.
|
List<Integer> |
getSelectedOptionsIndex()
This will get the indices of the selected options - the 'I' key.
|
List<String> |
getValue()
Returns the selected values, or an empty List.
|
String |
getValueAsString()
Returns a string representation of the "V" entry, or an empty string.
|
boolean |
isCombo()
Determines if Combo is set.
|
boolean |
isCommitOnSelChange()
Determines if CommitOnSelChange is set.
|
boolean |
isDoNotSpellCheck()
Determines if DoNotSpellCheck is set.
|
boolean |
isMultiSelect()
Determines if MultiSelect is set.
|
boolean |
isSort()
Determines if Sort is set.
|
void |
setCombo(boolean combo)
Set the Combo bit.
|
void |
setCommitOnSelChange(boolean commitOnSelChange)
Set the CommitOnSelChange bit.
|
void |
setDefaultValue(String value)
Sets the default value of this field.
|
void |
setDoNotSpellCheck(boolean doNotSpellCheck)
Set the DoNotSpellCheck bit.
|
void |
setMultiSelect(boolean multiSelect)
Set the MultiSelect bit.
|
void |
setOptions(List<String> displayValues)
This will set the display values - the 'Opt' key.
|
void |
setOptions(List<String> exportValues,
List<String> displayValues)
This will set the display and export values - the 'Opt' key.
|
void |
setSelectedOptionsIndex(List<Integer> values)
This will set the indices of the selected options - the 'I' key.
|
void |
setSort(boolean sort)
Set the Sort bit.
|
void |
setValue(List<String> values)
Sets the entry "V" to the given values.
|
void |
setValue(String value)
Sets the selected value of this field.
|
getDefaultAppearance, getDefaultStyleString, getQ, getRichTextValue, getStringOrStream, setDefaultAppearance, setDefaultStyleString, setQ, setRichTextValue
applyChange, getFieldFlags, getFieldType, getWidget, getWidgets, importFDF, setActions, setWidgets
getAcroForm, getActions, getAlternateFieldName, getCOSObject, getFullyQualifiedName, getInheritableAttribute, getMappingName, getParent, getPartialName, isNoExport, isReadOnly, isRequired, setAlternateFieldName, setFieldFlags, setMappingName, setNoExport, setPartialName, setReadOnly, setRequired, toString
public PDChoice(PDAcroForm acroForm)
acroForm
- The acroform.PDField.PDField(PDAcroForm)
public List<String> getOptions()
For a choice field the options array can either be an array
of text strings or an array of a two-element arrays.
The method always only returns either the text strings or,
in case of two-element arrays, an array of the first element of
the two-element arrays
Use getOptionsExportValues()
and getOptionsDisplayValues()
to get the entries of two-element arrays.
public void setOptions(List<String> displayValues)
The Opt array specifies the list of options in the choice field either as an array of text strings representing the display value or as an array of a two-element array where the first element is the export value and the second the display value.
To set both the export and the display value use setOptions(List, List)
displayValues
- List containing all possible options.public void setOptions(List<String> exportValues, List<String> displayValues)
This will set both, the export value and the display value of the choice field. If either one of the parameters is null or an empty list is supplied the options will be removed.
An IllegalArgumentException
will be thrown if the
number of items in the list differ.
exportValues
- List containing all possible export values.displayValues
- List containing all possible display values.setOptions(List)
public List<String> getOptionsDisplayValues()
For options with an array of text strings the display value and export value
are the same.
For options with an array of two-element arrays the display value is the
second entry in the two-element array.
public List<String> getOptionsExportValues()
For options with an array of text strings the display value and export value
are the same.
For options with an array of two-element arrays the export value is the
first entry in the two-element array.
public List<Integer> getSelectedOptionsIndex()
This is only needed if a choice field allows multiple selections and two different items have the same export value or more than one values is selected.
The indices are zero-based
public void setSelectedOptionsIndex(List<Integer> values)
This method is preferred over setValue(List)
for choice fields which
Setting the index will set the value too.
values
- List containing the indices of all selected options.public boolean isSort()
If set, the field’s option items shall be sorted alphabetically. The sorting has to be done when writing the PDF. PDF Readers are supposed to display the options in the order in which they occur in the Opt array.
public void setSort(boolean sort)
sort
- The value for Sort.isSort()
public boolean isMultiSelect()
public void setMultiSelect(boolean multiSelect)
multiSelect
- The value for MultiSelect.public boolean isDoNotSpellCheck()
public void setDoNotSpellCheck(boolean doNotSpellCheck)
doNotSpellCheck
- The value for DoNotSpellCheck.public boolean isCommitOnSelChange()
public void setCommitOnSelChange(boolean commitOnSelChange)
commitOnSelChange
- The value for CommitOnSelChange.public boolean isCombo()
public void setCombo(boolean combo)
combo
- The value for Combo.public void setValue(String value) throws IOException
setValue
in class PDField
value
- The name of the selected item.IOException
- if the value could not be setpublic void setDefaultValue(String value) throws IOException
value
- The name of the selected item.IOException
- if the value could not be setpublic void setValue(List<String> values) throws IOException
isMultiSelect()
to be true.values
- the list of valuesIOException
- if the appearance couldn't be generated.public List<String> getValue()
isMultiSelect()
is true.public List<String> getDefaultValue()
isMultiSelect()
is true.public String getValueAsString()
PDField
getValueAsString
in class PDField
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.