Skip to content

Commit 3d4f3ed

Browse files
ar3emArtem Bobko
authored andcommitted
Refactor according to findbugs
Autoported commit. Original commit hash: [6f034ab85] Manual files: kernel/findbugs-filter.xml
1 parent 661865b commit 3d4f3ed

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

itext/itext.kernel/itext/kernel/pdf/PdfCatalog.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ source product.
4444
using System;
4545
using System.Collections.Generic;
4646
using Common.Logging;
47+
using iText.IO.Util;
4748
using iText.Kernel;
4849
using iText.Kernel.Pdf.Action;
4950
using iText.Kernel.Pdf.Collection;
@@ -69,6 +70,14 @@ public class PdfCatalog : PdfObjectWrapper<PdfDictionary> {
6970

7071
private bool outlineMode;
7172

73+
private static readonly ICollection<PdfName> PAGE_MODES = new HashSet<PdfName>(JavaUtil.ArraysAsList(PdfName
74+
.UseNone, PdfName.UseOutlines, PdfName.UseThumbs, PdfName.FullScreen, PdfName.UseOC, PdfName.UseAttachments
75+
));
76+
77+
private static readonly ICollection<PdfName> PAGE_LAYOUTS = new HashSet<PdfName>(JavaUtil.ArraysAsList(PdfName
78+
.SinglePage, PdfName.OneColumn, PdfName.TwoColumnLeft, PdfName.TwoColumnRight, PdfName.TwoPageLeft, PdfName
79+
.TwoPageRight));
80+
7281
protected internal PdfCatalog(PdfDictionary pdfObject)
7382
: base(pdfObject) {
7483
//This HashMap contents all pages of the document and outlines associated to them
@@ -173,9 +182,7 @@ public virtual iText.Kernel.Pdf.PdfCatalog SetAdditionalAction(PdfName key, PdfA
173182
/// <param name="pageMode">page mode.</param>
174183
/// <returns>current instance of PdfCatalog</returns>
175184
public virtual iText.Kernel.Pdf.PdfCatalog SetPageMode(PdfName pageMode) {
176-
if (pageMode.Equals(PdfName.UseNone) || pageMode.Equals(PdfName.UseOutlines) || pageMode.Equals(PdfName.UseThumbs
177-
) || pageMode.Equals(PdfName.FullScreen) || pageMode.Equals(PdfName.UseOC) || pageMode.Equals(PdfName.
178-
UseAttachments)) {
185+
if (PAGE_MODES.Contains(pageMode)) {
179186
return Put(PdfName.PageMode, pageMode);
180187
}
181188
return this;
@@ -188,9 +195,7 @@ public virtual PdfName GetPageMode() {
188195
/// <summary>This method sets a page layout of the document</summary>
189196
/// <param name="pageLayout"/>
190197
public virtual iText.Kernel.Pdf.PdfCatalog SetPageLayout(PdfName pageLayout) {
191-
if (pageLayout.Equals(PdfName.SinglePage) || pageLayout.Equals(PdfName.OneColumn) || pageLayout.Equals(PdfName
192-
.TwoColumnLeft) || pageLayout.Equals(PdfName.TwoColumnRight) || pageLayout.Equals(PdfName.TwoPageLeft)
193-
|| pageLayout.Equals(PdfName.TwoPageRight)) {
198+
if (PAGE_LAYOUTS.Contains(pageLayout)) {
194199
return Put(PdfName.PageLayout, pageLayout);
195200
}
196201
return this;

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
aa0c58894a091657d1ae8f13810606cea44884b6
1+
6f034ab850913cfde4dc59309b71ba81973597e2

0 commit comments

Comments
 (0)