-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WTPDF flavours. Refactoring flavours
- Loading branch information
1 parent
f29ba91
commit c5c021d
Showing
6 changed files
with
160 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/src/main/java/org/verapdf/pdfa/flavours/PDFFlavours.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.verapdf.pdfa.flavours; | ||
|
||
public class PDFFlavours { | ||
|
||
public static boolean isPDFUARelatedFlavour(PDFAFlavour flavour) { | ||
return isFlavourFamily(flavour, PDFAFlavour.SpecificationFamily.PDF_UA) || isWTPDFFlavour(flavour) || isWCAGFlavour(flavour); | ||
} | ||
|
||
public static boolean isPDFUA1RelatedFlavour(PDFAFlavour flavour) { | ||
return isFlavour(flavour, PDFAFlavour.PDFUA_1) || isWCAGFlavour(flavour); | ||
} | ||
|
||
public static boolean isPDFUA2RelatedFlavour(PDFAFlavour flavour) { | ||
return isFlavour(flavour, PDFAFlavour.PDFUA_2) || isFlavourPart(flavour, PDFAFlavour.Specification.WTPDF_1_0); | ||
} | ||
|
||
public static boolean isWCAGFlavour(PDFAFlavour flavour) { | ||
return isFlavourFamily(flavour, PDFAFlavour.SpecificationFamily.WCAG); | ||
} | ||
|
||
public static boolean isWTPDFFlavour(PDFAFlavour flavour) { | ||
return isFlavourFamily(flavour, PDFAFlavour.SpecificationFamily.WTPDF); | ||
} | ||
|
||
public static boolean isFlavour(PDFAFlavour currentFlavour, PDFAFlavour checkedFlavour) { | ||
return currentFlavour == checkedFlavour; | ||
} | ||
|
||
public static boolean isFlavourFamily(PDFAFlavour flavour, PDFAFlavour.SpecificationFamily family) { | ||
return flavour != null && flavour.getPart().getFamily() == family; | ||
} | ||
|
||
public static boolean isFlavourPart(PDFAFlavour flavour, PDFAFlavour.Specification part) { | ||
return flavour != null && flavour.getPart() == part; | ||
} | ||
|
||
public static boolean isPDFSpecification(PDFAFlavour flavour, PDFAFlavour.PDFSpecification pdfSpecification) { | ||
return flavour != null && flavour.getPart().getPdfSpecification() == pdfSpecification; | ||
} | ||
|
||
public static boolean isFlavourISOSeries(PDFAFlavour flavour, PDFAFlavour.IsoStandardSeries isoStandardSeries) { | ||
return flavour != null && flavour.getPart().getSeries() == isoStandardSeries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
import org.verapdf.core.Directory; | ||
import org.verapdf.core.MapBackedDirectory; | ||
import org.verapdf.pdfa.flavours.PDFAFlavour; | ||
import org.verapdf.pdfa.flavours.PDFFlavours; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Carl Wilson</a> | ||
|
@@ -158,9 +159,22 @@ private static ProfileDirectoryImpl makeVeraProfileDir() { | |
|
||
private static String getProfilePath(PDFAFlavour flavour) { | ||
StringBuilder profilePath = new StringBuilder(); | ||
profilePath.append(PROFILE_RESOURCE_ROOT).append(flavour.getPart().getFamily().getFamily().replace("/", "") //$NON-NLS-1$ | ||
).append("-").append(flavour.getPart().getPartNumber()).append(flavour.getLevel().getCode().toUpperCase()); //$NON-NLS-1$ | ||
if (flavour == PDFAFlavour.PDFUA_2) { | ||
profilePath.append(PROFILE_RESOURCE_ROOT); | ||
|
||
profilePath.append(flavour.getPart().getFamily().getFamily().replace("/", "")); //$NON-NLS-1$ | ||
profilePath.append("-"); //$NON-NLS-1$ | ||
profilePath.append(flavour.getPart().getPartNumber()); | ||
if (flavour.getPart().getSubpartNumber() != null) { | ||
profilePath.append("-"); //$NON-NLS-1$ | ||
profilePath.append(flavour.getPart().getSubpartNumber()); | ||
} | ||
if (PDFFlavours.isWTPDFFlavour(flavour)) { | ||
profilePath.append("-"); //$NON-NLS-1$ | ||
profilePath.append(flavour.getLevel().getCode()); | ||
} else { | ||
profilePath.append(flavour.getLevel().getCode().toUpperCase()); //$NON-NLS-1$ | ||
} | ||
if (PDFFlavours.isFlavour(flavour, PDFAFlavour.PDFUA_2)) { | ||
profilePath.append("-").append("ISO32005"); | ||
} | ||
profilePath.append(XML_SUFFIX); | ||
|
Binary file not shown.