You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2015/03/06 15:55:50 UTC
svn commit: r1664643 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java
Author: msahyoun
Date: Fri Mar 6 14:55:50 2015
New Revision: 1664643
URL: http://svn.apache.org/r1664643
Log:
PDFBOX-2576 split long methods
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java?rev=1664643&r1=1664642&r2=1664643&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java Fri Mar 6 14:55:50 2015
@@ -581,7 +581,7 @@ public abstract class PDFieldTreeNode im
COSDictionary kidDictionary = (COSDictionary) kids.getObject(i);
if (name[nameIndex].equals(kidDictionary.getString(COSName.T)))
{
- retval = (PDFieldTreeNode) PDFieldTreeNode.createField(acroForm, kidDictionary, this);
+ retval = PDFieldTreeNode.createField(acroForm, kidDictionary, this);
if (name.length > nameIndex + 1)
{
retval = retval.findKid(name, nameIndex + 1);
@@ -785,8 +785,6 @@ public abstract class PDFieldTreeNode im
{
this.getDictionary().setString(COSName.TM, mappingName);
}
-
-
/**
* Creates a COSField subclass from the given field.
@@ -800,15 +798,7 @@ public abstract class PDFieldTreeNode im
String fieldType = findFieldType(field);
if (FIELD_TYPE_CHOICE.equals(fieldType))
{
- int flags = field.getInt(COSName.FF, 0);
- if ((flags & PDChoice.FLAG_COMBO) != 0)
- {
- return new PDComboBox(form, field, parentNode);
- }
- else
- {
- return new PDListBox(form, field, parentNode);
- }
+ return createChoiceSubType(form, field, parentNode);
}
else if (FIELD_TYPE_TEXT.equals(fieldType))
{
@@ -820,22 +810,7 @@ public abstract class PDFieldTreeNode im
}
else if (FIELD_TYPE_BUTTON.equals(fieldType))
{
- int flags = field.getInt(COSName.FF, 0);
- // BJL: I have found that the radio flag bit is not always set
- // and that sometimes there is just a kids dictionary.
- // so, if there is a kids dictionary then it must be a radio button group.
- if ((flags & PDButton.FLAG_RADIO) != 0)
- {
- return new PDRadioButton(form, field, parentNode);
- }
- else if ((flags & PDButton.FLAG_PUSHBUTTON) != 0)
- {
- return new PDPushButton(form, field, parentNode);
- }
- else
- {
- return new PDCheckbox(form, field, parentNode);
- }
+ return createButtonSubType(form, field, parentNode);
}
else
{
@@ -843,6 +818,39 @@ public abstract class PDFieldTreeNode im
}
}
+ private static PDFieldTreeNode createChoiceSubType(PDAcroForm form, COSDictionary field, PDFieldTreeNode parentNode)
+ {
+ int flags = field.getInt(COSName.FF, 0);
+ if ((flags & PDChoice.FLAG_COMBO) != 0)
+ {
+ return new PDComboBox(form, field, parentNode);
+ }
+ else
+ {
+ return new PDListBox(form, field, parentNode);
+ }
+ }
+
+ private static PDFieldTreeNode createButtonSubType(PDAcroForm form, COSDictionary field, PDFieldTreeNode parentNode)
+ {
+ int flags = field.getInt(COSName.FF, 0);
+ // BJL: I have found that the radio flag bit is not always set
+ // and that sometimes there is just a kids dictionary.
+ // so, if there is a kids dictionary then it must be a radio button group.
+ if ((flags & PDButton.FLAG_RADIO) != 0)
+ {
+ return new PDRadioButton(form, field, parentNode);
+ }
+ else if ((flags & PDButton.FLAG_PUSHBUTTON) != 0)
+ {
+ return new PDPushButton(form, field, parentNode);
+ }
+ else
+ {
+ return new PDCheckbox(form, field, parentNode);
+ }
+ }
+
private static String findFieldType(COSDictionary dic)
{
String retval = dic.getNameAsString(COSName.FT);