Author: tilman
Date: Sun Oct 27 08:46:24 2024
New Revision: 1921591

URL: http://svn.apache.org/viewvc?rev=1921591&view=rev
Log:
PDFBOX-5890: add simpler method to pass MCID, check parameter for existing 
method

Modified:
    
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java?rev=1921591&r1=1921590&r2=1921591&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java
 Sun Oct 27 08:46:24 2024
@@ -617,7 +617,23 @@ public class PDStructureElement extends
     /**
      * Appends a marked-content sequence kid.
      * 
-     * @param markedContent the marked-content sequence
+     * @param mcid the marked-content id (MCID).
+     * @throws IllegalArgumentException if the mcid is negative.
+     */
+    public void appendKid(int mcid)
+    {
+        if (mcid < 0)
+        {
+            throw new IllegalArgumentException("MCID should not be negative");
+        }
+        this.appendKid(COSInteger.get(mcid));
+    }
+
+    /**
+     * Appends a marked-content sequence kid.
+     * 
+     * @param markedContent the marked-content sequence with the MCID.
+     * @throws IllegalArgumentException if the mcid is negative or doesn't 
exist.
      */
     public void appendKid(PDMarkedContent markedContent)
     {
@@ -625,7 +641,12 @@ public class PDStructureElement extends
         {
             return;
         }
-        this.appendKid(COSInteger.get(markedContent.getMCID()));
+        int mcid = markedContent.getMCID();
+        if (mcid < 0)
+        {
+            throw new IllegalArgumentException("MCID is negative or doesn't 
exist");
+        }
+        this.appendKid(COSInteger.get(mcid));
     }
 
     /**


Reply via email to