Author: tilman
Date: Mon Dec 16 19:33:29 2019
New Revision: 1871676
URL: http://svn.apache.org/viewvc?rev=1871676&view=rev
Log:
PDFBOX-4071: Sonar fix: merge if statement / collapsible "if" statements
Modified:
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Modified:
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
(original)
+++
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
Mon Dec 16 19:33:29 2019
@@ -63,12 +63,9 @@ public class PrintFields
if (field instanceof PDNonTerminalField)
{
- if (!sParent.equals(field.getPartialName()))
+ if (!sParent.equals(field.getPartialName()) && partialName != null)
{
- if (partialName != null)
- {
- sParent = sParent + "." + partialName;
- }
+ sParent = sParent + "." + partialName;
}
System.out.println(sLevel + sParent);
Modified:
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
(original)
+++
pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
Mon Dec 16 19:33:29 2019
@@ -98,15 +98,12 @@ public class CustomPageDrawer
@Override
protected Paint getPaint(PDColor color) throws IOException
{
- // if this is the non-stroking color
- if (getGraphicsState().getNonStrokingColor() == color)
+ // if this is the non-stroking color, find red, ignoring alpha
channel
+ if (getGraphicsState().getNonStrokingColor() == color &&
+ color.toRGB() == (Color.RED.getRGB() & 0x00FFFFFF))
{
- // find red, ignoring alpha channel
- if (color.toRGB() == (Color.RED.getRGB() & 0x00FFFFFF))
- {
- // replace it with blue
- return Color.BLUE;
- }
+ // replace it with blue
+ return Color.BLUE;
}
return super.getPaint(color);
}
Modified:
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
(original)
+++
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
Mon Dec 16 19:33:29 2019
@@ -152,16 +152,13 @@ public class TrueTypeFont implements Fon
// after the initial parsing of the ttf there aren't any write
operations
// to the HashMap anymore, so that we don't have to synchronize the
read access
TTFTable ttfTable = tables.get(tag);
- if (ttfTable != null)
+ if (ttfTable != null && !ttfTable.initialized)
{
- if (!ttfTable.initialized)
+ synchronized (lockReadtable)
{
- synchronized (lockReadtable)
+ if (!ttfTable.initialized)
{
- if (!ttfTable.initialized)
- {
- readTable(ttfTable);
- }
+ readTable(ttfTable);
}
}
}
Modified:
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
(original)
+++
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
Mon Dec 16 19:33:29 2019
@@ -105,14 +105,12 @@ public class COSFloat extends COSNumber
}
}
// check for very small values
- else if (Float.compare(floatValue, 0) == 0 &&
Double.compare(doubleValue, 0) != 0)
+ else if (Float.compare(floatValue, 0) == 0 &&
Double.compare(doubleValue, 0) != 0 &&
+ Math.abs(doubleValue) < Float.MIN_NORMAL)
{
- if (Math.abs(doubleValue) < Float.MIN_NORMAL )
- {
- floatValue = Float.MIN_NORMAL;
- floatValue *= doubleValue >= 0 ? 1 : -1;
- valueReplaced = true;
- }
+ floatValue = Float.MIN_NORMAL;
+ floatValue *= doubleValue >= 0 ? 1 : -1;
+ valueReplaced = true;
}
if (valueReplaced)
{
Modified:
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
(original)
+++
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
Mon Dec 16 19:33:29 2019
@@ -511,15 +511,9 @@ public class ScratchFile implements Clos
}
}
- if (file != null)
+ if (file != null && !file.delete() && file.exists() && ioexc ==
null)
{
- if (!file.delete())
- {
- if (file.exists() && (ioexc == null))
- {
- ioexc = new IOException("Error deleting scratch file:
" + file.getAbsolutePath());
- }
- }
+ ioexc = new IOException("Error deleting scratch file: " +
file.getAbsolutePath());
}
}
Modified:
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
(original)
+++
pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
Mon Dec 16 19:33:29 2019
@@ -283,21 +283,15 @@ public class FDFAnnotationStamp extends
NodeList nodeList = arrayEl.getChildNodes();
String parentAttrKey = arrayEl.getAttribute("KEY");
- if ("BBox".equals(parentAttrKey))
+ if ("BBox".equals(parentAttrKey) && nodeList.getLength() < 4)
{
- if (nodeList.getLength() < 4)
- {
- throw new IOException("BBox does not have enough coordinates,
only has: " +
- nodeList.getLength());
- }
+ throw new IOException("BBox does not have enough coordinates, only
has: " +
+ nodeList.getLength());
}
- else if ("Matrix".equals(parentAttrKey))
+ else if ("Matrix".equals(parentAttrKey) && nodeList.getLength() < 6)
{
- if (nodeList.getLength() < 6)
- {
- throw new IOException("Matrix does not have enough
coordinates, only has: " +
- nodeList.getLength());
- }
+ throw new IOException("Matrix does not have enough coordinates,
only has: " +
+ nodeList.getLength());
}
for (int i = 0; i < nodeList.getLength(); i++)
Modified:
pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1871676&r1=1871675&r2=1871676&view=diff
==============================================================================
---
pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
(original)
+++
pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Mon Dec 16 19:33:29 2019
@@ -816,16 +816,13 @@ public class PreflightParser extends PDF
endObjectKey = readString();
// we have case with a second 'endstream' before endobj
- if (!endObjectKey.startsWith("endobj"))
+ if (!endObjectKey.startsWith("endobj") &&
endObjectKey.startsWith("endstream"))
{
- if (endObjectKey.startsWith("endstream"))
+ endObjectKey = endObjectKey.substring(9).trim();
+ if (endObjectKey.length() == 0)
{
- endObjectKey = endObjectKey.substring(9).trim();
- if (endObjectKey.length() == 0)
- {
- // no other characters in extra endstream line
- endObjectKey = readString(); // read next line
- }
+ // no other characters in extra endstream line
+ endObjectKey = readString(); // read next line
}
}
}