|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.MIME.ExhibitMIME
public final class ExhibitMIME
Routines to establish/check exhibit MIME types. This is hard-wired into the Gallery for now; we don't allow dynamic loading of new types and handlers...
This is a rewrite and extension of the old (pre-PG2K) PG Attributes class.
| Nested Class Summary | |
|---|---|
static class |
ExhibitMIME.ExhibitTypeParameters
JavaBean outlining file details of one Gallery exhibit item type. |
| Field Summary | |
|---|---|
private static java.util.Hashtable<java.lang.String,ExhibitMIME.ExhibitTypeParameters> |
_gET_cache
Private cache of mappings from extension to parameters. |
private static ExhibitMIME.ExhibitTypeParameters[] |
_gFPBT_cache
Private cache of mappings from type to parameters. |
private static java.util.Hashtable<java.lang.String,ExhibitMIME.ExhibitTypeParameters> |
_iVIFE_cache
Private cache of mappings from extension to parameters. |
static java.lang.String |
DEFAULT_HANDLER_PACKAGE
Package for default media handlers. |
static int |
ET__max
Maximum valid ET_XXX value (these values may be sparse). |
static int |
ET__min
Minimum valid ET_XXX value (these values may be sparse). |
static int |
ET_3GP
Type of 3GPP file. |
static int |
ET_AU
Type of Sun audio (usually 64kbps 8-bit u-law G.711) file. |
static int |
ET_AVI
Type of RealMedia file. |
static int |
ET_BMP
Type of BMP image file. |
static int |
ET_GIF
Type of GIF file. |
static int |
ET_HTMLFRAG
Type of HTML text fragment file. |
static int |
ET_JP2
Type of JPEG-2000 image file. |
static int |
ET_JPEG
Type of JPEG file. |
static int |
ET_MIDI
Type of General MIDI audio file. |
static int |
ET_MNG
Type of MNG (GIF-replacement) file. |
static int |
ET_MOV
Type of QuickTime movie file. |
static int |
ET_MP2
Type of MPEG-1 Layer-II audio file. |
static int |
ET_MP3
Type of MPEG-1 or MPEG-2 or MPEG-2.5 Layer-III audio file (8kbps and up). |
static int |
ET_MP4
Type of MPEG-4 audio file (2kbps and up). |
static int |
ET_MPEG
Type of MPEG video file. |
static int |
ET_PDF
Type of PDF file. |
static int |
ET_PNG
Type of PNG (GIF-replacement) file. |
static int |
ET_PPT
Type of PowerPoint presentation file. |
static int |
ET_RM
Type of RealMedia file. |
static int |
ET_RTF
Type of Windows Rich Text Format file. |
static int |
ET_SWF
Type of Flash file. |
static int |
ET_TBZ2
Type of BZIP2ed tar archive file. |
static int |
ET_TGZ
Type of GZIPped tar archive file. |
static int |
ET_TIFF
Type of TIFF image file. |
static int |
ET_TRML
Type of Gallery 'trail' marked-up text file. |
static int |
ET_WAV
Type of WAV audio file. |
static int |
ET_WMV
Type of Windows Movie file. |
static int |
ET_ZIP
Type of ZIP archive file. |
private static ExhibitMIME.ExhibitTypeParameters[] |
inputFileTypes
File types accepted by (and generated by) the Gallery. |
private static int |
longestMagicBytes
The longest known magic number in bytes of any exhibit type supported; strictly positive once computed. |
| Constructor Summary | |
|---|---|
ExhibitMIME()
|
|
| Method Summary | |
|---|---|
static void |
checkMagicOK(ExhibitMIME.ExhibitTypeParameters etp,
java.io.File file)
Checks that file has expected magic number; throws IOException if not. |
static ExhibitMIME.ExhibitTypeParameters[] |
getAllValidExhibitTypes()
Returns a (private) list of all valid exhibit types, in order by type. |
static ExhibitMIME.ExhibitTypeParameters |
getExhibitType(java.lang.String extension)
Gets type of an exhibit given its extension. |
static ExhibitMIME.ExhibitTypeParameters |
getInputFileType(java.lang.CharSequence name)
Gets the type of a file from its name, or null if unrecognised here. |
static int |
getLongestMagicBytes()
Get longest known magic number in bytes of any exhibit type supported; strictly positive. |
static java.lang.String |
getMIMEType(java.lang.CharSequence name)
Get the MIME type of an exhibit (even at the end of filename or URI or URL) from its name; never null nor "". |
static ExhibitMIME.ExhibitTypeParameters |
getParamsByType(int type)
Given an ET_XXX type, returns the ExhibitTypeParameters. |
static ExhibitMIME.ExhibitTypeParameters |
guessTypeFromMagic(java.io.InputStream is)
Guesses the type of a file/exhibit from its magic number, or null if unrecognisable. |
static ExhibitMIME.ExhibitTypeParameters |
isValidInputExhibitNameExtension(java.lang.CharSequence extension)
Checks if the extension of the (putative) exhibit name is a recognised input extension. |
static boolean |
magicOK(ExhibitMIME.ExhibitTypeParameters etp,
java.io.InputStream exhibitByteStream)
Verifies the magic number for a given exhibit. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_HANDLER_PACKAGE
public static final int ET_GIF
public static final int ET_JPEG
public static final int ET_AU
public static final int ET_MP2
public static final int ET_MP3
public static final int ET_MP4
public static final int ET_MIDI
public static final int ET_WAV
public static final int ET_HTMLFRAG
public static final int ET_MPEG
public static final int ET_TIFF
public static final int ET_BMP
public static final int ET_PPT
public static final int ET_RM
public static final int ET_AVI
public static final int ET_PNG
public static final int ET_MNG
public static final int ET_JP2
public static final int ET_SWF
public static final int ET_PDF
public static final int ET_3GP
public static final int ET_WMV
public static final int ET_RTF
public static final int ET_TRML
public static final int ET_ZIP
public static final int ET_TGZ
public static final int ET_TBZ2
public static final int ET_MOV
public static final int ET__min
public static final int ET__max
private static final ExhibitMIME.ExhibitTypeParameters[] inputFileTypes
private static final java.util.Hashtable<java.lang.String,ExhibitMIME.ExhibitTypeParameters> _iVIFE_cache
Fixed small size.
private static final java.util.Hashtable<java.lang.String,ExhibitMIME.ExhibitTypeParameters> _gET_cache
Fixed small size.
private static volatile int longestMagicBytes
Computed on first use.
private static ExhibitMIME.ExhibitTypeParameters[] _gFPBT_cache
Fixed small size.
| Constructor Detail |
|---|
public ExhibitMIME()
| Method Detail |
|---|
public static ExhibitMIME.ExhibitTypeParameters[] getAllValidExhibitTypes()
public static ExhibitMIME.ExhibitTypeParameters isValidInputExhibitNameExtension(java.lang.CharSequence extension)
This returns null if the extension is not recognised, else the (immutable) ExhibitTypeParameters describing it.
public static ExhibitMIME.ExhibitTypeParameters getExhibitType(java.lang.String extension)
This returns null if the extension is not recognised, else the (immutable) ExhibitTypeParameters describing the exhibit type.
This checks first by the primary suffix for each exhibit type, but if that fails may check by secondary suffix.
public static boolean magicOK(ExhibitMIME.ExhibitTypeParameters etp,
java.io.InputStream exhibitByteStream)
Returns false if the magic number check fails.
If the file type specified has no unique magic number to be checked this always succeeds.
This function does not close the input stream.
etp - is the exhibit type (must not be null)exhibitByteStream - is a stream of bytes from the
start of the exhibit at least long enough to contain the
magic number
public static void checkMagicOK(ExhibitMIME.ExhibitTypeParameters etp,
java.io.File file)
throws java.io.IOException,
java.io.InvalidObjectException
java.io.InvalidObjectException - if given file does not have
a correct magic number
java.io.IOException - in case of difficulty reading the filepublic static int getLongestMagicBytes()
public static ExhibitMIME.ExhibitTypeParameters guessTypeFromMagic(java.io.InputStream is)
throws java.io.IOException
The stream may need to be markable to allow various possibilities to be tested.
java.io.IOExceptionpublic static ExhibitMIME.ExhibitTypeParameters getInputFileType(java.lang.CharSequence name)
This returns null if the extension is not recognised for an exhibit, else returns the (immutable) ExhibitTypeParameters describing it.
The extension should be for an exhibit input, though this can be called to quickly check if a filename or URI might be for an exhibit, returning null if not.
name - name of file or URL/URIpublic static ExhibitMIME.ExhibitTypeParameters getParamsByType(int type)
public static java.lang.String getMIMEType(java.lang.CharSequence name)
throws java.io.IOException
java.io.IOException
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||