com.snowtide.pdf.forms
Class AcroTextField

java.lang.Object
  extended by com.snowtide.pdf.forms.AcroTextField
All Implemented Interfaces:
AcroFormField, FormField

public class AcroTextField
extends java.lang.Object

Represents a text field in an interactive AcroForm.

Text fields can either be plain or 'rich'. Plain text fields return false from hasRichTextValue(), and their getValue() function will return a simple String object. Rich text fields return true from hasRichTextValue(), and their getValue() function will return an XHTML rich text string, as specified in Section 8.6.2 of the PDF document specification.

Version:
©2004-2012 Snowtide Informatics Systems, Inc.

Field Summary
protected  com.snowtide.pdf.PDFTextStreamCallback callback
           
 
Fields inherited from interface com.snowtide.pdf.forms.AcroFormField
FIELD_TYPE_BUTTON, FIELD_TYPE_CHOICE, FIELD_TYPE_OTHER, FIELD_TYPE_SIGNATURE, FIELD_TYPE_TEXT
 
Method Summary
 boolean canChangeValue()
          This function always returns true.
 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.
 int getMaxLength()
          Returns the maximum length of this field, as specified by this form field's /MaxLen entry.
 java.lang.String getName()
          Returns the canonical name of this field.
 java.lang.String getRichTextValue()
          Returns the 'rich text' value for this field (XHTML that conforms to the XFA specification), if available.
 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.
 java.lang.Object getValue()
          Returns the value of this field, as specified in the /V entry in this field's PDF dictionary.
 boolean hasRichTextValue()
          Returns true only if the value of this field is 'rich text' (XHTML that conforms to the XFA specification), which may be retrieved via the getRichTextValue() function.
 boolean hasValueChanged()
          Returns true only if this field's value has been changed since being loaded from the PDF document.
 boolean isFileSelection()
          Returns true if this is field is designated to hold the path of a user-selected file.
 boolean isMultiline()
          Returns true if this is a multiline text field.
 boolean isPasswordEntry()
          Returns true if this is a password-entry text field.
 boolean isReadOnly()
          Returns true only if this field is designated as read-only.
 boolean setValue(java.lang.String val)
          Sets the value of this text field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callback

protected final com.snowtide.pdf.PDFTextStreamCallback callback
Method Detail

setValue

public boolean setValue(java.lang.String val)
                 throws java.lang.IllegalArgumentException
Sets the value of this text field. The provided String must not be null; otherwise, this function will throw an IllegalArgumentException. This function returns true only if the provided String value is different than the current value of the field.

Specified by:
setValue in interface AcroFormField
Throws:
java.lang.IllegalArgumentException - - if the provided value is invalid for the particular field or field type at hand. Refer to each field type's class javadoc for details on how and when a field value parameter is considered invalid.

canChangeValue

public boolean canChangeValue()
This function always returns true.

Specified by:
canChangeValue in interface AcroFormField

getMaxLength

public int getMaxLength()
Returns the maximum length of this field, as specified by this form field's /MaxLen entry. This function will return -1 if the maximum length is undefined.


getRichTextValue

public java.lang.String getRichTextValue()
Returns the 'rich text' value for this field (XHTML that conforms to the XFA specification), if available. If this field does not contain a rich text value, then the field's value is available via the AcroFormField.getValue() function.

See Also:
hasRichTextValue()

isMultiline

public boolean isMultiline()
Returns true if this is a multiline text field.


isPasswordEntry

public boolean isPasswordEntry()
Returns true if this is a password-entry text field.


isFileSelection

public boolean isFileSelection()
Returns true if this is field is designated to hold the path of a user-selected file.


hasRichTextValue

public boolean hasRichTextValue()
Returns true only if the value of this field is 'rich text' (XHTML that conforms to the XFA specification), which may be retrieved via the getRichTextValue() function. If this function returns false, then the field's value is available via AcroFormField.getValue().

See Also:
getRichTextValue()

isReadOnly

public boolean isReadOnly()
Description copied from interface: AcroFormField
Returns true only if this field is designated as read-only. Note that this is just a hint, provided for the benefit of end-user tools. PDFTextStream does not enforce the read-only state of a form field; i.e. it will allow a field's value to be set even if it is designated as read-only.

Specified by:
isReadOnly in interface AcroFormField

getDefaultValue

public java.lang.Object getDefaultValue()
Description copied from interface: AcroFormField
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. The type of the returned object will be the same as the type of object returned by the AcroFormField.getValue() function, and depends upon the type of this field.

Specified by:
getDefaultValue in interface AcroFormField

getFullName

public java.lang.String getFullName()
Description copied from interface: 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.

Specified by:
getFullName in interface AcroFormField

getLocalName

public java.lang.String getLocalName()
Description copied from interface: AcroFormField
Returns the local name of the field, as specified in the /T entry in this field's PDF dictionary. This name is also used as the value returned by the FormField.getName() implementation.

Specified by:
getLocalName in interface AcroFormField

getMappingName

public java.lang.String getMappingName()
Description copied from interface: AcroFormField
Returns the 'mapping name' of this field, as specified in the /TM entry in this field's PDF dictionary. The mapping name is used to identify the field in exported form data formats. This function can return null if no mapping name is defined.

Specified by:
getMappingName in interface AcroFormField

getName

public java.lang.String getName()
Description copied from interface: FormField
Returns the canonical name of this field. Only one FormField instance with a particular name should be available from a Form instance.

Specified by:
getName in interface FormField

getType

public java.lang.Object getType()
Description copied from interface: AcroFormField
Returns the type of field, as specified in the /FT entry in this field's PDF dictionary. This is an indication of the subtype of this AcroFormField instance:

Specified by:
getType in interface AcroFormField

hasValueChanged

public boolean hasValueChanged()
Description copied from interface: AcroFormField
Returns true only if this field's value has been changed since being loaded from the PDF document.

Specified by:
hasValueChanged in interface AcroFormField

getUIName

public java.lang.String getUIName()
Description copied from interface: 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.

Specified by:
getUIName in interface AcroFormField
Specified by:
getUIName in interface FormField

getValue

public java.lang.Object getValue()
Description copied from interface: AcroFormField
Returns the value of this field, as specified in the /V entry in this field's PDF dictionary. The type of the returned object depends upon the type of this field.

Specified by:
getValue in interface AcroFormField
Specified by:
getValue in interface FormField