org.apache.pdfbox.preflight.utils

## Class COSUtils

- java.lang.Object
- - org.apache.pdfbox.preflight.utils.COSUtils

    public final class COSUtils
    extends Object

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `closeDocumentQuietly(org.apache.pdfbox.cos.COSDocument document)` Close the given Document.
`static void` `closeDocumentQuietly(org.apache.pdfbox.pdmodel.PDDocument document)` Close the given Document.
`static org.apache.pdfbox.cos.COSArray` `getAsArray(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.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 org.apache.pdfbox.cos.COSDictionary` `getAsDictionary(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.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 Float` `getAsFloat(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.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 Integer` `getAsInteger(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.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 org.apache.pdfbox.cos.COSStream` `getAsStream(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.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 String` `getAsString(org.apache.pdfbox.cos.COSBase cbase, org.apache.pdfbox.cos.COSDocument cDoc)` Return the COSBase object as String if the COSBase object is an instance of COSString or COSName or a reference to it.
`static boolean` `isArray(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if the elt is a COSArray or a reference to a COSArray
`static boolean` `isDictionary(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if the elt is a COSDictionary or a reference to a COSDictionary
`static boolean` `isFloat(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if the elt is a COSFloat or a reference to a COSFloat
`static boolean` `isInteger(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if the elt is a COSInteger or a reference to a COSInteger
`static boolean` `isNumeric(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if elt is COSInteger or COSFloat
`static boolean` `isStream(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.COSDocument doc)` return true if the elt is a COSStream or a reference to a COSStream
`static boolean` `isString(org.apache.pdfbox.cos.COSBase elt, org.apache.pdfbox.cos.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`

### Method Detail

#### isDictionary

    public static boolean isDictionary(org.apache.pdfbox.cos.COSBase elt,
                                       org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.COSBase elt,
                                   org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.COSBase elt,
                                   org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.COSBase elt,
                                    org.apache.pdfbox.cos.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.

#### isNumeric

    public static boolean isNumeric(org.apache.pdfbox.cos.COSBase elt,
                                    org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.COSBase elt,
                                  org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.COSBase elt,
                                  org.apache.pdfbox.cos.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 org.apache.pdfbox.cos.COSArray getAsArray(org.apache.pdfbox.cos.COSBase cbase,
                                                            org.apache.pdfbox.cos.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 String getAsString(org.apache.pdfbox.cos.COSBase cbase,
                                     org.apache.pdfbox.cos.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 org.apache.pdfbox.cos.COSDictionary getAsDictionary(org.apache.pdfbox.cos.COSBase cbase,
                                                                      org.apache.pdfbox.cos.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 org.apache.pdfbox.cos.COSStream getAsStream(org.apache.pdfbox.cos.COSBase cbase,
                                                              org.apache.pdfbox.cos.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 Float getAsFloat(org.apache.pdfbox.cos.COSBase cbase,
                                   org.apache.pdfbox.cos.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 Integer getAsInteger(org.apache.pdfbox.cos.COSBase cbase,
                                       org.apache.pdfbox.cos.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(org.apache.pdfbox.cos.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(org.apache.pdfbox.pdmodel.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.