Skip to content

Commit 2ab8bbf

Browse files
committed
PDFBOX-4892: simplify code, as suggested by valerybokov
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1891663 13f79535-47bb-0310-9956-ffa450edef68
1 parent 68752b2 commit 2ab8bbf

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

preflight/src/main/java/org/apache/pdfbox/preflight/process/StreamValidationProcess.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,25 @@ public void validateStreamObject(PreflightContext context, COSBase cObj)
8888
protected void checkFilters(COSStream stream, PreflightContext context)
8989
{
9090
COSBase bFilter = stream.getDictionaryObject(COSName.FILTER);
91-
if (bFilter != null)
91+
if (bFilter instanceof COSArray)
9292
{
93-
if (bFilter instanceof COSArray)
93+
COSArray afName = (COSArray) bFilter;
94+
for (int i = 0; i < afName.size(); ++i)
9495
{
95-
COSArray afName = (COSArray) bFilter;
96-
for (int i = 0; i < afName.size(); ++i)
97-
{
98-
FilterHelper.isAuthorizedFilter(context, afName.getString(i));
99-
}
100-
}
101-
else if (bFilter instanceof COSName)
102-
{
103-
String fName = ((COSName) bFilter).getName();
104-
FilterHelper.isAuthorizedFilter(context, fName);
105-
}
106-
else
107-
{
108-
// ---- The filter type is invalid
109-
addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_INVALID_FILTER,
110-
"Filter should be a Name or an Array"));
96+
FilterHelper.isAuthorizedFilter(context, afName.getString(i));
11197
}
11298
}
99+
else if (bFilter instanceof COSName)
100+
{
101+
String fName = ((COSName) bFilter).getName();
102+
FilterHelper.isAuthorizedFilter(context, fName);
103+
}
104+
else if (bFilter != null)
105+
{
106+
// ---- The filter type is invalid
107+
addValidationError(context, new ValidationError(ERROR_SYNTAX_STREAM_INVALID_FILTER,
108+
"Filter should be a Name or an Array"));
109+
}
113110
// else Filter entry is optional
114111
}
115112

0 commit comments

Comments
 (0)