MIMETypes.st
author tz
Fri, 09 Jan 1998 16:50:18 +0100
changeset 752 93690dcd1b75
parent 713 548898fdd1dc
child 1021 004c324dc31a
permissions -rw-r--r--
button and label translation support added.

"
 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)

    [author:]
        Claus Gittinger
"
! !

!MIMETypes class methodsFor:'initialization'!

initialize
    "initialize wellKnown facts"

    |t|

    (t := TypeToImageReaderClassMapping) isNil ifTrue:[
	TypeToImageReaderClassMapping := t := Dictionary new
    ].
    t at:'image/jpeg' put:JPEGReader.
    t at:'image/gif'  put:GIFReader.
    t at:'image/tiff' put:TIFFReader.

    (t := FileSuffixToTypeMapping) isNil ifTrue:[
	FileSuffixToTypeMapping := t := Dictionary new
    ].
    t at:'jpg' put:'image/jpeg'.
    t at:'gif' put:'image/gif'.
    t at:'tif' put:'image/tiff'.

    t at:'htm'  put:'text/html'.
    t at:'html' put:'text/html'.
    t at:'ps'   put:'application/postscript'.

    (t := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
	FileSuffixToImageReaderClassMapping := t := Dictionary new
    ].
    t at:'jpg'  put:JPEGReader.
    t at:'gif'  put:GIFReader.
    t at:'tif'  put:TIFFReader.

    (t := CharSetToFontMapping) isNil ifTrue:[
	CharSetToFontMapping := t := Dictionary new
    ].
    t at:'iso2022-jp'   put:'jis*0208*'.
    t at:'x-iso2022-jp' put:'jis*0208*'.
    t at:'x-euc-jp'     put:'jis*0208*'.
    t at:'x-shift-jis'  put:'jis*0208*'.
    t at:'x-sjis'       put:'jis*0208*'.
    t at:'x-jis7'       put:'jis*0208*'.
    t at:'jis7'         put:'jis*0208*'.
    t at:'euc'          put:'jis*0208*'.
    t at:'euc-jp'       put:'jis*0208*'.
    t at:'sjis'         put:'jis*0208*'.

    t at:'big5'        put:'big5*'.

    t at:'gb2312'      put:'gb*'.
    t at:'hz-gb-2312'  put:'gb*'.
    t at:'x-gbk'       put:'gb*'.

    t at:'iso2022-kr'  put:'ksc*'.
    t at:'x-euc-kr'    put:'ksc*'.

    "
     self initialize
    "

    "Modified: 16.7.1997 / 13:52:50 / 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
    ^ FileSuffixToImageReaderClassMapping ? #()

    "Modified: 30.6.1997 / 22:06:11 / cg"
!

fontForCharset:aCharSet
    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil

    "
     MIMETypes fontForCharset:'iso2022-jp'
     MIMETypes fontForCharset:'euc-jp'     
    "

    "Modified: 30.6.1997 / 23:26:30 / cg"
!

imageFileSuffixes
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
    ^ FileSuffixToImageReaderClassMapping keys

    "Modified: 30.6.1997 / 21:51:39 / cg"
    "Created: 30.6.1997 / 22:04:48 / cg"
!

imageReaderClasses
    |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

    "Modified: 30.6.1997 / 21:51:39 / cg"
    "Created: 30.6.1997 / 22:03:42 / cg"
!

imageReaderForSuffix:aSuffix
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil

    "Modified: 30.6.1997 / 21:51:39 / cg"
    "Created: 30.6.1997 / 21:59:11 / cg"
!

imageReaderForSuffix:aSuffix put:aReaderClass
    FileSuffixToImageReaderClassMapping isNil ifTrue:[
        FileSuffixToImageReaderClassMapping := Dictionary new.
    ].
    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass

    "Modified: 30.6.1997 / 21:51:44 / cg"
    "Created: 30.6.1997 / 21:59:43 / cg"
!

imageReaderForType:mimeTypeString
    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil

    "Modified: 30.6.1997 / 21:51:39 / cg"
    "Created: 30.6.1997 / 21:56:01 / cg"
!

imageReaderForType:mimeTypeString put:aReaderClass
    TypeToImageReaderClassMapping isNil ifTrue:[
        TypeToImageReaderClassMapping := Dictionary new.
    ].
    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass

    "Modified: 30.6.1997 / 21:51:44 / cg"
    "Created: 30.6.1997 / 21:56:11 / cg"
!

mimeTypeForSuffix:suffix
    ^ FileSuffixToTypeMapping at:suffix asLowercase ifAbsent:nil

    "Created: 30.6.1997 / 21:55:51 / cg"
    "Modified: 30.6.1997 / 21:58:13 / cg"
!

mimeTypeForSuffix:suffix put:mimeType
    FileSuffixToTypeMapping isNil ifTrue:[
        FileSuffixToTypeMapping := Dictionary new
    ].
    FileSuffixToTypeMapping at:suffix put:mimeType asLowercase

    "Created: 30.6.1997 / 21:56:20 / cg"
    "Modified: 30.6.1997 / 21:58:19 / cg"
! !

!MIMETypes class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.10 1997-10-21 18:26:41 cg Exp $'
! !
MIMETypes initialize!