Class ImageUtil
java.lang.Object
org.apache.xmlgraphics.image.loader.util.ImageUtil
Helper and convenience methods for working with the image package.
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamAutomatically decorates an InputStream so it is buffered.static voidcloseQuietly(Source src) Deprecated.static InputStreamDecorates an InputStream with a BufferedInputStream if it doesn't support mark()/reset().static MapgetDefaultHints(ImageSessionContext session) Creates a new hint Map with values from the FOUserAgent.static ImageInputStreamReturns the ImageInputStream of a Source object.static InputStreamgetInputStream(Source src) Deprecated.Please useXmlSourceUtil.getInputStream(Source)instead.static IntegerExtracts page index information from a URI.static booleanIndicates whether the Source object has an ImageInputStream instance.static booleanhasInputStream(Source src) Indicates whether the Source object has an InputStream instance.static booleanDeprecated.useXmlSourceUtil.hasReader(Source)insteadstatic ImageInputStreamDecorates an ImageInputStream so the flush*() methods are ignored and have no effect.static booleanIndicates whether an InputStream is GZIP compressed.static ImageInputStreamReturns the ImageInputStream of a Source object.static InputStreamneedInputStream(Source src) Deprecated.useXmlSourceUtil.needInputStream(Source)insteadstatic intExtracts page index information from a URI.static voidremoveStreams(Source src) Deprecated.useXmlSourceUtil.removeStreams(Source)instead
-
Method Details
-
getInputStream
Deprecated.Please useXmlSourceUtil.getInputStream(Source)instead.Returns the InputStream of a Source object.- Parameters:
src- the Source object- Returns:
- the InputStream (or null if there's not InputStream available)
-
getImageInputStream
Returns the ImageInputStream of a Source object.- Parameters:
src- the Source object- Returns:
- the ImageInputStream (or null if there's not ImageInputStream available)
-
needInputStream
Deprecated.useXmlSourceUtil.needInputStream(Source)insteadReturns the InputStream of a Source object. This method throws an IllegalArgumentException if there's no InputStream instance available from the Source object.- Parameters:
src- the Source object- Returns:
- the InputStream
-
needImageInputStream
Returns the ImageInputStream of a Source object. This method throws an IllegalArgumentException if there's no ImageInputStream instance available from the Source object.- Parameters:
src- the Source object- Returns:
- the ImageInputStream
-
hasInputStream
Indicates whether the Source object has an InputStream instance.- Parameters:
src- the Source object- Returns:
- true if an InputStream is available
-
hasReader
Deprecated.useXmlSourceUtil.hasReader(Source)insteadIndicates whether the Source object has a Reader instance.- Parameters:
src- the Source object- Returns:
- true if an Reader is available
-
hasImageInputStream
Indicates whether the Source object has an ImageInputStream instance.- Parameters:
src- the Source object- Returns:
- true if an ImageInputStream is available
-
removeStreams
Deprecated.useXmlSourceUtil.removeStreams(Source)insteadRemoves any references to InputStreams or Readers from the given Source to prohibit accidental/unwanted use by a component further downstream.- Parameters:
src- the Source object
-
closeQuietly
Deprecated.useXmlSourceUtil.closeQuietly(Source)insteadCloses the InputStreams or ImageInputStreams of Source objects. Any exception occurring while closing the stream is ignored.- Parameters:
src- the Source object
-
ignoreFlushing
Decorates an ImageInputStream so the flush*() methods are ignored and have no effect. The decoration is implemented using a dynamic proxy.- Parameters:
in- the ImageInputStream- Returns:
- the decorated ImageInputStream
-
isGZIPCompressed
Indicates whether an InputStream is GZIP compressed. The InputStream must support mark()/reset().- Parameters:
in- the InputStream (must return true on markSupported())- Returns:
- true if the InputStream is GZIP compressed
- Throws:
IOException- in case of an I/O error
-
decorateMarkSupported
Decorates an InputStream with a BufferedInputStream if it doesn't support mark()/reset().- Parameters:
in- the InputStream- Returns:
- the decorated InputStream
-
autoDecorateInputStream
Automatically decorates an InputStream so it is buffered. Furthermore, it makes sure it is decorated with a GZIPInputStream if the stream is GZIP compressed.- Parameters:
in- the InputStream- Returns:
- the decorated InputStream
- Throws:
IOException- in case of an I/O error
-
getDefaultHints
Creates a new hint Map with values from the FOUserAgent.- Parameters:
session- the session context- Returns:
- a Map of hints
-
getPageIndexFromURI
Extracts page index information from a URI. The expected pattern is "page=x" where x is a non-negative integer number. The page index must be specified as part of the URI fragment and is 1-based, i.e. the first page is 1 but the the method returns a zero-based page index. An example:http://www.foo.bar/images/scan1.tif#page=4(The method will return 3.)If no page index information is found in the URI or if the URI cannot be parsed, the method returns null.
- Parameters:
uri- the URI that should be inspected- Returns:
- the page index (0 is the first page) or null if there's no page index information in the URI
-
needPageIndexFromURI
Extracts page index information from a URI. The expected pattern is "page=x" where x is a non-negative integer number. The page index must be specified as part of the URI fragment and is 1-based, i.e. the first page is 1 but the the method returns a zero-based page index. An example:http://www.foo.bar/images/scan1.tif#page=4(The method will return 3.)If no page index information is found in the URI, the method just returns 0 which indicates the first page.
- Parameters:
uri- the URI that should be inspected- Returns:
- the page index (0 is the first page)
-
XmlSourceUtil.closeQuietly(Source)instead