Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| xmlgraphics-commons 2.0.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xmlgraphics.image.loader.util
Class ImageUtil

    java.lang.Object
      org.apache.xmlgraphics.image.loader.util.ImageUtil

    public final class ImageUtil

extends Object

Helper and convenience methods for working with the image package.

Method Summary
`static InputStream` | `autoDecorateInputStream(InputStream in)` Automatically decorates an InputStream so it is buffered.
`static void` | `closeQuietly(Source src)` Deprecated. use `XmlSourceUtil.closeQuietly(Source)` instead
`static InputStream` | `decorateMarkSupported(InputStream in)` Decorates an InputStream with a BufferedInputStream if it doesn't support mark()/reset().
`static Map` | `getDefaultHints(ImageSessionContext session)` Creates a new hint Map with values from the FOUserAgent.
`static ImageInputStream` | `getImageInputStream(Source src)` Returns the ImageInputStream of a Source object.
`static InputStream` | `getInputStream(Source src)` Deprecated. Please use `XmlSourceUtil.getInputStream(Source)` instead.
`static Integer` | `getPageIndexFromURI(String uri)` Extracts page index information from a URI.
`static boolean` | `hasImageInputStream(Source src)` Indicates whether the Source object has an ImageInputStream instance.
`static boolean` | `hasInputStream(Source src)` Indicates whether the Source object has an InputStream instance.
`static boolean` | `hasReader(Source src)` Deprecated. use `XmlSourceUtil.hasReader(Source)` instead
`static ImageInputStream` | `ignoreFlushing(ImageInputStream in)` Decorates an ImageInputStream so the flush*() methods are ignored and have no effect.
`static boolean` | `isGZIPCompressed(InputStream in)` Indicates whether an InputStream is GZIP compressed.
`static ImageInputStream` | `needImageInputStream(Source src)` Returns the ImageInputStream of a Source object.
`static InputStream` | `needInputStream(Source src)` Deprecated. use `XmlSourceUtil.needInputStream(Source)` instead
`static int` | `needPageIndexFromURI(String uri)` Extracts page index information from a URI.
`static void` | `removeStreams(Source src)` Deprecated. use `XmlSourceUtil.removeStreams(Source)` instead

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInputStream

    @Deprecated
    public static InputStream getInputStream(Source src)

  Deprecated. Please use `XmlSourceUtil.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

    public static ImageInputStream getImageInputStream(Source src)

  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
    public static InputStream needInputStream(Source src)

  Deprecated. use `XmlSourceUtil.needInputStream(Source)` instead

  Returns 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

    public static ImageInputStream needImageInputStream(Source src)

  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

    public static boolean hasInputStream(Source src)

  Indicates whether the Source object has an InputStream instance.

  Parameters:
    `src` - the Source object
  Returns:
    true if an InputStream is available

### hasReader

    @Deprecated
    public static boolean hasReader(Source src)

  Deprecated. use `XmlSourceUtil.hasReader(Source)` instead

  Indicates whether the Source object has a Reader instance.

  Parameters:
    `src` - the Source object
  Returns:
    true if an Reader is available

### hasImageInputStream

    public static boolean hasImageInputStream(Source src)

  Indicates whether the Source object has an ImageInputStream instance.

  Parameters:
    `src` - the Source object
  Returns:
    true if an ImageInputStream is available

### removeStreams

    @Deprecated
    public static void removeStreams(Source src)

  Deprecated. use `XmlSourceUtil.removeStreams(Source)` instead

  Removes 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
    public static void closeQuietly(Source src)

  Deprecated. use `XmlSourceUtil.closeQuietly(Source)` instead

  Closes the InputStreams or ImageInputStreams of Source objects. Any exception occurring while closing the stream is ignored.

  Parameters:
    `src` - the Source object

### ignoreFlushing

    public static ImageInputStream ignoreFlushing(ImageInputStream in)

  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

    public static boolean isGZIPCompressed(InputStream in)
                                    throws IOException

  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

    public static InputStream decorateMarkSupported(InputStream in)

  Decorates an InputStream with a BufferedInputStream if it doesn't support mark()/reset().

  Parameters:
    `in` - the InputStream
  Returns:
    the decorated InputStream

### autoDecorateInputStream

    public static InputStream autoDecorateInputStream(InputStream in)
                                               throws IOException

  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

    public static Map getDefaultHints(ImageSessionContext session)

  Creates a new hint Map with values from the FOUserAgent.

  Parameters:
    `session` - the session context
  Returns:
    a Map of hints

### getPageIndexFromURI

    public static Integer getPageIndexFromURI(String uri)

  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

    public static int needPageIndexFromURI(String uri)

  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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| xmlgraphics-commons 2.0.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1999-2015 The Apache Software Foundation. All Rights Reserved.