|
Class: MIMETypes
Object
|
+--MIMETypes
- Package:
- stx:libview2
- Category:
- Net-Communication-Support
- Version:
- rev:
1.224
date: 2024/04/12 17:40:28
- user: stefan
- file: MIMETypes.st directory: libview2
- module: stx stc-classLibrary: libview2
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.
copyrightCOPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
knownTypessimply a reminder for me ...
application mime file extentsions
powerpoint application/ms-powerpoint .pot, .ppz, .ppt, .pps,
application/mspowerpoint
application/vnd.ms-powerpoint
application/x-mspowerpoint
shockwave application/x-shockwave-flash .swf
futuresplash application/futuresplash .spl
initialization
-
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.
-
defineImageType: mimeType suffix: aSuffix reader: aReaderClass
-
register an image reader.
-
defineImageType: mimeType suffix: aSuffix reader: aReaderClass info: info
-
register an image reader.
-
initialize
-
initialize wellKnown facts
Usage example(s):
-
initializeAudioReaderMappings
-
these are used so select an audio reader, based on a file's MIME type
-
initializeCommentStringMappings
-
these are used by the editor's comment/uncomment functions
-
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
|
-
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
'foo.py' asFilename mimeTypeFromName
|
-
initializeFileNameToMimeTypeMapping
-
initialize wellKnown facts
Usage example(s):
self initializeFileNameToMimeTypeMapping
|
-
initializeImageReaderMappings
-
these are used so select an image reader, based on a bitmap image's MIME type
-
initializeParenthesisSpecMappings
-
these are used by the editors to mark matching parentheses
-
mimeTypeForFilename: filename put: mimeType
-
register a MIME type for a filename
-
mimeTypeForSuffix: suffix put: mimeType
-
register a MIME type for a file suffix
initialization-lists
-
applicationCompressorsAndArchiveTypeList
-
compressor applications
-
applicationMiscTypeList
-
misc applications
-
applicationProgLangTypeList
-
applications for programming languages
-
applicationTextTypeList
-
text applications
-
applicationTypeList
-
applications
-
audioTypeList
-
audio formats ...
-
imageTypeList
-
wellknown image formats ...
-
miscFilenameList
-
other formats (not by suffix, but by fileName instead) ...
-
osSpecificTypeList
-
self osSpecificTypeList
-
osxSpecificTypeList
-
the first column is a list of extensions, the second the more-or-less official MIME type
-
textTypeList
-
misc text ...
-
unixSpecificTypeList
-
the first column is a list of extensions, the second the more-or-less official MIME type
-
videoTypeList
-
video formats ...
-
windowsSpecificTypeList
-
the first column is a list of extensions, the second the more-or-less official MIME type
obsolete
-
defaultCommandForMimeType: mimeType
-
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf'
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
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
-
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')
|
-
fileSuffixToImageReaderMapping
-
return the suffix-to-imageReader mapping
-
imageFileSuffixes
-
return a collection with known file suffixes
-
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:'foo.cbl'
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'
Time microsecondsToRun:[ MIMETypes mimeTypeForFilename:'orders.edi' ]
MIMETypes mimeTypeForFilename:'orders.edi'
|
-
mimeTypeForSuffix: suffix
-
given a file suffix, return the MIME type
Usage example(s):
self mimeTypeForSuffix:'gif'
self mimeTypeForSuffix:'rpm'
self mimeTypeForSuffix:'zip'
self mimeTypeForSuffix:'py'
self mimeTypeForSuffix:'svg'
|
-
mimeTypeForSuffixMapping
-
-
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'
|
-
mimeTypeOfContents: filename
-
given a filename, scan the contents, return the MIME type or nil, if unknown
-
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
-
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
-
suffixForMimeType: mimeType
-
given a file suffix, return the MIME type
Usage example(s):
self suffixForMimeType:(MIMEType fromString:'image/gif')
|
-
suffixForMimeTypeString: mimeTypeString
-
given a file suffix, return the MIME type
Usage example(s):
self suffixForMimeTypeString:'image/gif'
|
-
typeToInfoMapping
-
queries-applications
-
defaultCommandPerMIME
-
returns the collection which is used to map MIME type to command-templates.
Usage example(s):
MIMETypes defaultCommandPerMIME
|
-
defaultCommandTemplateToOpenMimeType: mimeType
-
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf'
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html'
-
defaultCommandTemplateToPrintMimeType: mimeType
-
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf'
-
defaultPrintCommandPerMIME
-
returns the collection which is used to map MIME type to printing command-templates.
queries-audio formats
-
audioReaderClasses
-
return a collection of registered audio reader classes
-
audioReaderForSuffix: aSuffix
-
given a file suffix, return an appropriate audio reader class
Usage example(s):
self audioReaderForSuffix:'wav'
self audioReaderForSuffix:'snd'
self audioReaderForSuffix:'aiff'
|
-
audioReaderForSuffix: aSuffix put: aReaderClass
-
register an audio reader for a file suffix
-
audioReaderForType: mimeTypeString
-
given a MIME type, return an appropriate audio reader class
-
audioReaderForType: mimeTypeString put: aReaderClass
-
register an audio reader for a MIME type
queries-image formats
-
imageReaderClasses
-
return a collection of registered image reader classes
-
imageReaderForSuffix: aSuffix
-
given a file suffix, return an appropriate image reader class
Usage example(s):
self imageReaderForSuffix:'wbmp'
|
-
imageReaderForSuffix: aSuffix put: aReaderClass
-
register an image reader for a file suffix
-
imageReaderForType: mimeTypeString
-
given a MIME type, return an appropriate image reader class
-
imageReaderForType: mimeTypeString put: aReaderClass
-
register an image reader for a MIME type
queries-language syntax
-
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'.
|
-
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'.
|
-
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)
Usage example(s):
|mime|
mime := MIMETypes mimeTypeForFilename:'Makefile'.
MIMETypes commentStringsForMimeType:mime suffix:nil.
|
Usage example(s):
|mime|
mime := MIMETypes mimeTypeForFilename:'Object.st'.
MIMETypes commentStringsForMimeType:mime suffix:nil.
|
-
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)
Usage example(s):
|mime|
mime := MIMETypes mimeTypeForFilename:'Makefile'.
MIMETypes commentStringsForMimeType:mime suffix:nil.
|
Usage example(s):
|mime|
mime := MIMETypes mimeTypeForFilename:'Object.st'.
MIMETypes commentStringsForMimeType:mime suffix:nil.
|
-
parenthesisSpecForFilename: aFilename
-
return a useful parenthesis spec; heuristics for now.
The returned value is a dictionary to be used as parenthesis spec in an editor
Usage example(s):
MIMETypes parenthesisSpecForFilename:'Object.st'.
MIMETypes parenthesisSpecForFilename:'Foo.java'.
MIMETypes parenthesisSpecForFilename:'Foo.html'.
MIMETypes parenthesisSpecForFilename:'Foo.lsp'.
MIMETypes parenthesisSpecForFilename:'Foo.py'.
MIMETypes parenthesisSpecForFilename:'Foo.bla'.
|
-
parenthesisSpecForFilename: aFilename ifUnknown: alternative
-
MIMETypes parenthesisSpecForFilename:'Foo.py' ifUnknown:#bad.
MIMETypes parenthesisSpecForFilename:'Foo.bla' ifUnknown:#bad.
MIMETypes parenthesisSpecForFilename:'Foo.scm' ifUnknown:#bad.
MIMETypes parenthesisSpecForFilename:'Foo.py' ifUnknown:#bad.
MIMETypes parenthesisSpecForFilename:'Foo.js' ifUnknown:#bad.
-
parenthesisSpecForMimeType: mime
-
|mime1 mime2|
mime1 := 'application/x-python-source' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime1.
mime1 := 'application/x-foobar' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime2.
-
parenthesisSpecForMimeType: mime ifUnknown: alternative
-
|mime1 mime2|
mime1 := 'application/x-python-source' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime1 ifUnknown:#bad.
mime1 := 'application/x-foobar' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime2 ifUnknown:#bad.
-
parenthesisSpecForMimeType: mime suffix: suff
-
-
parenthesisSpecForMimeType: mime suffix: suff ifUnknown: alternativeValue
-
basic fetcher; tries to find an entry either in the mime-types dict,
or the suffix dict.
Usage example(s):
|mime1 mime2|
mime1 := 'application/x-python-source' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime1 suffix:'bla' ifUnknown:#bad.
mime2 := 'application/x-foobar' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime2 suffix:'py' ifUnknown:#bad.
mime2 := 'application/x-foobar' asMimeType.
MIMETypes parenthesisSpecForMimeType:mime2 suffix:'bla' ifUnknown:#bad.
|
MIMEType
MIMETypes mimeTypeFromString:'text/plain'
|
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite'
|
MIMETypes mimeTypeForSuffix:'gif'
MIMETypes mimeTypeForSuffix:'ets'
MIMETypes mimeTypeForSuffix:'xlsx'
|
|