diff --git a/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java b/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java index 2c36ec33b03..d574a17b206 100644 --- a/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java +++ b/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java @@ -272,11 +272,11 @@ public boolean equals(Object object) if (object instanceof CharStringCommand) { CharStringCommand that = (CharStringCommand) object; - if (type1KeyWord != null && type1KeyWord.equals(that.getType1KeyWord())) + if (type1KeyWord != null && type1KeyWord == that.getType1KeyWord()) { return true; } - if (type2KeyWord != null && type2KeyWord.equals(that.getType2KeyWord())) + if (type2KeyWord != null && type2KeyWord == that.getType2KeyWord()) { return true; } diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java index 45ea0574539..a57c5d3e3f8 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java @@ -289,14 +289,14 @@ public static PDImageXObject createFromFileByContent(File file, PDDocument doc) throw new IllegalArgumentException("Image type not supported: " + file.getName()); } - if (fileType.equals(FileType.JPEG)) + if (fileType == FileType.JPEG) { try (FileInputStream fis = new FileInputStream(file)) { return JPEGFactory.createFromStream(doc, fis); } } - if (fileType.equals(FileType.TIFF)) + if (fileType == FileType.TIFF) { try { @@ -311,7 +311,7 @@ public static PDImageXObject createFromFileByContent(File file, PDDocument doc) fileType = FileType.PNG; } } - if (fileType.equals(FileType.BMP) || fileType.equals(FileType.GIF) || fileType.equals(FileType.PNG)) + if (fileType == FileType.BMP || fileType == FileType.GIF || fileType == FileType.PNG) { BufferedImage bim = ImageIO.read(file); return LosslessFactory.createFromImage(doc, bim); @@ -349,11 +349,11 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt throw new IllegalArgumentException("Image type not supported: " + name); } - if (fileType.equals(FileType.JPEG)) + if (fileType == FileType.JPEG) { return JPEGFactory.createFromByteArray(document, byteArray); } - if (fileType.equals(FileType.PNG)) + if (fileType == FileType.PNG) { // Try to directly convert the image without recoding it. PDImageXObject image = PNGConverter.convertPNGImage(document, byteArray); @@ -362,7 +362,7 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt return image; } } - if (fileType.equals(FileType.TIFF)) + if (fileType == FileType.TIFF) { try { @@ -377,7 +377,7 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt fileType = FileType.PNG; } } - if (fileType.equals(FileType.BMP) || fileType.equals(FileType.GIF) || fileType.equals(FileType.PNG)) + if (fileType == FileType.BMP || fileType == FileType.GIF || fileType == FileType.PNG) { ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); BufferedImage bim = ImageIO.read(bais); diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java index 6d74d78fa23..92f072f2581 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java @@ -123,12 +123,12 @@ public RenderState getRenderState(RenderDestination destination) COSDictionary usage = dict.getCOSDictionary(COSName.USAGE); if (usage != null) { - if (RenderDestination.PRINT.equals(destination)) + if (RenderDestination.PRINT == destination) { COSDictionary print = usage.getCOSDictionary(COSName.PRINT); state = print == null ? null : print.getCOSName(COSName.PRINT_STATE); } - else if (RenderDestination.VIEW.equals(destination)) + else if (RenderDestination.VIEW == destination) { COSDictionary view = usage.getCOSDictionary(COSName.VIEW); state = view == null ? null : view.getCOSName(COSName.VIEW_STATE); diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentProperties.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentProperties.java index 1ae8864955e..bb62f56badd 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentProperties.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentProperties.java @@ -288,7 +288,7 @@ public boolean isGroupEnabled(PDOptionalContentGroup group) //i.e. OCProperties/Configs PDOptionalContentProperties.BaseState baseState = getBaseState(); - boolean enabled = !baseState.equals(BaseState.OFF); + boolean enabled = baseState != BaseState.OFF; //TODO What to do with BaseState.Unchanged? if (group == null) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java b/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java index 0af6df957d5..8d89e18e802 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java @@ -574,7 +574,7 @@ protected void showType3Glyph(Matrix textRenderingMatrix, PDType3Font font, int { PDGraphicsState state = getGraphicsState(); RenderingMode renderingMode = state.getTextState().getRenderingMode(); - if (!RenderingMode.NEITHER.equals(renderingMode)) + if (RenderingMode.NEITHER != renderingMode) { super.showType3Glyph(textRenderingMatrix, font, code, displacement); } @@ -1828,7 +1828,7 @@ private TransparencyGroup(PDTransparencyGroup form, boolean isSoftMask, Matrix c private BufferedImage create2ByteGrayAlphaImage(int width, int height) { // gray + alpha - int[] bandOffsets = new int[] {1, 0}; + int[] bandOffsets = {1, 0}; int bands = bandOffsets.length; // Color Model used for raw GRAY + ALPHA @@ -2001,7 +2001,7 @@ private boolean isHiddenOCG(PDPropertyList propertyList) return true; } } - else if (RenderState.OFF.equals(printState)) + else if (RenderState.OFF == printState) { return true; }