Class COSUtils


  • public final class COSUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.commons.logging.Log LOGGER  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private COSUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeDocumentQuietly​(COSDocument document)
      Close the given Document.
      static void closeDocumentQuietly​(PDDocument document)
      Close the given Document.
      static COSArray getAsArray​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as COSArray if the COSBase object is an instance of COSArray or a reference to a COSArray object.
      static COSDictionary getAsDictionary​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as COSDictionary if the COSBase object is an instance of COSDictionary or a reference to a COSDictionary object.
      static java.lang.Float getAsFloat​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as Float if the COSBase object is an instance of COSFloat or a reference to a COSFloat object.
      static java.lang.Integer getAsInteger​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as Integer if the COSBase object is an instance of COSInteger or a reference to a COSInteger object.
      static COSStream getAsStream​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as COSStream if the COSBase object is an instance of COSStream or a reference to a COSStream object.
      static java.lang.String getAsString​(COSBase cbase, COSDocument cDoc)
      Return the COSBase object as String if the COSBase object is an instance of COSString or COSName or a reference to it.
      private static COSBase getCOSObjectAsClass​(COSObject cosObject, COSDocument cDoc, java.lang.Class claz)
      Return the COSObject object as class if the COSObject object is a reference to an object of that class.
      static boolean isArray​(COSBase elt, COSDocument doc)
      return true if the elt is a COSArray or a reference to a COSArray
      private static boolean isClass​(COSBase elt, COSDocument doc, java.lang.Class claz)
      return true if the elt is of class or a reference to a that class.
      static boolean isDictionary​(COSBase elt, COSDocument doc)
      return true if the elt is a COSDictionary or a reference to a COSDictionary
      static boolean isFloat​(COSBase elt, COSDocument doc)
      return true if the elt is a COSFloat or a reference to a COSFloat
      static boolean isInteger​(COSBase elt, COSDocument doc)
      return true if the elt is a COSInteger or a reference to a COSInteger
      static boolean isNumeric​(COSBase elt, COSDocument doc)
      return true if elt is COSInteger or COSFloat
      static boolean isStream​(COSBase elt, COSDocument doc)
      return true if the elt is a COSStream or a reference to a COSStream
      static boolean isString​(COSBase elt, COSDocument doc)
      return true if the elt is a COSString or a COSName or a reference to it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.apache.commons.logging.Log LOGGER
    • Constructor Detail

      • COSUtils

        private COSUtils()
    • Method Detail

      • isDictionary

        public static boolean isDictionary​(COSBase elt,
                                           COSDocument doc)
        return true if the elt is a COSDictionary or a reference to a COSDictionary
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSDictionary or a reference to it.
      • isString

        public static boolean isString​(COSBase elt,
                                       COSDocument doc)
        return true if the elt is a COSString or a COSName or a reference to it.
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSString or a COSName or a reference to it.
      • isStream

        public static boolean isStream​(COSBase elt,
                                       COSDocument doc)
        return true if the elt is a COSStream or a reference to a COSStream
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSStream or a reference to it.
      • isInteger

        public static boolean isInteger​(COSBase elt,
                                        COSDocument doc)
        return true if the elt is a COSInteger or a reference to a COSInteger
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSInteger or a reference to it.
      • isClass

        private static boolean isClass​(COSBase elt,
                                       COSDocument doc,
                                       java.lang.Class claz)
        return true if the elt is of class or a reference to a that class.
        Parameters:
        elt - the object to check.
        doc - the document.
        claz - the class.
        Returns:
        true if the object is a of that class or a reference to it.
      • isNumeric

        public static boolean isNumeric​(COSBase elt,
                                        COSDocument doc)
        return true if elt is COSInteger or COSFloat
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSInteger, COSFloat or a reference to it.
      • isFloat

        public static boolean isFloat​(COSBase elt,
                                      COSDocument doc)
        return true if the elt is a COSFloat or a reference to a COSFloat
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSFloat or a reference to it.
      • isArray

        public static boolean isArray​(COSBase elt,
                                      COSDocument doc)
        return true if the elt is a COSArray or a reference to a COSArray
        Parameters:
        elt - the object to check.
        doc - the document.
        Returns:
        true if the object is a COSArray or a reference to it.
      • getAsArray

        public static COSArray getAsArray​(COSBase cbase,
                                          COSDocument cDoc)
        Return the COSBase object as COSArray if the COSBase object is an instance of COSArray or a reference to a COSArray object. In other cases, this method returns null;
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as COSArray if the object is a COSArray or a reference to it. Returns null otherwise.
      • getAsString

        public static java.lang.String getAsString​(COSBase cbase,
                                                   COSDocument cDoc)
        Return the COSBase object as String if the COSBase object is an instance of COSString or COSName or a reference to it.
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as String if the object is a COSString or COSName or reference to it. Returns null otherwise.
      • getAsDictionary

        public static COSDictionary getAsDictionary​(COSBase cbase,
                                                    COSDocument cDoc)
        Return the COSBase object as COSDictionary if the COSBase object is an instance of COSDictionary or a reference to a COSDictionary object. In other cases, this method returns null;
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as COSDictionary if the object is a COSDictionary or a reference to it. Returns null otherwise.
      • getAsStream

        public static COSStream getAsStream​(COSBase cbase,
                                            COSDocument cDoc)
        Return the COSBase object as COSStream if the COSBase object is an instance of COSStream or a reference to a COSStream object. In other cases, this method returns null;
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as COSStream if the object is a COSStream or a reference to it. Returns null otherwise.
      • getAsFloat

        public static java.lang.Float getAsFloat​(COSBase cbase,
                                                 COSDocument cDoc)
        Return the COSBase object as Float if the COSBase object is an instance of COSFloat or a reference to a COSFloat object. In other cases, this method returns null;
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as Float if the object is a COSFloat or a reference to it. Returns null otherwise.
      • getAsInteger

        public static java.lang.Integer getAsInteger​(COSBase cbase,
                                                     COSDocument cDoc)
        Return the COSBase object as Integer if the COSBase object is an instance of COSInteger or a reference to a COSInteger object. In other cases, this method returns null;
        Parameters:
        cbase - the object to get.
        cDoc - the document.
        Returns:
        the object as Integer if the object is a COSInteger or a reference to it. Returns null otherwise.
      • closeDocumentQuietly

        public static void closeDocumentQuietly​(COSDocument document)
        Close the given Document. If the close method of the document throws an exception, it is logged using a commons logger (Level : WARN)
        Parameters:
        document - the document.
      • closeDocumentQuietly

        public static void closeDocumentQuietly​(PDDocument document)
        Close the given Document. If the close method of the document throws an exception, it is logged using a commons logger (Level : WARN)
        Parameters:
        document - the document.
      • getCOSObjectAsClass

        private static COSBase getCOSObjectAsClass​(COSObject cosObject,
                                                   COSDocument cDoc,
                                                   java.lang.Class claz)
        Return the COSObject object as class if the COSObject object is a reference to an object of that class. If not, then this method returns null;
        Parameters:
        cosObject - the object to get.
        cDoc - the document.
        claz - the class.
        Returns:
        the object as class if the object is a reference to that class. Returns null otherwise.