pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1635911 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
Date Sat, 01 Nov 2014 10:00:31 GMT
Author: lehmi
Date: Sat Nov  1 10:00:30 2014
New Revision: 1635911

URL: http://svn.apache.org/r1635911
Log:
PDFBOX-649: log unsupported annotation types instead of throwing an exception

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java?rev=1635911&r1=1635910&r2=1635911&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java Sat
Nov  1 10:00:30 2014
@@ -20,12 +20,13 @@ import java.awt.Color;
 import java.io.IOException;
 import java.util.Calendar;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
-
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
@@ -35,11 +36,12 @@ import org.w3c.dom.Element;
 /**
  * This represents an FDF annotation that is part of the FDF document.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.4 $
- */
+ * @author Ben Litchfield
+ * 
+ * */
 public abstract class FDFAnnotation implements COSObjectable
 {
+    private static final Log LOG = LogFactory.getLog(FDFAnnotation.class);
     /**
      * Annotation dictionary.
      */
@@ -51,7 +53,7 @@ public abstract class FDFAnnotation impl
     public FDFAnnotation()
     {
         annot = new COSDictionary();
-        annot.setName( "Type", "Annot" );
+        annot.setItem( COSName.TYPE, COSName.ANNOT );
     }
 
     /**
@@ -177,17 +179,16 @@ public abstract class FDFAnnotation impl
     public static FDFAnnotation create( COSDictionary fdfDic ) throws IOException
     {
         FDFAnnotation retval = null;
-        if( fdfDic == null )
-        {
-            //do nothing and return null
-        }
-        else if( FDFAnnotationText.SUBTYPE.equals( fdfDic.getNameAsString( COSName.SUBTYPE
) ) )
+        if( fdfDic != null )
         {
-            retval = new FDFAnnotationText( fdfDic );
-        }
-        else
-        {
-            throw new IOException( "Unknown annotation type '" + fdfDic.getNameAsString(
COSName.SUBTYPE ) + "'" );
+	        if( FDFAnnotationText.SUBTYPE.equals( fdfDic.getNameAsString( COSName.SUBTYPE )
) )
+	        {
+	            retval = new FDFAnnotationText( fdfDic );
+	        }
+	        else
+	        {
+	            LOG.warn("Unknown annotation type '" + fdfDic.getNameAsString( COSName.SUBTYPE
) + "'" );
+	        }
         }
         return retval;
     }
@@ -220,7 +221,7 @@ public abstract class FDFAnnotation impl
     public Integer getPage()
     {
         Integer retval = null;
-        COSNumber page = (COSNumber)annot.getDictionaryObject( "Page" );
+        COSNumber page = (COSNumber)annot.getDictionaryObject( COSName.PAGE );
         if( page != null )
         {
             retval = page.intValue();
@@ -282,7 +283,7 @@ public abstract class FDFAnnotation impl
      */
     public String getDate()
     {
-        return annot.getString( "date" );
+        return annot.getString( COSName.DATE );
     }
 
     /**
@@ -292,7 +293,7 @@ public abstract class FDFAnnotation impl
      */
     public void setDate( String date )
     {
-        annot.setString( "date", date );
+        annot.setString( COSName.DATE, date );
     }
 
     /**
@@ -518,7 +519,6 @@ public abstract class FDFAnnotation impl
         {
             retval = new PDRectangle( rectArray );
         }
-
         return retval;
     }
 



Mime
View raw message