Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions xmp-core/src/main/java/org/verapdf/xmp/impl/VeraPDFMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class VeraPDFMeta {
public static final String PDFAID_PREFIX = "pdfaid";
public static final String PDFUAID_PREFIX = "pdfuaid";
public static final String PDFA_EXTENSION_PREFIX = "pdfaExtension";
public static final String DC_PREFIX = "dc";
public static final String PDFD_PREFIX = "pdfd";
public static final String SCHEMAS = "schemas";
public static final String CONFORMANCE = "conformance";
public static final String PART = "part";
Expand Down Expand Up @@ -365,6 +367,39 @@ public boolean containsDeclaration(String conformsTo) {
return false;
}

public VeraPDFMeta addDeclarations(Set<String> conformsToURIs) throws XMPException {
if (conformsToURIs == null || conformsToURIs.isEmpty()) {
throw new IllegalArgumentException("Argument conformsToURIs can not be null or empty");
}
if (getProperty(PDFA_DECLARATIONS, DECLARATIONS) == null) {
meta.setProperty(PDFA_DECLARATIONS, DECLARATIONS, null,
new PropertyOptions().setArray(true));
}

for (String uri : conformsToURIs) {
this.meta.appendArrayItem(
PDFA_DECLARATIONS,
DECLARATIONS,
null,
null,
new PropertyOptions().setStruct(true)
);
int idx = this.meta.countArrayItems(PDFA_DECLARATIONS, DECLARATIONS);
String itemPath = XMPPathFactory.composeArrayItemPath(DECLARATIONS, idx);
this.meta.setStructField(
PDFA_DECLARATIONS,
itemPath,
PDFA_DECLARATIONS,
CONFORMS_TO,
uri,
null
);
}

update();
return this;
}

public VeraPDFMeta setPDFAIdentificationPart(Integer identificationPart) throws XMPException {
String value = identificationPart == null ? null : identificationPart.toString();
return setSimpleTextProperty(XMPSchemaRegistryImpl.NS_PDFA_ID, PART, value);
Expand Down
Loading