pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1798970 - in /pdfbox/trunk: debugger/src/main/java/org/apache/pdfbox/debugger/ debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/ debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ debugger/src/main/java/org/ap...
Date Fri, 16 Jun 2017 17:58:57 GMT
Author: tilman
Date: Fri Jun 16 17:58:57 2017
New Revision: 1798970

URL: http://svn.apache.org/viewvc?rev=1798970&view=rev
Log:
PDFBOX-2852: use jdk7 syntax

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexEditor.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/KToolTip.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/LogDialog.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionFactory.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Fri Jun
16 17:58:57 2017
@@ -220,22 +220,22 @@ public class PDFDebugger extends JFrame
         
         for( int i = 0; i < args.length; i++ )
         {
-            if( args[i].equals( PASSWORD ) )
+            switch (args[i])
             {
-                i++;
-                if( i >= args.length )
-                {
-                    usage();
-                }
-                password = args[i];
-            }
-            else if( args[i].equals(VIEW_STRUCTURE) )
-            {
-                viewPages = false;
-            }
-            else
-            {
-                filename = args[i];
+                case PASSWORD:
+                    i++;
+                    if (i >= args.length)
+                    {
+                        usage();
+                    }
+                    password = args[i];
+                    break;
+                case VIEW_STRUCTURE:
+                    viewPages = false;
+                    break;
+                default:
+                    filename = args[i];
+                    break;
             }
         }
         final PDFDebugger viewer = new PDFDebugger(viewPages);
@@ -277,9 +277,10 @@ public class PDFDebugger extends JFrame
         {
             try
             {
-                InputStream is = new FileInputStream(file);
-                configuration.load(is);
-                is.close();
+                try (InputStream is = new FileInputStream(file))
+                {
+                    configuration.load(is);
+                }
             }
             catch(IOException e)
             {

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexEditor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexEditor.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexEditor.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexEditor.java
Fri Jun 16 17:58:57 2017
@@ -157,22 +157,20 @@ class HexEditor extends JPanel implement
     {
         int index = event.getHexIndex();
 
-        if (event.getNavigation().equals(SelectEvent.NEXT))
+        switch (event.getNavigation())
         {
-            index += 1;
-        }
-        else if (event.getNavigation().equals(SelectEvent.PREVIOUS))
-        {
-            index -= 1;
-        }
-        else if (event.getNavigation().equals(SelectEvent.UP))
-        {
-            index -= 16;
-
-        }
-        else if (event.getNavigation().equals(SelectEvent.DOWN))
-        {
-            index += 16;
+            case SelectEvent.NEXT:
+                index += 1;
+                break;
+            case SelectEvent.PREVIOUS:
+                index -= 1;
+                break;
+            case SelectEvent.UP:
+                index -= 16;
+                break;
+            case SelectEvent.DOWN:
+                index += 16;
+                break;
         }
         if (index >= 0 && index <= model.size() - 1)
         {

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/KToolTip.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/KToolTip.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/KToolTip.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/KToolTip.java
Fri Jun 16 17:58:57 2017
@@ -85,10 +85,9 @@ final class KToolTip extends ColorToolTi
             throw new IOException("Error loading resource: " + name);
         }
 
-        InputStream input = url.openStream();
-        ICC_Profile iccProfile = ICC_Profile.getInstance(input);
-        input.close();
-
-        return iccProfile;
+        try (InputStream input = url.openStream())
+        {
+            return ICC_Profile.getInstance(input);
+        }
     }
 }

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
Fri Jun 16 17:58:57 2017
@@ -89,43 +89,45 @@ public class ToolTipController
         if (word != null)
         {
             ToolTip toolTip;
-            if (word.equals(FONT_OPERATOR))
+            switch (word)
             {
-                toolTip = new FontToolTip(resources, rowText);
-                return toolTip.getToolTipText();
-            }
-            else if (word.equals(STROKING_COLOR))
-            {
-                String colorSpaceName = findColorSpace(offset, STROKING_COLOR_SPACE);
-                if (colorSpaceName != null)
-                {
-                    toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
+                case FONT_OPERATOR:
+                    toolTip = new FontToolTip(resources, rowText);
                     return toolTip.getToolTipText();
+                case STROKING_COLOR:
+                {
+                    String colorSpaceName = findColorSpace(offset, STROKING_COLOR_SPACE);
+                    if (colorSpaceName != null)
+                    {
+                        toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
+                        return toolTip.getToolTipText();
+                    }
+                    break;
                 }
-            }
-            else if (word.equals(NON_STROKING_COLOR))
-            {
-                String colorSpaceName = findColorSpace(offset, NON_STROKING_COLOR_SPACE);
-                if (colorSpaceName != null)
+                case NON_STROKING_COLOR:
                 {
-                    toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
-                    return toolTip.getToolTipText();
+                    String colorSpaceName = findColorSpace(offset, NON_STROKING_COLOR_SPACE);
+                    if (colorSpaceName != null)
+                    {
+                        toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
+                        return toolTip.getToolTipText();
+                    }
+                    break;
                 }
-            }
-            else if (word.equals(RGB_STROKING_COLOR) || word.equals(RGB_NON_STROKING_COLOR))
-            {
-                toolTip = new RGToolTip(rowText);
-                return toolTip.getToolTipText();
-            }
-            else if (word.equals(CMYK_STROKING_COLOR) || word.equals(CMYK_NON_STROKING_COLOR))
-            {
-                toolTip = new KToolTip(rowText);
-                return toolTip.getToolTipText();
-            }
-            else if (word.equals(GRAY_STROKING_COLOR) || word.equals(GRAY_NON_STROKING_COLOR))
-            {
-                toolTip = new GToolTip(rowText);
-                return toolTip.getToolTipText();
+                case RGB_STROKING_COLOR:
+                case RGB_NON_STROKING_COLOR:
+                    toolTip = new RGToolTip(rowText);
+                    return toolTip.getToolTipText();
+                case CMYK_STROKING_COLOR:
+                case CMYK_NON_STROKING_COLOR:
+                    toolTip = new KToolTip(rowText);
+                    return toolTip.getToolTipText();
+                case GRAY_STROKING_COLOR:
+                case GRAY_NON_STROKING_COLOR:
+                    toolTip = new GToolTip(rowText);
+                    return toolTip.getToolTipText();
+                default:
+                    break;
             }
         }
         return null;

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/LogDialog.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/LogDialog.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/LogDialog.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/LogDialog.java Fri Jun
16 17:58:57 2017
@@ -51,7 +51,7 @@ public class LogDialog extends JDialog
 
     private final JLabel logLabel;
     private final JTextPane textPane;
-    private JScrollPane scrollPane;
+    private final JScrollPane scrollPane;
     private int fatalCount = 0;
     private int errorCount = 0;
     private int warnCount = 0;
@@ -76,51 +76,46 @@ public class LogDialog extends JDialog
         
         String levelText;
         SimpleAttributeSet levelStyle = new SimpleAttributeSet();
-        if (level.equals("fatal"))
+        switch (level)
         {
-            levelText = "Fatal";
-            StyleConstants.setForeground(levelStyle, Color.WHITE);
-            StyleConstants.setBackground(levelStyle, Color.BLACK);
-            fatalCount++;
-        } 
-        else if (level.equals("error"))
-        {
-            levelText = "Error";
-            StyleConstants.setForeground(levelStyle, new Color(0xFF291F));
-            StyleConstants.setBackground(levelStyle, new Color(0xFFF0F0));
-            errorCount++;
-        } 
-        else if (level.equals("warn"))
-        {
-            levelText = "Warning";
-            StyleConstants.setForeground(levelStyle, new Color(0x614201));
-            StyleConstants.setBackground(levelStyle, new Color(0xFFFCE5));
-            warnCount++;
-        } 
-        else if (level.equals("info"))
-        {
-            levelText = "Info";
-            StyleConstants.setForeground(levelStyle, new Color(0x203261));
-            StyleConstants.setBackground(levelStyle, new Color(0xE2E8FF));
-            otherCount++;
-        } 
-        else if (level.equals("debug"))
-        {
-            levelText = "Debug";
-            StyleConstants.setForeground(levelStyle, new Color(0x32612E));
-            StyleConstants.setBackground(levelStyle, new Color(0xF4FFEC));
-            otherCount++;
-        } 
-        else if (level.equals("trace"))
-        {
-            levelText = "Trace";
-            StyleConstants.setForeground(levelStyle, new Color(0x64438D));
-            StyleConstants.setBackground(levelStyle, new Color(0xFEF3FF));
-            otherCount++;
-        } 
-        else
-        {
-            throw new Error(level);
+            case "fatal":
+                levelText = "Fatal";
+                StyleConstants.setForeground(levelStyle, Color.WHITE);
+                StyleConstants.setBackground(levelStyle, Color.BLACK);
+                fatalCount++;
+                break;
+            case "error":
+                levelText = "Error";
+                StyleConstants.setForeground(levelStyle, new Color(0xFF291F));
+                StyleConstants.setBackground(levelStyle, new Color(0xFFF0F0));
+                errorCount++;
+                break;
+            case "warn":
+                levelText = "Warning";
+                StyleConstants.setForeground(levelStyle, new Color(0x614201));
+                StyleConstants.setBackground(levelStyle, new Color(0xFFFCE5));
+                warnCount++;
+                break;
+            case "info":
+                levelText = "Info";
+                StyleConstants.setForeground(levelStyle, new Color(0x203261));
+                StyleConstants.setBackground(levelStyle, new Color(0xE2E8FF));
+                otherCount++;
+                break;
+            case "debug":
+                levelText = "Debug";
+                StyleConstants.setForeground(levelStyle, new Color(0x32612E));
+                StyleConstants.setBackground(levelStyle, new Color(0xF4FFEC));
+                otherCount++;
+                break;
+            case "trace":
+                levelText = "Trace";
+                StyleConstants.setForeground(levelStyle, new Color(0x64438D));
+                StyleConstants.setBackground(levelStyle, new Color(0xFEF3FF));
+                otherCount++;
+                break;
+            default:
+                throw new Error(level);
         }
 
         SimpleAttributeSet nameStyle = new SimpleAttributeSet();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java Fri
Jun 16 17:58:57 2017
@@ -147,41 +147,37 @@ public abstract class FDFAnnotation impl
             String[] flagTokens = flags.split(",");
             for (String flagToken : flagTokens)
             {
-                if (flagToken.equals("invisible"))
+                switch (flagToken)
                 {
-                    setInvisible(true);
-                }
-                else if (flagToken.equals("hidden"))
-                {
-                    setHidden(true);
-                }
-                else if (flagToken.equals("print"))
-                {
-                    setPrinted(true);
-                }
-                else if (flagToken.equals("nozoom"))
-                {
-                    setNoZoom(true);
-                }
-                else if (flagToken.equals("norotate"))
-                {
-                    setNoRotate(true);
-                }
-                else if (flagToken.equals("noview"))
-                {
-                    setNoView(true);
-                }
-                else if (flagToken.equals("readonly"))
-                {
-                    setReadOnly(true);
-                }
-                else if (flagToken.equals("locked"))
-                {
-                    setLocked(true);
-                }
-                else if (flagToken.equals("togglenoview"))
-                {
-                    setToggleNoView(true);
+                    case "invisible":
+                        setInvisible(true);
+                        break;
+                    case "hidden":
+                        setHidden(true);
+                        break;
+                    case "print":
+                        setPrinted(true);
+                        break;
+                    case "nozoom":
+                        setNoZoom(true);
+                        break;
+                    case "norotate":
+                        setNoRotate(true);
+                        break;
+                    case "noview":
+                        setNoView(true);
+                        break;
+                    case "readonly":
+                        setReadOnly(true);
+                        break;
+                    case "locked":
+                        setLocked(true);
+                        break;
+                    case "togglenoview":
+                        setToggleNoView(true);
+                        break;
+                    default:
+                        break;
                 }
             }
         }
@@ -264,38 +260,35 @@ public abstract class FDFAnnotation impl
             String style = element.getAttribute("style");
             if (style != null && !style.isEmpty())
             {
-                if (style.equals("dash"))
-                {
-                    borderStyle.setStyle("D");
-                }
-                else if (style.equals("bevelled"))
-                {
-                    borderStyle.setStyle("B");
-                }
-                else if (style.equals("inset"))
-                {
-                    borderStyle.setStyle("I");
-                }
-                else if (style.equals("underline"))
-                {
-                    borderStyle.setStyle("U");
-                }
-                else if (style.equals("cloudy"))
-                {
-                    borderStyle.setStyle("S");
-                    PDBorderEffectDictionary borderEffect = new PDBorderEffectDictionary();
-                    borderEffect.setStyle("C");
-                    String intensity = element.getAttribute("intensity");
-                    if (intensity != null && !intensity.isEmpty())
-                    {
-                        borderEffect.setIntensity(Float.parseFloat(element
-                                .getAttribute("intensity")));
-                    }
-                    setBorderEffect(borderEffect);
-                }
-                else
+                switch (style)
                 {
-                    borderStyle.setStyle("S");
+                    case "dash":
+                        borderStyle.setStyle("D");
+                        break;
+                    case "bevelled":
+                        borderStyle.setStyle("B");
+                        break;
+                    case "inset":
+                        borderStyle.setStyle("I");
+                        break;
+                    case "underline":
+                        borderStyle.setStyle("U");
+                        break;
+                    case "cloudy":
+                        borderStyle.setStyle("S");
+                        PDBorderEffectDictionary borderEffect = new PDBorderEffectDictionary();
+                        borderEffect.setStyle("C");
+                        String intensity = element.getAttribute("intensity");
+                        if (intensity != null && !intensity.isEmpty())
+                        {
+                            borderEffect.setIntensity(Float.parseFloat(element
+                                    .getAttribute("intensity")));
+                        }
+                        setBorderEffect(borderEffect);
+                        break;
+                    default:
+                        borderStyle.setStyle("S");
+                        break;
                 }
             }
             String dashes = element.getAttribute("dashes");

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java Fri
Jun 16 17:58:57 2017
@@ -81,158 +81,142 @@ public class FDFDictionary implements CO
             if (node instanceof Element)
             {
                 Element child = (Element) node;
-                if (child.getTagName().equals("f"))
+                switch (child.getTagName())
                 {
-                    PDSimpleFileSpecification fs = new PDSimpleFileSpecification();
-                    fs.setFile(child.getAttribute("href"));
-                    setFile(fs);
-                }
-                else if (child.getTagName().equals("ids"))
-                {
-                    COSArray ids = new COSArray();
-                    String original = child.getAttribute("original");
-                    String modified = child.getAttribute("modified");
-                    try
-                    {
-                        ids.add(COSString.parseHex(original));
-                    }
-                    catch (IOException e)
-                    {
-                        LOG.warn("Error parsing ID entry for attribute 'original' [" + original
-                                + "]. ID entry ignored.", e);
-                    }
-                    try
-                    {
-                        ids.add(COSString.parseHex(modified));
-                    }
-                    catch (IOException e)
-                    {
-                        LOG.warn("Error parsing ID entry for attribute 'modified' [" + modified
-                                + "]. ID entry ignored.", e);
-                    }
-                    setID(ids);
-                }
-                else if (child.getTagName().equals("fields"))
-                {
-                    NodeList fields = child.getChildNodes();
-                    List<FDFField> fieldList = new ArrayList<>();
-                    for (int f = 0; f < fields.getLength(); f++)
-                    {
-                        Node currentNode = fields.item(f);
-                        if (currentNode instanceof Element
-                                && ((Element) currentNode).getTagName().equals("field"))
+                    case "f":
+                        PDSimpleFileSpecification fs = new PDSimpleFileSpecification();
+                        fs.setFile(child.getAttribute("href"));
+                        setFile(fs);
+                        break;
+                    case "ids":
+                        COSArray ids = new COSArray();
+                        String original = child.getAttribute("original");
+                        String modified = child.getAttribute("modified");
+                        try
                         {
-                            try
-                            {
-                                fieldList.add(new FDFField((Element) fields.item(f)));
-                            }
-                            catch (IOException e)
-                            {
-                                LOG.warn("Error parsing field entry [" + currentNode.getNodeValue()
-                                        + "]. Field ignored.", e);
-                            }
+                            ids.add(COSString.parseHex(original));
                         }
-                    }
-                    setFields(fieldList);
-                }
-                else if (child.getTagName().equals("annots"))
-                {
-                    NodeList annots = child.getChildNodes();
-                    List<FDFAnnotation> annotList = new ArrayList<>();
-                    for (int j = 0; j < annots.getLength(); j++)
-                    {
-                        Node annotNode = annots.item(j);
-                        if (annotNode instanceof Element)
-                        {
-
-                            // the node name defines the annotation type
-                            Element annot = (Element) annotNode;
-                            String annotationName = annot.getNodeName();
-                            try
+                        catch (IOException e)
+                        {
+                            LOG.warn("Error parsing ID entry for attribute 'original' ["
+ original +
+                                    "]. ID entry ignored.", e);
+                        }
+                        try
+                        {
+                            ids.add(COSString.parseHex(modified));
+                        }
+                        catch (IOException e)
+                        {
+                            LOG.warn("Error parsing ID entry for attribute 'modified' ["
+ modified +
+                                    "]. ID entry ignored.", e);
+                        }
+                        setID(ids);
+                        break;
+                    case "fields":
+                        NodeList fields = child.getChildNodes();
+                        List<FDFField> fieldList = new ArrayList<>();
+                        for (int f = 0; f < fields.getLength(); f++)
+                        {
+                            Node currentNode = fields.item(f);
+                            if (currentNode instanceof Element
+                                    && ((Element) currentNode).getTagName().equals("field"))
                             {
-                                if (annotationName.equals("text"))
-                                {
-                                    annotList.add(new FDFAnnotationText(annot));
-                                }
-                                else if (annotationName.equals("caret"))
-                                {
-                                    annotList.add(new FDFAnnotationCaret(annot));
-                                }
-                                else if (annotationName.equals("freetext"))
-                                {
-                                    annotList.add(new FDFAnnotationFreeText(annot));
-                                }
-                                else if (annotationName.equals("fileattachment"))
-                                {
-                                    annotList.add(new FDFAnnotationFileAttachment(annot));
-                                }
-                                else if (annotationName.equals("highlight"))
-                                {
-                                    annotList.add(new FDFAnnotationHighlight(annot));
-                                }
-                                else if (annotationName.equals("ink"))
-                                {
-                                    annotList.add(new FDFAnnotationInk(annot));
-                                }
-                                else if (annotationName.equals("line"))
-                                {
-                                    annotList.add(new FDFAnnotationLine(annot));
-                                }
-                                else if (annotationName.equals("link"))
-                                {
-                                    annotList.add(new FDFAnnotationLink(annot));
-                                }
-                                else if (annotationName.equals("circle"))
-                                {
-                                    annotList.add(new FDFAnnotationCircle(annot));
-                                }
-                                else if (annotationName.equals("square"))
-                                {
-                                    annotList.add(new FDFAnnotationSquare(annot));
-                                }
-                                else if (annotationName.equals("polygon"))
-                                {
-                                    annotList.add(new FDFAnnotationPolygon(annot));
-                                }
-                                else if (annotationName.equals("polyline"))
+                                try
                                 {
-                                    annotList.add(new FDFAnnotationPolyline(annot));
+                                    fieldList.add(new FDFField((Element) fields.item(f)));
                                 }
-                                else if (annotationName.equals("sound"))
+                                catch (IOException e)
                                 {
-                                    annotList.add(new FDFAnnotationSound(annot));
+                                    LOG.warn("Error parsing field entry [" + currentNode.getNodeValue()
+
+                                            "]. Field ignored.", e);
                                 }
-                                else if (annotationName.equals("squiggly"))
-                                {
-                                    annotList.add(new FDFAnnotationSquiggly(annot));
-                                }
-                                else if (annotationName.equals("stamp"))
-                                {
-                                    annotList.add(new FDFAnnotationStamp(annot));
-                                }
-                                else if (annotationName.equals("strikeout"))
-                                {
-                                    annotList.add(new FDFAnnotationStrikeOut(annot));
-                                }
-                                else if (annotationName.equals("underline"))
-                                {
-                                    annotList.add(new FDFAnnotationUnderline(annot));
+                            }
+                        }
+                        setFields(fieldList);
+                        break;
+                    case "annots":
+                        NodeList annots = child.getChildNodes();
+                        List<FDFAnnotation> annotList = new ArrayList<>();
+                        for (int j = 0; j < annots.getLength(); j++)
+                        {
+                            Node annotNode = annots.item(j);
+                            if (annotNode instanceof Element)
+                            {
+                                // the node name defines the annotation type
+                                Element annot = (Element) annotNode;
+                                String annotationName = annot.getNodeName();
+                                try
+                                {
+                                    switch (annotationName)
+                                    {
+                                        case "text":
+                                            annotList.add(new FDFAnnotationText(annot));
+                                            break;
+                                        case "caret":
+                                            annotList.add(new FDFAnnotationCaret(annot));
+                                            break;
+                                        case "freetext":
+                                            annotList.add(new FDFAnnotationFreeText(annot));
+                                            break;
+                                        case "fileattachment":
+                                            annotList.add(new FDFAnnotationFileAttachment(annot));
+                                            break;
+                                        case "highlight":
+                                            annotList.add(new FDFAnnotationHighlight(annot));
+                                            break;
+                                        case "ink":
+                                            annotList.add(new FDFAnnotationInk(annot));
+                                            break;
+                                        case "line":
+                                            annotList.add(new FDFAnnotationLine(annot));
+                                            break;
+                                        case "link":
+                                            annotList.add(new FDFAnnotationLink(annot));
+                                            break;
+                                        case "circle":
+                                            annotList.add(new FDFAnnotationCircle(annot));
+                                            break;
+                                        case "square":
+                                            annotList.add(new FDFAnnotationSquare(annot));
+                                            break;
+                                        case "polygon":
+                                            annotList.add(new FDFAnnotationPolygon(annot));
+                                            break;
+                                        case "polyline":
+                                            annotList.add(new FDFAnnotationPolyline(annot));
+                                            break;
+                                        case "sound":
+                                            annotList.add(new FDFAnnotationSound(annot));
+                                            break;
+                                        case "squiggly":
+                                            annotList.add(new FDFAnnotationSquiggly(annot));
+                                            break;
+                                        case "stamp":
+                                            annotList.add(new FDFAnnotationStamp(annot));
+                                            break;
+                                        case "strikeout":
+                                            annotList.add(new FDFAnnotationStrikeOut(annot));
+                                            break;
+                                        case "underline":
+                                            annotList.add(new FDFAnnotationUnderline(annot));
+                                            break;
+                                        default:
+                                            LOG.warn("Unknown or unsupported annotation type
'" +
+                                                    annotationName + "'");
+                                            break;
+                                    }
                                 }
-                                else
+                                catch (IOException e)
                                 {
-                                    LOG.warn("Unknown or unsupported annotation type '"
-                                            + annotationName + "'");
+                                    LOG.warn("Error parsing annotation information [" +
+                                            annot.getNodeValue() + "]. Annotation ignored",
e);
                                 }
                             }
-                            catch (IOException e)
-                            {
-                                LOG.warn(
-                                        "Error parsing annotation information ["
-                                                + annot.getNodeValue() + "]. Annotation ignored",
e);
-                            }
                         }
-                    }
-                    setAnnotations(annotList);
+                        setAnnotations(annotList);
+                        break;
+                    default:
+                        break;
                 }
             }
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java Fri Jun
16 17:58:57 2017
@@ -83,17 +83,19 @@ public class FDFField implements COSObje
             if (node instanceof Element)
             {
                 Element child = (Element) node;
-                if (child.getTagName().equals("value"))
+                switch (child.getTagName())
                 {
-                    setValue(XMLUtil.getNodeValue(child));
-                }
-                else if (child.getTagName().equals("value-richtext"))
-                {
-                    setRichText(new COSString(XMLUtil.getNodeValue(child)));
-                }
-                else if (child.getTagName().equals("field"))
-                {
-                    kids.add(new FDFField(child));
+                    case "value":
+                        setValue(XMLUtil.getNodeValue(child));
+                        break;
+                    case "value-richtext":
+                        setRichText(new COSString(XMLUtil.getNodeValue(child)));
+                        break;
+                    case "field":
+                        kids.add(new FDFField(child));
+                        break;
+                    default:
+                        break;
                 }
             }
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionFactory.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionFactory.java
Fri Jun 16 17:58:57 2017
@@ -46,60 +46,55 @@ public final class PDActionFactory
     public static PDAction createAction( COSDictionary action )
     {
         PDAction retval = null;
-        if( action != null )
+        if( action != null)
         {
-            String type = action.getNameAsString( COSName.S );
-            if( PDActionJavaScript.SUB_TYPE.equals( type ) )
+            String type = action.getNameAsString(COSName.S);
+            if (type != null)
             {
-                retval = new PDActionJavaScript( action );
-            }
-            else if( PDActionGoTo.SUB_TYPE.equals( type ) )
-            {
-                retval = new PDActionGoTo( action );
-            }
-            else if( PDActionLaunch.SUB_TYPE.equals( type ) )
-            {
-                retval = new PDActionLaunch( action );
-            }
-            else if( PDActionRemoteGoTo.SUB_TYPE.equals( type ) )
-            {
-                retval = new PDActionRemoteGoTo( action );
-            }
-            else if( PDActionURI.SUB_TYPE.equals( type ) )
-            {
-                retval = new PDActionURI( action );
-            }
-            else if (PDActionNamed.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionNamed(action);
-            }
-            else if (PDActionSound.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionSound(action);
-            }
-            else if (PDActionMovie.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionMovie(action);
-            }
-            else if (PDActionImportData.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionImportData(action);
-            }
-            else if (PDActionResetForm.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionResetForm(action);
-            }
-            else if (PDActionHide.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionHide(action);
-            }
-            else if (PDActionSubmitForm.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionSubmitForm(action);
-            }
-            else if (PDActionThread.SUB_TYPE.equals(type))
-            {
-                retval = new PDActionThread(action);
+                switch (type)
+                {
+                    case PDActionJavaScript.SUB_TYPE:
+                        retval = new PDActionJavaScript(action);
+                        break;
+                    case PDActionGoTo.SUB_TYPE:
+                        retval = new PDActionGoTo(action);
+                        break;
+                    case PDActionLaunch.SUB_TYPE:
+                        retval = new PDActionLaunch(action);
+                        break;
+                    case PDActionRemoteGoTo.SUB_TYPE:
+                        retval = new PDActionRemoteGoTo(action);
+                        break;
+                    case PDActionURI.SUB_TYPE:
+                        retval = new PDActionURI(action);
+                        break;
+                    case PDActionNamed.SUB_TYPE:
+                        retval = new PDActionNamed(action);
+                        break;
+                    case PDActionSound.SUB_TYPE:
+                        retval = new PDActionSound(action);
+                        break;
+                    case PDActionMovie.SUB_TYPE:
+                        retval = new PDActionMovie(action);
+                        break;
+                    case PDActionImportData.SUB_TYPE:
+                        retval = new PDActionImportData(action);
+                        break;
+                    case PDActionResetForm.SUB_TYPE:
+                        retval = new PDActionResetForm(action);
+                        break;
+                    case PDActionHide.SUB_TYPE:
+                        retval = new PDActionHide(action);
+                        break;
+                    case PDActionSubmitForm.SUB_TYPE:
+                        retval = new PDActionSubmitForm(action);
+                        break;
+                    case PDActionThread.SUB_TYPE:
+                        retval = new PDActionThread(action);
+                        break;
+                    default:
+                        break;
+                }
             }
         }
         return retval;

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java?rev=1798970&r1=1798969&r2=1798970&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java Fri Jun 16 17:58:57
2017
@@ -47,63 +47,52 @@ public final class PDFBox
             String[] arguments = new String[args.length - 1];
             System.arraycopy(args, 1, arguments, 0, arguments.length);
             boolean exitAfterCallingMain = true;
-            if (command.equals("Decrypt"))
+            switch (command)
             {
-                Decrypt.main(arguments);
-            }
-            else if (command.equals("Encrypt"))
-            {
-                Encrypt.main(arguments);
-            }
-            else if (command.equals("ExtractText"))
-            {
-                ExtractText.main(arguments);
-            }
-            else if (command.equals("ExtractImages"))
-            {
-                ExtractImages.main(arguments);
-            }
-            else if (command.equals("OverlayPDF"))
-            {
-                OverlayPDF.main(arguments);
-            }
-            else if (command.equals("PrintPDF"))
-            {
-                PrintPDF.main(arguments);
-            }
-            else if (command.equals("PDFDebugger"))
-            {
-                PDFDebugger.main(arguments);
-                exitAfterCallingMain = false;
-            }
-            else if (command.equals("PDFMerger"))
-            {
-                PDFMerger.main(arguments);
-            }
-            else if (command.equals("PDFReader"))
-            {
-                PDFDebugger.main(arguments);
-                exitAfterCallingMain = false;
-            }
-            else if (command.equals("PDFSplit"))
-            {
-                PDFSplit.main(arguments);
-            }
-            else if (command.equals("PDFToImage"))
-            {
-                PDFToImage.main(arguments);
-            }
-            else if (command.equals("TextToPDF"))
-            {
-                TextToPDF.main(arguments);
-            }
-            else if (command.equals("WriteDecodedDoc"))
-            {
-                WriteDecodedDoc.main(arguments);
-            }
-            else
-            {
-                showMessageAndExit();
+                case "Decrypt":
+                    Decrypt.main(arguments);
+                    break;
+                case "Encrypt":
+                    Encrypt.main(arguments);
+                    break;
+                case "ExtractText":
+                    ExtractText.main(arguments);
+                    break;
+                case "ExtractImages":
+                    ExtractImages.main(arguments);
+                    break;
+                case "OverlayPDF":
+                    OverlayPDF.main(arguments);
+                    break;
+                case "PrintPDF":
+                    PrintPDF.main(arguments);
+                    break;
+                case "PDFDebugger":
+                    PDFDebugger.main(arguments);
+                    exitAfterCallingMain = false;
+                    break;
+                case "PDFMerger":
+                    PDFMerger.main(arguments);
+                    break;
+                case "PDFReader":
+                    PDFDebugger.main(arguments);
+                    exitAfterCallingMain = false;
+                    break;
+                case "PDFSplit":
+                    PDFSplit.main(arguments);
+                    break;
+                case "PDFToImage":
+                    PDFToImage.main(arguments);
+                    break;
+                case "TextToPDF":
+                    TextToPDF.main(arguments);
+                    break;
+                case "WriteDecodedDoc":
+                    WriteDecodedDoc.main(arguments);
+                    break;
+                default:
+                    showMessageAndExit();
+                    break;
             }
             if (exitAfterCallingMain)
             {



Mime
View raw message