Skip to content

Commit 278f5eb

Browse files
committed
PDFBOX-6088: add "rev" to schema
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929356 13f79535-47bb-0310-9956-ffa450edef68
1 parent b6dd907 commit 278f5eb

File tree

2 files changed

+85
-8
lines changed

2 files changed

+85
-8
lines changed

xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public class PDFAIdentificationSchema extends XMPSchema
5151
@PropertyType(type = Types.Text, card = Cardinality.Simple)
5252
public static final String CONFORMANCE = "conformance";
5353

54+
// PDFBOX-6088 https://pdfa.org/future-proofing-xmp-identification-schema/
55+
@PropertyType(type = Types.Integer, card = Cardinality.Simple)
56+
public static final String REV = "rev";
57+
5458
/*
5559
* <rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">
5660
* <pdfaid:conformance>B</pdfaid:conformance> <pdfaid:part>1</pdfaid:part> </rdf:Description>
@@ -73,7 +77,7 @@ public PDFAIdentificationSchema(XMPMetadata metadata, String prefix)
7377
}
7478

7579
/**
76-
* Set the PDFA Version identifier (with string)
80+
* Set the PDF/A Version identifier (with string)
7781
*
7882
* @param value
7983
* The version Id value to set
@@ -86,7 +90,7 @@ public void setPartValueWithString(String value)
8690
}
8791

8892
/**
89-
* Set the PDFA Version identifier (with an int)
93+
* Set the PDF/A Version identifier (with an int)
9094
*
9195
* @param value
9296
* The version Id value to set
@@ -203,7 +207,7 @@ public Integer getPart()
203207
}
204208

205209
/**
206-
* Give the property corresponding to the PDFA Version id
210+
* Give the property corresponding to the PDF/A Version id
207211
*
208212
* @return Part property
209213
*/
@@ -233,7 +237,7 @@ public String getAmendment()
233237
}
234238

235239
/**
236-
* Give the property corresponding to the PDFA Amendment id
240+
* Give the property corresponding to the PDF/A Amendment id
237241
*
238242
* @return Amendment property
239243
*/
@@ -248,7 +252,7 @@ public TextType getAmdProperty()
248252
}
249253

250254
/**
251-
* Give the PDFA Amendment Id (as an String)
255+
* Give the PDF/A Amendment Id (as an String)
252256
*
253257
* @return Amendment Value
254258
*/
@@ -273,7 +277,7 @@ public String getAmd()
273277
}
274278

275279
/**
276-
* Give the property corresponding to the PDFA Conformance id
280+
* Give the property corresponding to the PDF/A Conformance id
277281
*
278282
* @return conformance property
279283
*/
@@ -312,4 +316,76 @@ public String getConformance()
312316
}
313317
}
314318

319+
/**
320+
* Set the PDF/A revision (with string)
321+
*
322+
* @param value The revision value to set
323+
*
324+
*/
325+
public void setRevValueWithString(String value)
326+
{
327+
IntegerType rev = (IntegerType) instanciateSimple(REV, value);
328+
addProperty(rev);
329+
}
330+
331+
/**
332+
* Set the PDF/A revision (with an int)
333+
*
334+
* @param value The revision value to set
335+
*/
336+
public void setRevValueWithInt(int value)
337+
{
338+
IntegerType rev = (IntegerType) instanciateSimple(REV, value);
339+
addProperty(rev);
340+
}
341+
342+
/**
343+
* Set the PDF/A revision identifier (with an int)
344+
*
345+
* @param value The revision property to set
346+
*/
347+
public void setRev(Integer value)
348+
{
349+
setRevValueWithInt(value);
350+
}
351+
352+
/**
353+
* Set the PDF/A revision identifier
354+
*
355+
* @param rev set the PDF/A revision id property
356+
*/
357+
public void setRevProperty(IntegerType rev)
358+
{
359+
addProperty(rev);
360+
}
361+
362+
/**
363+
* Give the property corresponding to the PDF/A revision
364+
*
365+
* @return revision property
366+
*/
367+
public IntegerType getRevProperty()
368+
{
369+
AbstractField tmp = getProperty(REV);
370+
if (tmp instanceof IntegerType)
371+
{
372+
return (IntegerType) tmp;
373+
}
374+
return null;
375+
}
376+
377+
/**
378+
* Give the PDF/A revision (as an integer)
379+
*
380+
* @return revision value (Integer) or null if it is missing
381+
*/
382+
public Integer getRev()
383+
{
384+
IntegerType tmp = getRevProperty();
385+
if (tmp == null)
386+
{
387+
return null;
388+
}
389+
return tmp.getValue();
390+
}
315391
}

xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ void testElementProperty(String property, PropertyType type, Object value) throw
6161
xmpSchemaTester.testGetSetProperty();
6262
}
6363

64-
static Stream<Arguments> initializeParameters()
64+
static Stream<Arguments> initializeParameters() throws Exception
6565
{
6666
return Stream.of(
6767
Arguments.of("part", XMPSchemaTester.createPropertyType(Types.Integer), 1),
6868
Arguments.of("amd", XMPSchemaTester.createPropertyType(Types.Text), "2005"),
69-
Arguments.of("conformance", XMPSchemaTester.createPropertyType(Types.Text), "B")
69+
Arguments.of("conformance", XMPSchemaTester.createPropertyType(Types.Text), "B"),
70+
Arguments.of("rev", XMPSchemaTester.createPropertyType(Types.Integer), 2020)
7071
);
7172
}
7273
}

0 commit comments

Comments
 (0)