]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Support as independant PDF object. Used for on-the-fly stream output.
authorJeremias Maerki <jeremias@apache.org>
Thu, 27 Mar 2003 10:42:00 +0000 (10:42 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 27 Mar 2003 10:42:00 +0000 (10:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196158 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFNumber.java

index 806a2b8d6087f8a8d1a0f4aeeb617b1d8bc5bb19..6f1c143a7bc472ced43522e59abb25a1dba56756 100644 (file)
 package org.apache.fop.pdf;
 
 /**
- * This class contains some utility methods for outputing numbers to PDF.
+ * This class represents a simple number object. It also contains contains some 
+ * utility methods for outputing numbers to PDF.
  */
-public class PDFNumber {
+public class PDFNumber extends PDFObject {
 
-    /** prevent instantiation */
-    private PDFNumber() { }
+    private Number number;
+
+    /**
+     * Returns the number.
+     * @return the number
+     */
+    public Number getNumber() {
+        return this.number;
+    }
+    
+    /**
+     * Sets the number.
+     * @param number the number
+     */
+    public void setNumber(Number number) {
+        this.number = number;
+    }
 
     /**
      * Output a Double value to a string suitable for PDF.
@@ -143,5 +159,20 @@ public class PDFNumber {
         return (p.toString());
     }
 
+    /**
+     * @see org.apache.fop.pdf.PDFObject#toPDFString()
+     */
+    protected String toPDFString() {
+        if (getNumber() == null) {
+            throw new IllegalArgumentException(
+                "The number of this PDFNumber must not be empty");
+        }
+        StringBuffer sb = new StringBuffer(64);
+        sb.append(getObjectID());
+        sb.append(getNumber().toString());
+        sb.append("\nendobj\n");
+        return sb.toString();
+    }
+
 }