"
COPYRIGHT (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.
"
Object subclass:#MIMETypes
instanceVariableNames:''
classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
FileSuffixToImageReaderClassMapping CharSetToFontMapping'
poolDictionaries:''
category:'System-Documentation'
!
!MIMETypes class methodsFor:'documentation'!
copyright
"
COPYRIGHT (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.
"
!
documentation
"
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.
[author:]
Claus Gittinger
"
! !
!MIMETypes class methodsFor:'initialization'!
initialize
"initialize wellKnown facts"
|typeToImageReaderClassMapping fileSuffixToTypeMapping
fileSuffixToImageReaderClassMapping charSetToFontMapping|
"/ image formats.
(typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
].
typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
typeToImageReaderClassMapping at:'image/gif' put:GIFReader.
typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
(fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
].
fileSuffixToTypeMapping at:'jpg' put:'image/jpeg'.
fileSuffixToTypeMapping at:'gif' put:'image/gif'.
fileSuffixToTypeMapping at:'tif' put:'image/tiff'.
fileSuffixToTypeMapping at:'xbm' put:'image/x-xbitmap'.
fileSuffixToTypeMapping at:'xpm' put:'image/x-xpixmap'.
fileSuffixToTypeMapping at:'png' put:'image/x-png'.
fileSuffixToTypeMapping at:'pcd' put:'image/x-photo-cd'.
fileSuffixToTypeMapping at:'bmp' put:'image/x-MS-bmp'.
fileSuffixToTypeMapping at:'rgb' put:'image/x-rgb'.
fileSuffixToTypeMapping at:'ppm' put:'image/x-portable-pixmap'.
fileSuffixToTypeMapping at:'pgm' put:'image/x-portable-graymap'.
fileSuffixToTypeMapping at:'pbm' put:'image/x-portable-bitmap'.
fileSuffixToTypeMapping at:'pnm' put:'image/x-portable-anymap'.
fileSuffixToTypeMapping at:'xwd' put:'image/x-xwindowdump'.
fileSuffixToTypeMapping at:'ras' put:'image/x-cmu-raster'.
fileSuffixToTypeMapping at:'htm' put:'text/html'.
fileSuffixToTypeMapping at:'html' put:'text/html'.
fileSuffixToTypeMapping at:'ps' put:'application/postscript'.
fileSuffixToTypeMapping at:'pdf' put:'application/pdf'.
fileSuffixToTypeMapping at:'rtf' put:'application/rtf'.
fileSuffixToTypeMapping at:'htm' put:'text/html'.
fileSuffixToTypeMapping at:'html' put:'text/html'.
fileSuffixToTypeMapping at:'txt' put:'text/plain'.
fileSuffixToTypeMapping at:'text' put:'text/plain'.
fileSuffixToTypeMapping at:'movie' put:'video/x-sgi-movie'.
fileSuffixToTypeMapping at:'avi' put:'video/x-msvideo'.
fileSuffixToTypeMapping at:'qt' put:'video/quicktime'.
fileSuffixToTypeMapping at:'mov' put:'video/quicktime'.
fileSuffixToTypeMapping at:'moov' put:'video/quicktime'.
fileSuffixToTypeMapping at:'mpv2' put:'video/x-mpeg2'.
fileSuffixToTypeMapping at:'mpv' put:'video/mpeg'.
fileSuffixToTypeMapping at:'mpegv' put:'video/mpeg'.
fileSuffixToTypeMapping at:'mpg' put:'video/mpeg'.
fileSuffixToTypeMapping at:'mpeg' put:'video/mpeg'.
fileSuffixToTypeMapping at:'ra' put:'audio/x-pn-realaudio'.
fileSuffixToTypeMapping at:'mpa' put:'audio/x-mpeg'.
fileSuffixToTypeMapping at:'mpega' put:'audio/x-mpeg'.
fileSuffixToTypeMapping at:'wav' put:'audio/x-wav'.
fileSuffixToTypeMapping at:'aif' put:'audio/x-aiff'.
fileSuffixToTypeMapping at:'aiff' put:'audio/x-aiff'.
fileSuffixToTypeMapping at:'aifc' put:'audio/x-aiff'.
fileSuffixToTypeMapping at:'au' put:'audio/basic'.
fileSuffixToTypeMapping at:'snd' put:'audio/basic'.
(fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
].
fileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader.
fileSuffixToImageReaderClassMapping at:'gif' put:GIFReader.
fileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader.
"/ misc stuff
fileSuffixToTypeMapping at:'st' put:'application/x-smalltalk-source'.
fileSuffixToTypeMapping at:'js' put:'application/x-javascript'.
fileSuffixToTypeMapping at:'tar' put:'application/x-tar'.
fileSuffixToTypeMapping at:'tgz' put:'application/x-tar-compressed'.
fileSuffixToTypeMapping at:'zip' put:'application/x-zip-compressed'.
fileSuffixToTypeMapping at:'sh' put:'application/x-sh'.
fileSuffixToTypeMapping at:'tcl' put:'application/x-tcl'.
fileSuffixToTypeMapping at:'pl' put:'application/x-perl'.
"/ character sets (not really mime stuff, but also placed here)
(charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
CharSetToFontMapping := charSetToFontMapping := Dictionary new
].
charSetToFontMapping at:'iso2022-jp' put:'jis*0208*'.
charSetToFontMapping at:'x-iso2022-jp' put:'jis*0208*'.
charSetToFontMapping at:'x-euc-jp' put:'jis*0208*'.
charSetToFontMapping at:'x-shift-jis' put:'jis*0208*'.
charSetToFontMapping at:'x-sjis' put:'jis*0208*'.
charSetToFontMapping at:'x-jis7' put:'jis*0208*'.
charSetToFontMapping at:'jis7' put:'jis*0208*'.
charSetToFontMapping at:'euc' put:'jis*0208*'.
charSetToFontMapping at:'euc-jp' put:'jis*0208*'.
charSetToFontMapping at:'sjis' put:'jis*0208*'.
charSetToFontMapping at:'big5' put:'big5*'.
charSetToFontMapping at:'gb2312' put:'gb*'.
charSetToFontMapping at:'hz-gb-2312' put:'gb*'.
charSetToFontMapping at:'x-gbk' put:'gb*'.
charSetToFontMapping at:'iso2022-kr' put:'ksc*'.
charSetToFontMapping at:'x-euc-kr' put:'ksc*'.
"
self initialize
"
"Modified: / 1.8.1998 / 17:50:57 / cg"
! !
!MIMETypes class methodsFor:'accessing'!
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
"register an image reader."
aSuffix notNil ifTrue:[
self imageReaderForSuffix:aSuffix put:aReaderClass.
].
mimeType notNil ifTrue:[
self imageReaderForType:mimeType put:aReaderClass
].
(aSuffix notNil and:[mimeType notNil]) ifTrue:[
self mimeTypeForSuffix:aSuffix put:mimeType
].
!
fileSuffixToImageReaderMapping
"return the suffix-to-imageReader mapping"
^ FileSuffixToImageReaderClassMapping ? #()
"Modified: / 1.8.1998 / 17:00:11 / cg"
!
fontForCharset:aCharSet
"return the font-encoding for an iso-charset"
^ CharSetToFontMapping at:aCharSet ifAbsent:nil
"
MIMETypes fontForCharset:'iso2022-jp'
MIMETypes fontForCharset:'euc-jp'
"
"Modified: / 1.8.1998 / 17:00:57 / cg"
!
imageFileSuffixes
"return a collection with known file suffixes"
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
^ FileSuffixToImageReaderClassMapping keys
"Created: / 30.6.1997 / 22:04:48 / cg"
"Modified: / 1.8.1998 / 17:01:26 / cg"
!
imageReaderClasses
"return a collection of registered image reader classes"
|setOfClasses|
setOfClasses := IdentitySet new.
FileSuffixToImageReaderClassMapping notNil ifTrue:[
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
setOfClasses add:cls
].
].
TypeToImageReaderClassMapping notNil ifTrue:[
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
setOfClasses add:cls
].
].
^ setOfClasses
"Created: / 30.6.1997 / 22:03:42 / cg"
"Modified: / 1.8.1998 / 16:59:52 / cg"
!
imageReaderForSuffix:aSuffix
"given a file suffix, return an approriate image reader class"
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
"Created: / 30.6.1997 / 21:59:11 / cg"
"Modified: / 1.8.1998 / 17:01:58 / cg"
!
imageReaderForSuffix:aSuffix put:aReaderClass
"register an image reader for a file suffix"
FileSuffixToImageReaderClassMapping isNil ifTrue:[
FileSuffixToImageReaderClassMapping := Dictionary new.
].
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
"Created: / 30.6.1997 / 21:59:43 / cg"
"Modified: / 1.8.1998 / 17:02:14 / cg"
!
imageReaderForType:mimeTypeString
"given a mime-type, return an approriate image reader class"
TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
"Created: / 30.6.1997 / 21:56:01 / cg"
"Modified: / 1.8.1998 / 17:02:28 / cg"
!
imageReaderForType:mimeTypeString put:aReaderClass
"register an image reader for a mime-type"
TypeToImageReaderClassMapping isNil ifTrue:[
TypeToImageReaderClassMapping := Dictionary new.
].
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
"Created: / 30.6.1997 / 21:56:11 / cg"
"Modified: / 1.8.1998 / 17:02:40 / cg"
!
mimeTypeForSuffix:suffix
"given a file suffix, return the mime-type"
^ FileSuffixToTypeMapping at:suffix asLowercase ifAbsent:nil
"Created: / 30.6.1997 / 21:55:51 / cg"
"Modified: / 1.8.1998 / 17:02:59 / cg"
!
mimeTypeForSuffix:suffix put:mimeType
"register a mime type for a file suffix"
FileSuffixToTypeMapping isNil ifTrue:[
FileSuffixToTypeMapping := Dictionary new
].
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
"Created: / 30.6.1997 / 21:56:20 / cg"
"Modified: / 1.8.1998 / 17:03:18 / cg"
! !
!MIMETypes class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.13 1998-08-01 15:51:03 cg Exp $'
! !
MIMETypes initialize!