Module io.sf.carte.echosvg.awt
Class MagicNumberRegistryEntry
java.lang.Object
io.sf.carte.echosvg.ext.awt.image.spi.AbstractRegistryEntry
io.sf.carte.echosvg.ext.awt.image.spi.MagicNumberRegistryEntry
- All Implemented Interfaces:
ErrorConstants
,RegistryEntry
,StreamRegistryEntry
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 compatibility 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
Modifier and TypeClassDescriptionstatic class
Inner class that represents one magic number. -
Field Summary
Fields inherited from interface io.sf.carte.echosvg.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
ConstructorDescriptionMagicNumberRegistryEntry
(String name, float priority, String[] exts, String[] mimeTypes, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one magic number is required.MagicNumberRegistryEntry
(String name, float priority, String[] exts, String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) ConstructorMagicNumberRegistryEntry
(String name, float priority, String ext, String mimeType, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one extension and one magic number is required.MagicNumberRegistryEntry
(String name, float priority, String ext, String mimeType, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor, simplifies construction of entry when only one extension is required.MagicNumberRegistryEntry
(String name, String[] exts, String[] mimeTypes, int offset, byte[] magicNumbers) Constructor, simplifies construction of entry when only one magic number is required.MagicNumberRegistryEntry
(String name, String[] exts, String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) ConstructorMagicNumberRegistryEntry
(String name, String[] exts, String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers, float priority) Constructor, allows for overriding the default priority of magic number entries.MagicNumberRegistryEntry
(String name, String ext, String mimeType, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one extension and one magic number is required.MagicNumberRegistryEntry
(String name, String ext, String mimeType, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor, simplifies construction of entry when only one extension is required. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the maximum read ahead needed for all magic numbers.boolean
Check if the stream contains an image that can be handled by this format handlerMethods inherited from class io.sf.carte.echosvg.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 io.sf.carte.echosvg.ext.awt.image.spi.RegistryEntry
getFormatName, getMimeTypes, getPriority, getStandardExtensions
Methods inherited from interface io.sf.carte.echosvg.ext.awt.image.spi.StreamRegistryEntry
handleStream
-
Field Details
-
PRIORITY
public static final float PRIORITY- See Also:
-
-
Constructor Details
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, float priority, String ext, String mimeType, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one extension and one magic number is required.- Parameters:
name
- Format Namepriority
- the priority of the RegistryEntryext
- Standard extensionmimeType
- the supported MIME typeoffset
- Offset of magic numbermagicNumber
- byte array to match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, String ext, String mimeType, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one extension and one magic number is required.- Parameters:
name
- Format Nameext
- Standard extensionmimeType
- the supported MIME typeoffset
- Offset of magic numbermagicNumber
- byte array to match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, float priority, String ext, String mimeType, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor, simplifies construction of entry when only one extension is required.- Parameters:
name
- Format Namepriority
- the priority of the RegistryEntryext
- Standard extensionmimeType
- the supported MIME typemagicNumbers
- Array of magic numbers any of which can match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, String ext, String mimeType, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor, simplifies construction of entry when only one extension is required.- Parameters:
name
- Format Nameext
- Standard extensionmimeType
- the supported MIME typemagicNumbers
- Array of magic numbers any of which can match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, float priority, String[] exts, String[] mimeTypes, int offset, byte[] magicNumber) Constructor, simplifies construction of entry when only one magic number is required.- Parameters:
name
- Format Namepriority
- the priority of the RegistryEntryexts
- Standard set of extensionsmimeTypes
- array of supported MIME typesoffset
- Offset of magic numbermagicNumber
- byte array to match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, String[] exts, String[] mimeTypes, int offset, byte[] magicNumbers) Constructor, simplifies construction of entry when only one magic number is required.- Parameters:
name
- Format Nameexts
- Standard set of extensionsmimeTypes
- array of supported MIME typesoffset
- Offset of magic numbermagicNumbers
- byte array to match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, float priority, String[] exts, String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor- Parameters:
name
- Format Namepriority
- the priority of the RegistryEntryexts
- Standard set of extensionsmimeTypes
- array of supported MIME typesmagicNumbers
- array of magic numbers any of which can match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, String[] exts, String[] mimeTypes, MagicNumberRegistryEntry.MagicNumber[] magicNumbers) Constructor- Parameters:
name
- Format Nameexts
- Standard set of extensionsmimeTypes
- array of supported MIME typesmagicNumbers
- array of magic numbers any of which can match.
-
MagicNumberRegistryEntry
public MagicNumberRegistryEntry(String name, String[] exts, 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.- Parameters:
name
- Format Nameexts
- Standard set of extensionsmagicNumbers
- array of magic numbers any of which can match.priority
- The priority of this entry (1000 is baseline)
-
-
Method Details
-
getReadlimit
public int getReadlimit()Returns the maximum read ahead needed for all magic numbers.- Specified by:
getReadlimit
in interfaceStreamRegistryEntry
-
isCompatibleStream
Check if the stream contains an image that can be handled by this format handler- Specified by:
isCompatibleStream
in interfaceStreamRegistryEntry
- Throws:
StreamCorruptedException
-