eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MIMETypes':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: MIMETypes


Inheritance:

   Object
   |
   +--MIMETypes

Package:
stx:libview2
Category:
Net-Communication-Support
Version:
rev: 1.170 date: 2018/05/12 12:23:45
user: cg
file: MIMETypes.st directory: libview2
module: stx stc-classLibrary: libview2
Author:
Claus Gittinger

Description:


just a place to keep MIME information
(avoid spreading things at many places)

MIMETypes is abstract and functional.
Actually, in some OperatingSystems, this information may
be found in some config files (or registries).
Therefore, this class may have to be extended to support this
and fetch the information from there eventually.


Class protocol:

initialization
o  addMimeTypeDetector: aMimeTypeFromContentsDetectorBlock
any class (especially: image readers) may add a block
that detects the MIME type from a given content.
The block is called with two arguments, some data (usually the first few kilobytes
of a file) and the suffix of the file, or nil if unknown.
The block should return the MIME type or nil.

o  initialize
initialize wellKnown facts
usage example(s):
must be initialized first
usage example(s):
     self initialize

o  initializeCommentStringMappings
these are used by the editor's comment/uncomment functions

o  initializeDefaultCommands
these are used to select an application to be opened when a file of a particular
type is double clicked in the browser.
TODO: move this to OS
usage example(s):
     self initializeDefaultCommands

o  initializeFileInfoMappings
these are used by the file browser if a 'file' command is not present in the OS
usage example(s):
     self initializeFileInfoMappings
     'foo.H' asFilename mimeTypeFromName
     'foo.o' asFilename mimeTypeFromName

o  initializeFileNameToMimeTypeMapping
initialize wellKnown facts
usage example(s):
     self initializeFileNameToMimeTypeMapping

o  initializeImageReaderMappings
these are used so select an image reader, based on a bitmap image's MIME type

o  initializeParenthesisSpecMappings
these are used by the editors to mark matching parentheses

initialization-lists
o  applicationCompressorsAndArchiveTypeList
compressor applications

o  applicationMiscTypeList
misc applications

o  applicationProgLangTypeList
applications for programming languages

o  applicationTextTypeList
text applications

o  applicationTypeList
applications

o  audioTypeList
audio formats ...

o  imageTypeList
wellknown image formats ...

o  miscFilenameList
other formats (not by suffix, but by fileName instead) ...

o  osSpecificTypeList
self osSpecificTypeList

o  textTypeList
misc text ...

o  unixSpecificTypeList
the first column is a list of extensions, the second the more-or-less official MIME type

o  videoTypeList
video formats ...

o  windowsSpecificTypeList
the first column is a list of extensions, the second the more-or-less official MIME type

obsolete
o  defaultCommandForMimeType: mimeType
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf'


** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  fontForCharset: aCharSetName
return the font-encoding for an iso-charset

** This is an obsolete interface - do not use it (it may vanish in future versions) **

queries
o  defineImageType: mimeType suffix: aSuffix reader: aReaderClass
register an image reader.

o  defineImageType: mimeType suffix: aSuffix reader: aReaderClass info: info
register an image reader.

o  fileInfoForMimeType: mimeType
given a mimeType, return an info string similar to what the unix 'file' command
provides. This info here is returned by systems which have no file (i.e. MSDOS) and
for types of which file does not know about (smalltalk files, for example)
usage example(s):
     self fileInfoForMimeType:(MIMEType fromString:'text/html')
     self fileInfoForMimeType:(MIMEType fromString:'image/gif')

o  fileSuffixToImageReaderMapping
return the suffix-to-imageReader mapping

o  imageFileSuffixes
return a collection with known file suffixes

o  mimeTypeForFilename: filenameOrString
given a filename, return the MIME type or nil if unknown
usage example(s):
     MIMETypes mimeTypeForFilename:'typeinst.dvi'
     MIMETypes mimeTypeForFilename:'foo.tar'
     MIMETypes mimeTypeForFilename:'foo.tgz'
     MIMETypes mimeTypeForFilename:'foo.tar.gz'
     MIMETypes mimeTypeForFilename:'foo.txt'
     MIMETypes mimeTypeForFilename:'foo.pkg'
     MIMETypes mimeTypeForFilename:'foo.sm'
     MIMETypes mimeTypeForFilename:'/Users/cg/work/stx/goodies/bitmaps/tiffimages/moreSamples/multi-channel.ome.tif'
     MIMETypes mimeTypeForFilename:'multi-channel.ome.tif'
     MIMETypes mimeTypeForFilename:'multi-channel.tif'

o  mimeTypeForFilename: filename put: mimeType
register a MIME type for a filename

o  mimeTypeForSuffix: suffix
given a file suffix, return the MIME type
usage example(s):
     self mimeTypeForSuffix:'gif'
     self mimeTypeForSuffix:'rpm'
     self mimeTypeForSuffix:'zip'

o  mimeTypeForSuffix: suffix put: mimeType
register a MIME type for a file suffix

o  mimeTypeForSuffixMapping

o  mimeTypeFromString: mimeTypeString
given a MIME type for a string
usage example(s):
     MIMETypes mimeTypeFromString:'text/html'
     MIMETypes mimeTypeFromString:'image/gif'
     MIMETypes mimeTypeFromString:'application/x-expecco-testsuite'

o  mimeTypeOfContents: filename
given a filename, scan the contents, return the MIME type or nil, if unknown

o  mimeTypeOfData: someData
this tries to guess the MIME type of contents of someData.
Returns nil if unknown.
This is done using some heuristics, and may need some improvement

o  mimeTypeOfData: someData suffix: fileNameSuffixOrNilIfUnknown
this tries to guess the MIME type of someData.
Returns nil if unknown.
In addition to registered detectors (see addMimeTypeDetector:),
this is done using heuristics, and may need some improvement

o  suffixForMimeType: mimeType
given a file suffix, return the MIME type
usage example(s):
     self suffixForMimeType:(MIMEType fromString:'image/gif')

o  suffixForMimeTypeString: mimeTypeString
given a file suffix, return the MIME type
usage example(s):
     self suffixForMimeTypeString:'image/gif'

o  typeToInfoMapping

queries-applications
o  defaultCommandPerMIME
returns the collection which is used to map MIME type to command-templates.
usage example(s):
     MIMETypes defaultCommandPerMIME

o  defaultCommandTemplateToOpenMimeType: mimeType
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf'
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html'

o  defaultCommandTemplateToPrintMimeType: mimeType
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf'

o  defaultPrintCommandPerMIME
returns the collection which is used to map MIME type to printing command-templates.

queries-image formats
o  imageReaderClasses
return a collection of registered image reader classes

o  imageReaderForSuffix: aSuffix
given a file suffix, return an appropriate image reader class
usage example(s):
     self imageReaderForSuffix:'wbmp'

o  imageReaderForSuffix: aSuffix put: aReaderClass
register an image reader for a file suffix

o  imageReaderForType: mimeTypeString
given a MIME type, return an appropriate image reader class

o  imageReaderForType: mimeTypeString put: aReaderClass
register an image reader for a MIME type

queries-language syntax
o  commentStringsForFilename: aFilenameOrString
return a useful comment definition; heuristics for now.
The returned value is an array of 2 elements;
the first is the end-of-line comment string (or nil);
the second an array of opening/closing delimiters (or an array of nils)
usage example(s):
     MIMETypes commentStringsForFilename:'Makefile'.
     MIMETypes commentStringsForFilename:'Object.st'.
     MIMETypes commentStringsForFilename:'Foo.java'.
     MIMETypes commentStringsForFilename:'Foo.html'.

o  commentStringsForFilename: aFilename ifUnknown: alternativeBlockReturningCommentString
return a useful comment definition; heuristics for now.
The returned value is an array of 2 elements;
the first is the end-of-line comment string (or nil);
the second an array of opening/closing delimiters (or an array of nils)
usage example(s):
     MIMETypes commentStringsForFilename:'Makefile'.
     MIMETypes commentStringsForFilename:'Object.st'.
     MIMETypes commentStringsForFilename:'Foo.java'.

o  commentStringsForMimeType: mime suffix: suff
return a useful comment definition; heuristics for now.
The returned value is an array of 2 elements;
the first is the end-of-line comment string (or nil);
the second an array of opening/closing delimiters (or an array of nils)

o  commentStringsForMimeType: mime suffix: suff ifUnknown: alternativeBlockReturningCommentString
return a useful comment definition; heuristics for now.
The returned value is an array of 2 elements;
the first is the end-of-line comment string (or nil);
the second an array of opening/closing delimiters (or an array of nils)

o  parenthesisSpecForFilename: aFilename
return a useful parentesis spec; heuristics for now.
The returned value is a dictionary to be used as parentesis spec in an editor
usage example(s):
     MIMETypes parenthesisSpecForFilename:'Object.st'.
     MIMETypes parenthesisSpecForFilename:'Foo.java'.
     MIMETypes parenthesisSpecForFilename:'Foo.html'.
     MIMETypes parenthesisSpecForFilename:'Foo.lsp'.

o  parenthesisSpecForFilename: aFilename ifUnknown: alternative

o  parenthesisSpecForMimeType: mime suffix: suff

o  parenthesisSpecForMimeType: mime suffix: suff ifUnknown: alternativeValue


Private classes:

    MIMEType

Examples:


    MIMETypes mimeTypeFromString:'text/plain'
    MIMETypes mimeTypeFromString:'application/x-expecco-testsuite'
    MIMETypes mimeTypeForSuffix:'gif'
    MIMETypes mimeTypeForSuffix:'ets'
    MIMETypes mimeTypeForSuffix:'xlsx'


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 03:02:08 GMT