You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2022/07/03 16:39:23 UTC

svn commit: r1902433 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java

Author: lehmi
Date: Sun Jul  3 16:39:23 2022
New Revision: 1902433

URL: http://svn.apache.org/viewvc?rev=1902433&view=rev
Log:
PDFBOX-5149: make class public again, add generic type as proposed by Emmeran Seehuber

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java?rev=1902433&r1=1902432&r2=1902433&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java Sun Jul  3 16:39:23 2022
@@ -39,7 +39,7 @@ import org.apache.pdfbox.pdmodel.common.
  * Utility class used to clone PDF objects. It keeps track of objects it has already cloned.
  *
  */
-class PDFCloneUtility
+public class PDFCloneUtility
 {
     private static final Log LOG = LogFactory.getLog(PDFCloneUtility.class);
 
@@ -73,11 +73,14 @@ class PDFCloneUtility
     /**
      * Deep-clones the given object for inclusion into a different PDF document identified by the destination parameter.
      * 
+     * Expert use only, don’t use it if you don’t know exactly what you are doing.
+     * 
      * @param base the initial object as the root of the deep-clone operation
      * @return the cloned instance of the base object
      * @throws IOException if an I/O error occurs
      */
-    COSBase cloneForNewDocument(COSBase base) throws IOException
+    @SuppressWarnings("unchecked")
+    public <TCOSBase extends COSBase> TCOSBase cloneForNewDocument(TCOSBase base) throws IOException
     {
         if (base == null)
         {
@@ -87,7 +90,7 @@ class PDFCloneUtility
         if (retval != null)
         {
             // we are done, it has already been converted.
-            return retval;
+            return (TCOSBase) retval;
         }
         if (clonedValues.contains(base))
         {
@@ -97,7 +100,7 @@ class PDFCloneUtility
         retval = cloneCOSBaseForNewDocument((COSBase)base);
         clonedVersion.put(base, retval);
         clonedValues.add(retval);
-        return retval;
+        return (TCOSBase) retval;
     }
 
     COSBase cloneCOSBaseForNewDocument(COSBase base) throws IOException