From 6a415aad7bc99812b2397680b77575e43ea58ad4 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 18 Dec 2023 17:25:12 +0300 Subject: [PATCH] Add getpresentInEmbeddedFiles to GFCosFileSpecification --- .../org/verapdf/gf/model/impl/cos/GFCosDocument.java | 2 +- .../gf/model/impl/cos/GFCosFileSpecification.java | 10 +++++++++- .../verapdf/gf/model/visitor/cos/gf/GFCosVisitor.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java index 453e82e35..67a0fb198 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java @@ -420,7 +420,7 @@ private void getNamesEmbeddedFiles(List files, PDNameTreeN Map names = node.getNames(); for (COSObject value : names.values()) { if (value != null && value.getType().isDictionaryBased()) { - files.add(new GFCosFileSpecification((COSDictionary) value.getDirectBase())); + files.add(new GFCosFileSpecification((COSDictionary) value.getDirectBase(), true)); } } for (PDNameTreeNode kid : node.getKids()) { diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosFileSpecification.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosFileSpecification.java index 595830bfe..89dcf844f 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosFileSpecification.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosFileSpecification.java @@ -48,6 +48,8 @@ public class GFCosFileSpecification extends GFCosDict implements CosFileSpecific private final String f; private final String uf; private final String afrelationship; + + private final boolean presentInEmbeddedFiles; /** * Default constructor @@ -55,11 +57,12 @@ public class GFCosFileSpecification extends GFCosDict implements CosFileSpecific * @param dictionary * greenfield COSDictionary */ - public GFCosFileSpecification(COSDictionary dictionary) { + public GFCosFileSpecification(COSDictionary dictionary, boolean presentInEmbeddedFiles) { super(dictionary, COS_FILE_SPECIFICATION_TYPE); this.f = this.baseObject.getStringKey(ASAtom.F); this.uf = this.baseObject.getStringKey(ASAtom.UF); this.afrelationship = dictionary.getNameKeyStringValue(ASAtom.AF_RELATIONSHIP); + this.presentInEmbeddedFiles = presentInEmbeddedFiles; } @Override @@ -83,6 +86,11 @@ public Boolean getisAssociatedFile() { && StaticContainers.getFileSpecificationKeys().contains(this.baseObject.getObjectKey()); } + @Override + public Boolean getpresentInEmbeddedFiles() { + return this.presentInEmbeddedFiles; + } + @Override public Boolean getcontainsEF() { return baseObject != null && this.baseObject.knownKey(ASAtom.EF); diff --git a/validation-model/src/main/java/org/verapdf/gf/model/visitor/cos/gf/GFCosVisitor.java b/validation-model/src/main/java/org/verapdf/gf/model/visitor/cos/gf/GFCosVisitor.java index e44ab569b..917486a9b 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/visitor/cos/gf/GFCosVisitor.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/visitor/cos/gf/GFCosVisitor.java @@ -66,7 +66,7 @@ public Object visitFromBoolean(COSBoolean obj) { public Object visitFromDictionary(COSDictionary obj) { ASAtom type = obj.getNameKey(ASAtom.TYPE); boolean isFileSpec = ASAtom.FILESPEC.equals(type); - return isFileSpec ? new GFCosFileSpecification(obj) : new GFCosDict(obj); + return isFileSpec ? new GFCosFileSpecification(obj, false) : new GFCosDict(obj); } /** {@inheritDoc} Create a GFCosDocument for corresponding COSDocument.