Class COSFloat

  • All Implemented Interfaces:
    COSObjectable

    public class COSFloat
    extends COSNumber
    This class represents a floating point number in a PDF document.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        COSFloat​(float aFloat)
      Constructor.
      private COSFloat​(float aFloat, java.lang.String valueString)
      An internal constructor to avoid formatting for the predefined constants.
        COSFloat​(java.lang.String aFloat)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(ICOSVisitor visitor)
      Visitor pattern double dispatch method.
      private float coerce​(float floatValue)
      Check and coerce the value field to be between MIN_NORMAL and MAX_VALUE.
      boolean equals​(java.lang.Object o)
      float floatValue()
      The value of the float object that this one wraps.
      private java.lang.String formatString()
      Builds, if needed, and returns the string representation of the current value.
      int hashCode()
      int intValue()
      This will get the integer value of this object.
      long longValue()
      This will get the long value of this object.
      java.lang.String toString()
      void writePDF​(java.io.OutputStream output)
      This will output this string as a PDF object.
      • Methods inherited from class org.apache.pdfbox.cos.COSNumber

        get
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • value

        private final float value
      • valueAsString

        private java.lang.String valueAsString
      • ZERO

        public static final COSFloat ZERO
    • Constructor Detail

      • COSFloat

        public COSFloat​(float aFloat)
        Constructor.
        Parameters:
        aFloat - The primitive float object that this object wraps.
      • COSFloat

        private COSFloat​(float aFloat,
                         java.lang.String valueString)
        An internal constructor to avoid formatting for the predefined constants.
        Parameters:
        aFloat -
        valueString -
      • COSFloat

        public COSFloat​(java.lang.String aFloat)
                 throws java.io.IOException
        Constructor.
        Parameters:
        aFloat - The primitive float object that this object wraps.
        Throws:
        java.io.IOException - If aFloat is not a float.
    • Method Detail

      • coerce

        private float coerce​(float floatValue)
        Check and coerce the value field to be between MIN_NORMAL and MAX_VALUE.
        Parameters:
        floatValue - the value to be checked
        Returns:
        the coerced value
      • floatValue

        public float floatValue()
        The value of the float object that this one wraps.
        Specified by:
        floatValue in class COSNumber
        Returns:
        The value of this object.
      • longValue

        public long longValue()
        This will get the long value of this object.
        Specified by:
        longValue in class COSNumber
        Returns:
        The long value of this object,
      • intValue

        public int intValue()
        This will get the integer value of this object.
        Specified by:
        intValue in class COSNumber
        Returns:
        The int value of this object,
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • formatString

        private java.lang.String formatString()
        Builds, if needed, and returns the string representation of the current value.
        Returns:
        current value as string.
      • accept

        public void accept​(ICOSVisitor visitor)
                    throws java.io.IOException
        Visitor pattern double dispatch method.
        Specified by:
        accept in class COSBase
        Parameters:
        visitor - The object to notify when visiting this object.
        Throws:
        java.io.IOException - If an error occurs while visiting this object.
      • writePDF

        public void writePDF​(java.io.OutputStream output)
                      throws java.io.IOException
        This will output this string as a PDF object.
        Parameters:
        output - The stream to write to.
        Throws:
        java.io.IOException - If there is an error writing to the stream.