org.hd.d.pg2k.svrCore.MIME
Class ExhibitMIME.ExhibitTypeParameters

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.MIME.ExhibitMIME.ExhibitTypeParameters
All Implemented Interfaces:
java.lang.Comparable<ExhibitMIME.ExhibitTypeParameters>
Enclosing class:
ExhibitMIME

public static final class ExhibitMIME.ExhibitTypeParameters
extends java.lang.Object
implements java.lang.Comparable<ExhibitMIME.ExhibitTypeParameters>

JavaBean outlining file details of one Gallery exhibit item type. This object is immutable.

Not designed to be persisted, so not Serializable.

Note that this has no public no-arg constructor because these objects are all created statically and we create all the instances that should be created.

Note that this class is based on the assumption that we recognise exactly one filename suffix for each type of file archived in the Gallery, and when generating something of that type (usually) use one, different, suffix. Both suffixes are chose to be generally acceptable to most tools such as browsers.

These suffixes presented are intern()ed so that the number of copies of them kicking around can be reduced. Don't go casually making up lots of random filetypes...


Field Summary
 java.util.Set<java.lang.String> allMagics
          All legitimate `magic number' values for this type; never null.
 java.util.Set<java.lang.String> allSuffixesForFile
          All (dotless, lower-case) suffixes for this type, including the primary suffix; never null nor empty.
 java.lang.String description
          Textual (English) description of the file type.
 java.lang.String dotSuffixForInputFile
          Suffix of input file including leading dot; lower-case, never null.
 Handler handler
          Instance of handler class, or null if none.
 java.lang.String handlerClassName
          Fully-qualified name of handler class (implementing HandlerBase), or null if none.
 java.lang.String magic
          This is the primary `magic number' at the start of the file; never null though may be "".
 java.lang.String mimeType
          The canonical MIME type for this exhibit format; never null nor "".
 java.lang.String suffixForInputFile
          Suffix of file if this item is an exhibit in the Gallery; lower-case, never null.
 int type
          ET_XXX type of file.
 
Constructor Summary
private ExhibitMIME.ExhibitTypeParameters(int _type, java.lang.String _suffixForInputFile, java.lang.String[] _allSuffixes, java.lang.String _mimeType, java.lang.String _handlerClassName, java.lang.String _magic, java.lang.String[] _allMagics, java.lang.String _description)
          Make a new MIME type descriptor.
private ExhibitMIME.ExhibitTypeParameters(int _type, java.lang.String _suffixForInputFile, java.lang.String _mimeType, java.lang.String _handlerClassName, java.lang.String _magic, java.lang.String _description)
          Make a new MIME type descriptor.
 
Method Summary
 boolean canPossiblyCreateThumbnailOfSameMIMEType()
          Returns true if we may be able to create a thumbnail/sample with the same MIME type as this.
 int compareTo(ExhibitMIME.ExhibitTypeParameters o)
          Sort by type.
 boolean equals(java.lang.Object o)
          Equal if type is equal.
 int hashCode()
          Tested for equality and sorted on type.
 java.lang.String toString()
          Make meaningful human-readable diagnostic String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public final int type
ET_XXX type of file.


suffixForInputFile

public final java.lang.String suffixForInputFile
Suffix of file if this item is an exhibit in the Gallery; lower-case, never null. This means it is an input item, and should (for example) be read-only and never deleted.

This does not include the dot that comes before the extension.

This value is never null or zero-length, and is intern()ed.


dotSuffixForInputFile

public final java.lang.String dotSuffixForInputFile
Suffix of input file including leading dot; lower-case, never null. This is suffixForInputFile with a leading dot, and is intern()ed, so is never null and is not less than length 2.


allSuffixesForFile

public final java.util.Set<java.lang.String> allSuffixesForFile
All (dotless, lower-case) suffixes for this type, including the primary suffix; never null nor empty. We can recognise all these suffixes on input files as potentially indicating this MIME type.

No entries are null or "" or start with (or contain) a dot.

This is immutable.


magic

public final java.lang.String magic
This is the primary `magic number' at the start of the file; never null though may be "". This is really a byte string, in order, of the leading bytes we must see at the start of a file to be happy it is really the type the file suffix claims it is. If zero-length, this indicates that there is no such initial portion we can check.

This enables a simple form of file-type checking like the UNIX ``file'' utility.

This string may be zero-length, but it is never null.


allMagics

public final java.util.Set<java.lang.String> allMagics
All legitimate `magic number' values for this type; never null. Contains the primary magic value unless it is "".

No entries are null or "".

Is empty if no magic number.

This is immutable.


mimeType

public final java.lang.String mimeType
The canonical MIME type for this exhibit format; never null nor "". Of the form majorType/minorType eg "audio/basic" or "text/html", with all text lower-case.


handlerClassName

public final java.lang.String handlerClassName
Fully-qualified name of handler class (implementing HandlerBase), or null if none.


handler

public final Handler handler
Instance of handler class, or null if none.


description

public final java.lang.String description
Textual (English) description of the file type. This describes in human-readable terms what we expect the image to be (it may be that the file extension and magic number would allow a wider range than we describe here).

This is intended to be terse enough to go on a Web page with an image file if need be. It may be zero length, though must not be null.

Constructor Detail

ExhibitMIME.ExhibitTypeParameters

private ExhibitMIME.ExhibitTypeParameters(int _type,
                                          java.lang.String _suffixForInputFile,
                                          java.lang.String _mimeType,
                                          java.lang.String _handlerClassName,
                                          java.lang.String _magic,
                                          java.lang.String _description)
Make a new MIME type descriptor. Private constructor and object not (de)serialisable so as to ensure that only we can make instances here at run-time.

Parameters:
_handlerClassName - the fully-qualified class name of the handler for this MIME type; if null a default of DEFAULT_HANDLER_PACKAGE package with the class name the same as the primary (all-lower-case) suffix is used instead

ExhibitMIME.ExhibitTypeParameters

private ExhibitMIME.ExhibitTypeParameters(int _type,
                                          java.lang.String _suffixForInputFile,
                                          java.lang.String[] _allSuffixes,
                                          java.lang.String _mimeType,
                                          java.lang.String _handlerClassName,
                                          java.lang.String _magic,
                                          java.lang.String[] _allMagics,
                                          java.lang.String _description)
Make a new MIME type descriptor. Private constructor and object not (de)serialisable so as to ensure that only we can make instances here and at run-time.

Parameters:
_allSuffixes - null or a set of (dotless) extensions (possibly including the primary one) by which we may recognise input files of this type
_allMagics - null or a set of magix numbers/strings (possibly including the primary one if not "") by which we may recognise input files of this type
_handlerClassName - the fully-qualified class name of the handler for this MIME type; if null a default of DEFAULT_HANDLER_PACKAGE package with the class name the same as the primary (all-lower-case) suffix is used instead
Method Detail

toString

public java.lang.String toString()
Make meaningful human-readable diagnostic String representation. This is not intended to be machine-parsable, but does not contain whitespace if possible so it might be.

Overrides:
toString in class java.lang.Object
Returns:
human-readable indication of exhibit type.

hashCode

public int hashCode()
Tested for equality and sorted on type.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Equal if type is equal.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(ExhibitMIME.ExhibitTypeParameters o)
Sort by type.

Specified by:
compareTo in interface java.lang.Comparable<ExhibitMIME.ExhibitTypeParameters>

canPossiblyCreateThumbnailOfSameMIMEType

public boolean canPossiblyCreateThumbnailOfSameMIMEType()
Returns true if we may be able to create a thumbnail/sample with the same MIME type as this. We might fail in practice, but if this returns false we know that we definitely cannot make a thumbnail/sample for this exhibit type in the current execution context, eg without some loadable drivers.


DHD Multimedia Gallery V1.53.0

Copyright (c) 1996-2009, Damon Hart-Davis. All rights reserved.