intarsys PDF library API

de.intarsys.pdf.pd
Class PDAcroFormField

java.lang.Object
  extended by de.intarsys.pdf.cos.COSBasedObject
      extended by de.intarsys.pdf.pd.PDObject
          extended by de.intarsys.pdf.pd.PDAcroFormNode
              extended by de.intarsys.pdf.pd.PDAcroFormField
All Implemented Interfaces:
ICOSObjectListener, IAdditionalActionSupport, IAttributeSupport
Direct Known Subclasses:
PDAFButtonField, PDAFChoiceField, PDAFIntermediateNode, PDAFSignatureField, PDAFTextField

public abstract class PDAcroFormField
extends PDAcroFormNode
implements IAdditionalActionSupport

Abstract superclass for the different field types in an AcroForm.


Nested Class Summary
static class PDAcroFormField.MetaClass
          The meta class implementation
 
Field Summary
static Set ACROFORMFIELD_ACTION_TRIGGERS
          supported additional action triggers
static int ALIGNMENT_CENTER
          alignment constant: 1: Centered
static int ALIGNMENT_LEFT
          alignment constant: 0: Left-justified
static int ALIGNMENT_RIGHT
          alignment constant: 2: Right-justified
static COSName CN_FT_Btn
          Field type Button
static COSName CN_FT_Ch
          Field type Choice
static COSName CN_FT_Sig
          Field type Signature
static COSName CN_FT_Tx
          Field type Text
static COSName DK_DS
          The name for the DefaultStyle entry.
static COSName DK_DV
          The key for the DefaultValue entry.
static COSName DK_Ff
          The name of the FieldFlags entry.
static COSName DK_FT
          The name for field types entry.
static COSName DK_Kids
          The name for the childrens entry.
static COSName DK_MaxLen
          The name for the MaximumLength entry.
static COSName DK_Parent
          The name for the parent entry.
static COSName DK_RV
          The name for RichTextString value entry.
static COSName DK_T
          The name for the partial field name entry, also called the local name.
static COSName DK_TM
          The name for the mapping entry.
static COSName DK_TU
          The name for the AlternateFieldName entry.
static COSName DK_V
          The name for the fields value entry.
static PDAcroFormField.MetaClass META
          The meta class instance
 
Fields inherited from class de.intarsys.pdf.pd.PDAcroFormNode
DK_DA, DK_DR, DK_Encoding, DK_Font, DK_Q
 
Fields inherited from class de.intarsys.pdf.pd.PDObject
DK_Subtype, DK_Type
 
Fields inherited from interface de.intarsys.pdf.pd.IAdditionalActionSupport
DK_AA
 
Method Summary
 void addAnnotation(PDWidgetAnnotation annot)
          Insert a new PDAnnotation object for the form field.
 void addField(PDAcroFormField field)
          Insert a PDAcroFormField in the receiver node.
 int basicGetFieldFlags()
          Get the integer representing the field flags.
 void basicSetFieldFlags(int newFlags)
          Assign the integer representing the field flags.
 PDAcroFormField copy()
          Copy the receiver.
 COSObject cosGetDefaultValue()
          Tries to return a valid /DV entry: returns its own /DV entry, if it is not null returns the /DV entry of its logical root, if it is not null returns the first /DV entry found of the logical roots kids null if nothing was found
abstract  COSName cosGetExpectedFieldType()
          The AcroForm field type expected for this.
 COSName cosGetFieldType()
          The real AcroForm field type of this.
 COSObject cosGetValue()
          Tries to return a valid /V entry: returns its own /V entry, if it is not null returns the /V entry of its logical root, if it is not null returns the first /V entry found of the logical roots kids null if nothing was found
 COSObject cosSetValue(COSObject newValue)
          Sets the /V entry in this node and removes all /V entries in child nodes.
 void dispose(boolean disposeEmptyAncestors)
          Deprecated.  
 PDAcroForm getAcroForm()
          The PDAcroForm for this node.
 PDAdditionalActions getAdditionalActions()
           
 String getAlternateFieldName()
          The fields alternate name.
 PDAnnotation getAnyAnnotation()
          Deprecated.  
 String getDefaultValueString()
          The value from cosGetDefaultValue() converted to a String
 AcroFormFieldFlags getFieldFlags()
          The flags associated with the form field.
 List getGenericChildren()
          Get a collection of PDObject children if the receiver is a node in a hierarchical structure (like page nodes or form fields).
 PDObject getGenericParent()
          The parent of the receiver if it is a node in a hierarchical structure (like page nodes or form fields).
 List getKids()
          The child nodes of this (named after the /Kids key in the defining COSDictionary);
 String getLocalName()
          The local name for this node.
 String getLocalName(boolean canonical)
          The local name for this node.
 PDAcroFormNode getLogicalParent()
          The logical parent node of this PDAcroFormField.
 PDAcroFormField getLogicalRoot()
          The logical root node of this PDAcroFormField.
 Integer getMaxLen()
          The maximum length for this field or null if not defined.
 PDAcroFormField getParent()
          The parent node of this.
 String getQualifiedName()
          A fully qualified name for this.
 String getQualifiedName(boolean canonical)
          A fully qualified name for this.
 Set getSupportedTriggerEvents()
           
 String getValueString()
          The value from cosGetValue() converted to a String
 void invalidateCaches()
          Invalidate all local caches as the base object may have changed.
 boolean isAlignmentCenter()
          true if variable text in this is centered.
 boolean isAlignmentLeft()
          true if variable text in this is left aligned.
 boolean isAlignmentRight()
          true if variable text in this is right aligned.
 boolean isAnnotation()
          Returns true when the field is an annotation
 boolean isComb()
          Convenience to access "comb" flag.
 boolean isDoNotScroll()
          Convenience to access "DoNotScroll" flag.
 boolean isMultiline()
          Convenience to access "Multiline" flag.
 boolean isNoExport()
          Convenience to access "NoExport" flag.
 boolean isReadOnly()
          Convenience to access "ReadOnly" flag.
 boolean isTypeBtn()
          Return true if this is a field of type "Btn".
 boolean isTypeCh()
          Return true if this is a field of type "Ch".
 boolean isTypeSig()
          Return true if this is a field of type "Sig".
 boolean isTypeTx()
          Return true if this is a text field.
 boolean removeField(PDAcroFormField field)
          Remove a PDAcroFormField from the receiver.
 void reset()
          Reset this to its default value.
 void setAdditionalActions(PDAdditionalActions actions)
           
 void setAlignmentCenter()
          Make variable text centered.
 void setAlignmentLeft()
          Make variable text left aligned.
 void setAlignmentRight()
          Make variable text right aligned.
 void setAlternateFieldName(String newAlternateFieldName)
          Asssign a alternate field name.
 void setComb(boolean f)
          Convenience method to access "Comb" flag.
 void setDefaultValue(String value)
          Assign a new default value.
 void setDoNotScroll(boolean f)
          Convenience method to access "DoNotScroll" flag.
 void setLocalName(String newLocalName)
          Assign a new local name.
 void setMaxLength(Integer newMaxLength)
          Set the maximum length for this field.
 void setMultiline(boolean f)
          Convenience method to access "Multiline" flag.
 void setNoExport(boolean f)
          Convenience method to access "NoExport" flag.
 void setReadOnly(boolean f)
          Convenience method to access "ReadOnly" flag.
 void setValueString(String value)
          Set the value of this.
 void setValueStrings(List values)
          Set the value of this to a List of String objects.
 String toString()
           
 
Methods inherited from class de.intarsys.pdf.pd.PDAcroFormNode
canonicalize, collectLeafFields, getAnnotation, getAnnotations, getDefaultAppearanceContent, getDefaultAppearanceFont, getDefaultAppearanceFontColor, getDefaultAppearanceFontName, getDefaultAppearanceFontSize, getField, getField, getQuadding, setDefaultAppearanceContent, setDefaultAppearanceFont, setDefaultAppearanceFontColor, setDefaultAppearanceFontSize, setQuadding
 
Methods inherited from class de.intarsys.pdf.pd.PDObject
cosGetFieldDescendant, cosGetFieldInheritable, cosGetFieldInherited, cosGetSubtype, cosGetType, cosRemoveFieldInheritable, cosSetFieldInheritable, cosSetSubtype, cosSetType, getDoc, setGenericParent
 
Methods inherited from class de.intarsys.pdf.cos.COSBasedObject
changed, cosGetArray, cosGetDict, cosGetDoc, cosGetField, cosGetObject, cosGetStream, cosHasField, cosRemoveField, cosSetField, getAttribute, getFieldBoolean, getFieldDate, getFieldFixed, getFieldFixedArray, getFieldInt, getFieldMLString, getFieldString, removeAttribute, setAttribute, setFieldBoolean, setFieldFixed, setFieldInt, setFieldMLString, setFieldName, setFieldObject, setFieldString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DK_FT

public static final COSName DK_FT
The name for field types entry.


CN_FT_Btn

public static final COSName CN_FT_Btn
Field type Button


CN_FT_Tx

public static final COSName CN_FT_Tx
Field type Text


CN_FT_Ch

public static final COSName CN_FT_Ch
Field type Choice


CN_FT_Sig

public static final COSName CN_FT_Sig
Field type Signature


DK_Parent

public static final COSName DK_Parent
The name for the parent entry.


DK_Kids

public static final COSName DK_Kids
The name for the childrens entry.


DK_T

public static final COSName DK_T
The name for the partial field name entry, also called the local name.


DK_TU

public static final COSName DK_TU
The name for the AlternateFieldName entry.


DK_TM

public static final COSName DK_TM
The name for the mapping entry.


DK_Ff

public static final COSName DK_Ff
The name of the FieldFlags entry.

For a list of possible flags:

See Also:
AcroFormFieldFlags

DK_V

public static final COSName DK_V
The name for the fields value entry.


DK_DV

public static final COSName DK_DV
The key for the DefaultValue entry.


ALIGNMENT_LEFT

public static final int ALIGNMENT_LEFT
alignment constant: 0: Left-justified

See Also:
Constant Field Values

ALIGNMENT_CENTER

public static final int ALIGNMENT_CENTER
alignment constant: 1: Centered

See Also:
Constant Field Values

ALIGNMENT_RIGHT

public static final int ALIGNMENT_RIGHT
alignment constant: 2: Right-justified

See Also:
Constant Field Values

DK_DS

public static final COSName DK_DS
The name for the DefaultStyle entry.


DK_RV

public static final COSName DK_RV
The name for RichTextString value entry.


ACROFORMFIELD_ACTION_TRIGGERS

public static final Set ACROFORMFIELD_ACTION_TRIGGERS
supported additional action triggers


META

public static final PDAcroFormField.MetaClass META
The meta class instance


DK_MaxLen

public static final COSName DK_MaxLen
The name for the MaximumLength entry.

Method Detail

addAnnotation

public void addAnnotation(PDWidgetAnnotation annot)
Insert a new PDAnnotation object for the form field. The annotation represents the visual component displaying the logical form field. A form field can be represented by more than one annotation.

Parameters:
annot - The PDAnnotation to add to the field.

addField

public void addField(PDAcroFormField field)
Description copied from class: PDAcroFormNode
Insert a PDAcroFormField in the receiver node.

Specified by:
addField in class PDAcroFormNode
Parameters:
field - The field to be inserted.

basicGetFieldFlags

public int basicGetFieldFlags()
Get the integer representing the field flags.

Returns:
Get the integer representing the field flags.

basicSetFieldFlags

public void basicSetFieldFlags(int newFlags)
Assign the integer representing the field flags.

Parameters:
newFlags - The new flags

copy

public PDAcroFormField copy()
Copy the receiver.

The copy made does NOT contain any children information.

Returns:
A copy of the receiver.

cosGetDefaultValue

public COSObject cosGetDefaultValue()
Tries to return a valid /DV entry:
  1. returns its own /DV entry, if it is not null
  2. returns the /DV entry of its logical root, if it is not null
  3. returns the first /DV entry found of the logical roots kids
  4. null if nothing was found

Returns:
see description

cosGetExpectedFieldType

public abstract COSName cosGetExpectedFieldType()
The AcroForm field type expected for this.

Returns:
The AcroForm field type expected for this.

cosGetFieldType

public COSName cosGetFieldType()
The real AcroForm field type of this.

Returns:
The real AcroForm field type of this.

cosGetValue

public COSObject cosGetValue()
Tries to return a valid /V entry:
  1. returns its own /V entry, if it is not null
  2. returns the /V entry of its logical root, if it is not null
  3. returns the first /V entry found of the logical roots kids
  4. null if nothing was found

Returns:
see description

cosSetValue

public COSObject cosSetValue(COSObject newValue)
Sets the /V entry in this node and removes all /V entries in child nodes.

Parameters:
newValue -
Returns:
The /V entry previously associated with this.

dispose

public void dispose(boolean disposeEmptyAncestors)
Deprecated. 

Parameters:
disposeEmptyAncestors -

getAcroForm

public PDAcroForm getAcroForm()
Description copied from class: PDAcroFormNode
The PDAcroForm for this node.

Specified by:
getAcroForm in class PDAcroFormNode
Returns:
The PDAcroForm for this node.

getAdditionalActions

public PDAdditionalActions getAdditionalActions()
Specified by:
getAdditionalActions in interface IAdditionalActionSupport

getAlternateFieldName

public String getAlternateFieldName()
The fields alternate name.

Returns:
The fields alternate name.

getAnyAnnotation

public PDAnnotation getAnyAnnotation()
Deprecated. 

a acro form field may be associated with a widget annotation. somewhere down in the hierarchy there MUST be an annotation. this method returns the first annotation available.

Returns:
the first associated annotation object if available (or null)

getFieldFlags

public AcroFormFieldFlags getFieldFlags()
The flags associated with the form field.

Returns:
The flags associated with the form field.

getGenericChildren

public List getGenericChildren()
Description copied from class: PDObject
Get a collection of PDObject children if the receiver is a node in a hierarchical structure (like page nodes or form fields).

This enables the generic implementation of inherited field values and so on.

A concrete PDObject implementation supporting inheritance should implement this method.

Overrides:
getGenericChildren in class PDObject
Returns:
A collection of PDObject children if the receiver is a node in a hierarchical structure .

getGenericParent

public PDObject getGenericParent()
Description copied from class: PDObject
The parent of the receiver if it is a node in a hierarchical structure (like page nodes or form fields).

A concrete PDObject implementation supporting inheritance should implement this method.

Overrides:
getGenericParent in class PDObject
Returns:
The parent of the receiver if it is a node in a hierarchical structure (like page nodes or form fields).

getKids

public List getKids()
The child nodes of this (named after the /Kids key in the defining COSDictionary);

Returns:
The child nodes of this.

getLocalName

public String getLocalName()
The local name for this node. This method returns null for an non existing or empty /T entry in the defining COSDictionary.

Returns:
The local name for this node.

getLocalName

public String getLocalName(boolean canonical)
The local name for this node. This method returns null for an non existing or empty /T entry in the base COSDictionary. The name is transformed to canonical form if canonical is true.

Parameters:
canonical - Flag if the name shoul be in canonical form.
Returns:
The local name for this node.

getLogicalParent

public PDAcroFormNode getLogicalParent()
The logical parent node of this PDAcroFormField.

The logical parent is the next node up the parent hierarchy that has a different qualified name, this means it is a node that does not designate the same logical field as the receiver.

Returns:
the logical parent, or the form itself.

getLogicalRoot

public PDAcroFormField getLogicalRoot()
The logical root node of this PDAcroFormField.

The logical root is the last node up the parent hierarchy that has the name qualified name, this means the topmost node that designates the same logical field as the receiver.

Returns:
the root field, or this.

getMaxLen

public Integer getMaxLen()
The maximum length for this field or null if not defined.

Returns:
The maximum length for this field or null if not defined.

getParent

public PDAcroFormField getParent()
The parent node of this.

AcroForm fields are arranged in a hierarchical structure, beginning with the root AcroForm. Fields under the AcroForm return null as their parent.

Returns:
The parent node of this.

getQualifiedName

public String getQualifiedName()
A fully qualified name for this.

The name of a acro form field is the concatenation of every node's name in the hierarchy, separated with '.'.

Returns:
A fully qualified name for this.

getQualifiedName

public String getQualifiedName(boolean canonical)
A fully qualified name for this. If requested, the name is in canonical format.

The name of a acro form field is the concatenation of every node's name in the hierarchy, separated with '.'.

Parameters:
canonical - Flag if the name is in canonical format
Returns:
A fully qualified name for this.

getSupportedTriggerEvents

public Set getSupportedTriggerEvents()
Specified by:
getSupportedTriggerEvents in interface IAdditionalActionSupport

getValueString

public String getValueString()
The value from cosGetValue() converted to a String

Returns:
The value from cosGetValue() converted to a String

getDefaultValueString

public String getDefaultValueString()
The value from cosGetDefaultValue() converted to a String

Returns:
The value from cosGetDefaultValue() converted to a String

invalidateCaches

public void invalidateCaches()
Description copied from class: COSBasedObject
Invalidate all local caches as the base object may have changed.

Overrides:
invalidateCaches in class PDAcroFormNode

isAlignmentCenter

public boolean isAlignmentCenter()
true if variable text in this is centered.

Returns:
true if variable text in this is centered.

isAlignmentLeft

public boolean isAlignmentLeft()
true if variable text in this is left aligned.

Returns:
true if variable text in this is left aligned.

isAlignmentRight

public boolean isAlignmentRight()
true if variable text in this is right aligned.

Returns:
true if variable text in this is right aligned.

isAnnotation

public boolean isAnnotation()
Returns true when the field is an annotation

Returns:
true when the field is an annotation

isComb

public boolean isComb()
Convenience to access "comb" flag.


isDoNotScroll

public boolean isDoNotScroll()
Convenience to access "DoNotScroll" flag.


isMultiline

public boolean isMultiline()
Convenience to access "Multiline" flag.


isNoExport

public boolean isNoExport()
Convenience to access "NoExport" flag.


isReadOnly

public boolean isReadOnly()
Convenience to access "ReadOnly" flag.


isTypeBtn

public boolean isTypeBtn()
Return true if this is a field of type "Btn".

"Btn" means this is a button style object.

Returns:
Return true if this is a field of type "Btn".

isTypeCh

public boolean isTypeCh()
Return true if this is a field of type "Ch".

"Ch" means this is a choice object.

Returns:
Return true if this is a field of type "Ch".

isTypeSig

public boolean isTypeSig()
Return true if this is a field of type "Sig".

"Sig" means this is a text style object.

Returns:
Return true if this is a field of type "Sig".

isTypeTx

public boolean isTypeTx()
Return true if this is a text field.

"Tx" means this is a text style object.

Returns:
Return true if this is a field of type "Tx".

removeField

public boolean removeField(PDAcroFormField field)
Description copied from class: PDAcroFormNode
Remove a PDAcroFormField from the receiver.

Specified by:
removeField in class PDAcroFormNode
Parameters:
field - The field to remove.
Returns:
true if field was removed.

reset

public void reset()
Reset this to its default value.


setAdditionalActions

public void setAdditionalActions(PDAdditionalActions actions)
Specified by:
setAdditionalActions in interface IAdditionalActionSupport

setAlignmentCenter

public void setAlignmentCenter()
Make variable text centered.


setAlignmentLeft

public void setAlignmentLeft()
Make variable text left aligned.


setAlignmentRight

public void setAlignmentRight()
Make variable text right aligned.


setAlternateFieldName

public void setAlternateFieldName(String newAlternateFieldName)
Asssign a alternate field name.

Parameters:
newAlternateFieldName - The new alternate field name

setComb

public void setComb(boolean f)
Convenience method to access "Comb" flag.


setDefaultValue

public void setDefaultValue(String value)
Assign a new default value. The default value is used if no value (/V) is available.

Parameters:
value - The new default value.

setDoNotScroll

public void setDoNotScroll(boolean f)
Convenience method to access "DoNotScroll" flag.


setLocalName

public void setLocalName(String newLocalName)
Assign a new local name.

Parameters:
newLocalName - The new local name

setMaxLength

public void setMaxLength(Integer newMaxLength)
Set the maximum length for this field.

Parameters:
newMaxLength - The new maximum length

setMultiline

public void setMultiline(boolean f)
Convenience method to access "Multiline" flag.


setNoExport

public void setNoExport(boolean f)
Convenience method to access "NoExport" flag.


setReadOnly

public void setReadOnly(boolean f)
Convenience method to access "ReadOnly" flag.


setValueString

public void setValueString(String value)
Set the value of this.

Parameters:
value - The new value of this, represented by a String.

setValueStrings

public void setValueStrings(List values)
Set the value of this to a List of String objects.

Parameters:
values - The new value.

toString

public String toString()
Overrides:
toString in class PDObject

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.