You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/12/23 22:16:02 UTC
svn commit: r1647676 -
/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
Author: tilman
Date: Tue Dec 23 21:16:02 2014
New Revision: 1647676
URL: http://svn.apache.org/r1647676
Log:
PDFBOX-2576: nested if statements can be combined
Modified:
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java?rev=1647676&r1=1647675&r2=1647676&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java Tue Dec 23 21:16:02 2014
@@ -75,60 +75,56 @@ public class FontMetaDataValidation
}
DublinCoreSchema dc = metadata.getDublinCoreSchema();
- if (dc != null)
+ if (dc != null && dc.getTitleProperty() != null)
{
- if (dc.getTitleProperty() != null)
+ String defaultTitle = dc.getTitle("x-default");
+ if (defaultTitle != null)
{
- String defaultTitle = dc.getTitle("x-default");
- if (defaultTitle != null)
+ if (!defaultTitle.equals(fontName) && (noSubSetName != null && !defaultTitle.equals(noSubSetName)))
{
-
- if (!defaultTitle.equals(fontName) && (noSubSetName != null && !defaultTitle.equals(noSubSetName)))
- {
- StringBuilder sb = new StringBuilder(80);
- sb.append("FontName")
- .append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
- ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
- return false;
- }
-
- // --- default value is the right one
- return true;
+ StringBuilder sb = new StringBuilder(80);
+ sb.append("FontName")
+ .append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
+ ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
+ return false;
}
- else
+
+ // --- default value is the right one
+ return true;
+ }
+ else
+ {
+ Iterator<AbstractField> it = dc.getTitleProperty().getContainer().getAllProperties().iterator();
+ boolean empty = true;
+ while (it.hasNext())
{
- Iterator<AbstractField> it = dc.getTitleProperty().getContainer().getAllProperties().iterator();
- boolean empty = true;
- while (it.hasNext())
+ empty = false;
+ AbstractField tmp = it.next();
+ if (tmp != null && tmp instanceof TextType)
{
- empty = false;
- AbstractField tmp = it.next();
- if (tmp != null && tmp instanceof TextType)
+ if (((TextType) tmp).getStringValue().equals(fontName)
+ || (noSubSetName != null && ((TextType) tmp).getStringValue().equals(noSubSetName)))
{
- if (((TextType) tmp).getStringValue().equals(fontName)
- || (noSubSetName != null && ((TextType) tmp).getStringValue().equals(noSubSetName)))
- {
- // value found, return
- return true;
- }
+ // value found, return
+ return true;
}
}
+ }
- // title doesn't match, it is an error.
- StringBuilder sb = new StringBuilder(80);
- sb.append("FontName");
- if (empty)
- {
- sb.append(" present in the FontDescriptor dictionary can't be found in XMP information the Font File Stream.");
- ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING, sb.toString()));
- }
- else
- {
- sb.append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
- ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
- }
- return false;
+ // title doesn't match, it is an error.
+ StringBuilder sb = new StringBuilder(80);
+ sb.append("FontName");
+ if (empty)
+ {
+ sb.append(" present in the FontDescriptor dictionary can't be found in XMP information the Font File Stream.");
+ ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING, sb.toString()));
+ }
+ else
+ {
+ sb.append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
+ ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
}
+ return false;
}
}
return true;