Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.ext.awt.image.spi
Class MagicNumberRegistryEntry  view MagicNumberRegistryEntry download MagicNumberRegistryEntry.java

java.lang.Object
  extended byorg.apache.batik.ext.awt.image.spi.AbstractRegistryEntry
      extended byorg.apache.batik.ext.awt.image.spi.MagicNumberRegistryEntry
All Implemented Interfaces:
ErrorConstants, RegistryEntry, StreamRegistryEntry
Direct Known Subclasses:
JPEGRegistryEntry, PNGRegistryEntry, TIFFRegistryEntry

public abstract class MagicNumberRegistryEntry
extends AbstractRegistryEntry
implements StreamRegistryEntry

This Image tag registry entry is built around the notion of magic numbers. These are strings of bytes that are at a well known location in the input stream (often the start). This base class can handle the compatiblity check based on a list of Magic Numbers that correspond to your format (Some formats have multiple magic numbers associated with them).


Nested Class Summary
static class MagicNumberRegistryEntry.MagicNumber
          Inner class that represents one magic number.
 
Field Summary
(package private)  MagicNumberRegistryEntry.MagicNumber[] magicNumbers
          The list of magic numbers associated with this entry
static float PRIORITY
           
 
Fields inherited from class org.apache.batik.ext.awt.image.spi.AbstractRegistryEntry
exts, mimeTypes, name, priority
 
Fields inherited from interface org.apache.batik.ext.awt.image.spi.ErrorConstants
ERR_STREAM_FORMAT_UNREADABLE, ERR_STREAM_UNREADABLE, ERR_URL_FORMAT_UNREADABLE, ERR_URL_UNINTERPRETABLE, ERR_URL_UNREACHABLE, RESOURCES
 
Constructor Summary
MagicNumberRegistryEntry(java.lang.String name, java.lang.String[] exts, java.lang.String[] mimeTypes, int offset, byte[] magicNumber)
          Constructor, simplifies construction of entry when only one magic number is required.
MagicNumberRegistryEntry(java.lang.String name, java.lang.String[] exts, java.lang.String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers)
          Constructor
MagicNumberRegistryEntry(java.lang.String name, java.lang.String[] exts, java.lang.String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers, float priority)
          Constructor, allows for overriding the default priority of magic number entries.
MagicNumberRegistryEntry(java.lang.String name, java.lang.String ext, java.lang.String mimeType, int offset, byte[] magicNumber)
          Constructor, simplifies construction of entry when only one extension and one magic number is required.
MagicNumberRegistryEntry(java.lang.String name, java.lang.String ext, java.lang.String mimeType, MagicNumberRegistryEntry.MagicNumber[] magicNumbers)
          Constructor, simplifies construction of entry when only one extension is required.
 
Method Summary
 int getReadlimit()
          Returns the maximume read ahead needed for all magic numbers.
 boolean isCompatibleStream(java.io.InputStream is)
          Check if the stream contains an image that can be handled by this format handler
 
Methods inherited from class org.apache.batik.ext.awt.image.spi.AbstractRegistryEntry
getFormatName, getMimeTypes, getPriority, getStandardExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.batik.ext.awt.image.spi.StreamRegistryEntry
handleStream
 
Methods inherited from interface org.apache.batik.ext.awt.image.spi.RegistryEntry
getFormatName, getMimeTypes, getPriority, getStandardExtensions
 

Field Detail

PRIORITY

public static final float PRIORITY
See Also:
Constant Field Values

magicNumbers

MagicNumberRegistryEntry.MagicNumber[] magicNumbers
The list of magic numbers associated with this entry

Constructor Detail

MagicNumberRegistryEntry

public MagicNumberRegistryEntry(java.lang.String name,
                                java.lang.String ext,
                                java.lang.String mimeType,
                                int offset,
                                byte[] magicNumber)
Constructor, simplifies construction of entry when only one extension and one magic number is required.


MagicNumberRegistryEntry

public MagicNumberRegistryEntry(java.lang.String name,
                                java.lang.String ext,
                                java.lang.String mimeType,
                                MagicNumberRegistryEntry.MagicNumber[] magicNumbers)
Constructor, simplifies construction of entry when only one extension is required.


MagicNumberRegistryEntry

public MagicNumberRegistryEntry(java.lang.String name,
                                java.lang.String[] exts,
                                java.lang.String[] mimeTypes,
                                int offset,
                                byte[] magicNumber)
Constructor, simplifies construction of entry when only one magic number is required.


MagicNumberRegistryEntry

public MagicNumberRegistryEntry(java.lang.String name,
                                java.lang.String[] exts,
                                java.lang.String[] mimeTypes,
                                MagicNumberRegistryEntry.MagicNumber[] magicNumbers)
Constructor


MagicNumberRegistryEntry

public MagicNumberRegistryEntry(java.lang.String name,
                                java.lang.String[] exts,
                                java.lang.String[] mimeTypes,
                                MagicNumberRegistryEntry.MagicNumber[] magicNumbers,
                                float priority)
Constructor, allows for overriding the default priority of magic number entries. This should be needed very rarely since magic number checks are fairly relyable and hence aren't usually sensative to order issues.

Method Detail

getReadlimit

public int getReadlimit()
Returns the maximume read ahead needed for all magic numbers.

Specified by:
getReadlimit in interface StreamRegistryEntry

isCompatibleStream

public boolean isCompatibleStream(java.io.InputStream is)
                           throws java.io.StreamCorruptedException
Check if the stream contains an image that can be handled by this format handler

Specified by:
isCompatibleStream in interface StreamRegistryEntry