Class COSUtils
java.lang.Object
org.apache.pdfbox.preflight.utils.COSUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 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 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 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, 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 COSArrayprivate static boolean
isClass
(COSBase elt, COSDocument doc, 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 COSDictionarystatic boolean
isFloat
(COSBase elt, COSDocument doc) return true if the elt is a COSFloat or a reference to a COSFloatstatic boolean
isInteger
(COSBase elt, COSDocument doc) return true if the elt is a COSInteger or a reference to a COSIntegerstatic boolean
isNumeric
(COSBase elt, COSDocument doc) return true if elt is COSInteger or COSFloatstatic boolean
isStream
(COSBase elt, COSDocument doc) return true if the elt is a COSStream or a reference to a COSStreamstatic boolean
isString
(COSBase elt, COSDocument doc) return true if the elt is a COSString or a COSName or a reference to it.
-
Field Details
-
LOGGER
private static final org.apache.commons.logging.Log LOGGER
-
-
Constructor Details
-
COSUtils
private COSUtils()
-
-
Method Details
-
isDictionary
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
-