Skip to content

Commit

Permalink
Merge pull request #619 from veraPDF/static_xmp_containers
Browse files Browse the repository at this point in the history
Add StaticXmpCoreContainers to library
  • Loading branch information
MaximPlusov authored Dec 11, 2023
2 parents 6044919 + d601a0d commit c252a3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.verapdf.parser.PDFFlavour;
import org.verapdf.tools.StaticResources;
import org.verapdf.xmp.XMPException;
import org.verapdf.xmp.containers.StaticXmpCoreContainers;
import org.verapdf.xmp.impl.VeraPDFMeta;
import org.verapdf.ReleaseDetails;
import org.verapdf.component.ComponentDetails;
Expand Down Expand Up @@ -206,6 +207,7 @@ private static void initializeStaticResources(String password) {
private static void clearStaticContainers() {
StaticContainers.clearAllContainers();
StaticResources.clear();
StaticXmpCoreContainers.clearAllContainers();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.verapdf.pdfa.results.ValidationResult;
import org.verapdf.pdfa.validation.validators.ValidatorFactory;
import org.verapdf.tools.StaticResources;
import org.verapdf.xmp.containers.StaticXmpCoreContainers;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -153,6 +154,8 @@ private static boolean isValidPdfaStream(final InputStream toValidate, final PDF
private Map<String, CMap> cMapCache;
private Map<COSKey, PDStructureNameSpace> structureNameSpaceCache;
private Map<String, FontProgram> cachedFonts;
private Map<String, String> namespaceToPrefixMap;
private Map<String, String> prefixToNamespaceMap;

private void saveStaticContainersState() {
this.document = StaticResources.getDocument();
Expand Down Expand Up @@ -182,6 +185,9 @@ private void saveStaticContainersState() {

Map<String, FontProgram> cachedFonts = StaticResources.getCachedFonts();
this.cachedFonts = cachedFonts == null ? null : new HashMap<>(cachedFonts);

this.namespaceToPrefixMap = StaticXmpCoreContainers.getNamespaceToPrefixMap();
this.prefixToNamespaceMap = StaticXmpCoreContainers.getPrefixToNamespaceMap();
}

private void restoreSavedSCState() {
Expand All @@ -207,5 +213,8 @@ private void restoreSavedSCState() {
StaticResources.setStructureNameSpaceCache(this.structureNameSpaceCache);
StaticResources.setCachedFonts(this.cachedFonts);
StaticResources.setFlavour(this.flavour != null ? PDFFlavour.valueOf(this.flavour.name()) : null);

StaticXmpCoreContainers.setNamespaceToPrefixMap(this.namespaceToPrefixMap);
StaticXmpCoreContainers.setPrefixToNamespaceMap(this.prefixToNamespaceMap);
}
}

0 comments on commit c252a3d

Please sign in to comment.