643
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
|
|
12 |
|
|
13 |
"
|
|
14 |
|
|
15 |
Object subclass:#MIMETypes
|
|
16 |
instanceVariableNames:''
|
|
17 |
classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
|
648
|
18 |
FileSuffixToImageReaderClassMapping CharSetToFontMapping'
|
643
|
19 |
poolDictionaries:''
|
|
20 |
category:'System-Documentation'
|
|
21 |
!
|
|
22 |
|
|
23 |
!MIMETypes class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
|
|
37 |
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
documentation
|
|
42 |
"
|
|
43 |
just a place to keep MIME information
|
|
44 |
(avoid spreading things at many places)
|
|
45 |
|
|
46 |
[author:]
|
|
47 |
Claus Gittinger
|
|
48 |
"
|
|
49 |
! !
|
|
50 |
|
|
51 |
!MIMETypes class methodsFor:'initialization'!
|
|
52 |
|
|
53 |
initialize
|
645
|
54 |
"initialize wellKnown facts"
|
|
55 |
|
643
|
56 |
TypeToImageReaderClassMapping isNil ifTrue:[TypeToImageReaderClassMapping := Dictionary new].
|
645
|
57 |
TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
|
|
58 |
TypeToImageReaderClassMapping at:'image/gif' put:GIFReader.
|
|
59 |
TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
|
|
60 |
|
643
|
61 |
FileSuffixToTypeMapping isNil ifTrue:[FileSuffixToTypeMapping := Dictionary new].
|
645
|
62 |
FileSuffixToTypeMapping at:'jpg' put:'image/jpeg'.
|
|
63 |
FileSuffixToTypeMapping at:'gif' put:'image/gif'.
|
|
64 |
FileSuffixToTypeMapping at:'tif' put:'image/tiff'.
|
|
65 |
|
643
|
66 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[FileSuffixToImageReaderClassMapping := Dictionary new].
|
645
|
67 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader.
|
|
68 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader.
|
|
69 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader.
|
|
70 |
|
|
71 |
CharSetToFontMapping isNil ifTrue:[CharSetToFontMapping := Dictionary new].
|
|
72 |
CharSetToFontMapping at:'iso2022-jp' put:'jis'.
|
|
73 |
CharSetToFontMapping at:'euc-jp' put:'jis'.
|
|
74 |
CharSetToFontMapping at:'shift-jis' put:'jis'.
|
|
75 |
CharSetToFontMapping at:'jis7' put:'jis'.
|
|
76 |
CharSetToFontMapping at:'jis8' put:'jis'.
|
|
77 |
|
|
78 |
CharSetToFontMapping at:'iso2022-cn' put:'big5'.
|
|
79 |
CharSetToFontMapping at:'euc-cn' put:'big5'.
|
|
80 |
CharSetToFontMapping at:'hz' put:'big5'.
|
|
81 |
|
|
82 |
CharSetToFontMapping at:'gb2312' put:'gb'.
|
|
83 |
CharSetToFontMapping at:'euc-gb' put:'gb'.
|
|
84 |
|
|
85 |
CharSetToFontMapping at:'iso2022-kr' put:'ksc'.
|
|
86 |
CharSetToFontMapping at:'euc-kr' put:'ksc'.
|
643
|
87 |
|
|
88 |
"
|
|
89 |
self initialize
|
|
90 |
"
|
|
91 |
|
|
92 |
"Modified: 30.6.1997 / 21:58:47 / cg"
|
|
93 |
! !
|
|
94 |
|
|
95 |
!MIMETypes class methodsFor:'accessing'!
|
|
96 |
|
647
|
97 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
|
|
98 |
"register an image reader."
|
|
99 |
|
|
100 |
aSuffix notNil ifTrue:[
|
|
101 |
self imageReaderForSuffix:aSuffix put:aReaderClass.
|
|
102 |
].
|
|
103 |
|
|
104 |
mimeType notNil ifTrue:[
|
|
105 |
self imageReaderForType:mimeType put:aReaderClass
|
|
106 |
].
|
|
107 |
|
|
108 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[
|
|
109 |
self mimeTypeForSuffix:aSuffix put:mimeType
|
|
110 |
].
|
|
111 |
!
|
|
112 |
|
643
|
113 |
fileSuffixToImageReaderMapping
|
|
114 |
^ FileSuffixToImageReaderClassMapping ? #()
|
|
115 |
|
|
116 |
"Modified: 30.6.1997 / 22:06:11 / cg"
|
|
117 |
!
|
|
118 |
|
648
|
119 |
fontForCharset:aCharSet
|
|
120 |
^ CharSetToFontMapping at:aCharSet ifAbsent:nil
|
|
121 |
|
|
122 |
"
|
|
123 |
MIMETypes fontForCharset:'iso2022-jp'
|
|
124 |
MIMETypes fontForCharset:'euc-jp'
|
|
125 |
"
|
|
126 |
|
|
127 |
"Modified: 30.6.1997 / 23:26:30 / cg"
|
|
128 |
!
|
|
129 |
|
643
|
130 |
imageFileSuffixes
|
|
131 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
|
|
132 |
^ FileSuffixToImageReaderClassMapping keys
|
|
133 |
|
|
134 |
"Modified: 30.6.1997 / 21:51:39 / cg"
|
|
135 |
"Created: 30.6.1997 / 22:04:48 / cg"
|
|
136 |
!
|
|
137 |
|
|
138 |
imageReaderClasses
|
645
|
139 |
|setOfClasses|
|
|
140 |
|
|
141 |
setOfClasses := IdentitySet new.
|
|
142 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[
|
|
143 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
|
|
144 |
setOfClasses add:cls
|
|
145 |
].
|
|
146 |
].
|
|
147 |
TypeToImageReaderClassMapping notNil ifTrue:[
|
|
148 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
|
|
149 |
setOfClasses add:cls
|
|
150 |
].
|
|
151 |
].
|
|
152 |
^ setOfClasses
|
643
|
153 |
|
|
154 |
"Modified: 30.6.1997 / 21:51:39 / cg"
|
|
155 |
"Created: 30.6.1997 / 22:03:42 / cg"
|
|
156 |
!
|
|
157 |
|
|
158 |
imageReaderForSuffix:aSuffix
|
|
159 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
|
|
160 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
|
|
161 |
|
|
162 |
"Modified: 30.6.1997 / 21:51:39 / cg"
|
|
163 |
"Created: 30.6.1997 / 21:59:11 / cg"
|
|
164 |
!
|
|
165 |
|
|
166 |
imageReaderForSuffix:aSuffix put:aReaderClass
|
|
167 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[
|
|
168 |
FileSuffixToImageReaderClassMapping := Dictionary new.
|
|
169 |
].
|
|
170 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
|
|
171 |
|
|
172 |
"Modified: 30.6.1997 / 21:51:44 / cg"
|
|
173 |
"Created: 30.6.1997 / 21:59:43 / cg"
|
|
174 |
!
|
|
175 |
|
|
176 |
imageReaderForType:mimeTypeString
|
|
177 |
TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
|
|
178 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
|
|
179 |
|
|
180 |
"Modified: 30.6.1997 / 21:51:39 / cg"
|
|
181 |
"Created: 30.6.1997 / 21:56:01 / cg"
|
|
182 |
!
|
|
183 |
|
|
184 |
imageReaderForType:mimeTypeString put:aReaderClass
|
|
185 |
TypeToImageReaderClassMapping isNil ifTrue:[
|
|
186 |
TypeToImageReaderClassMapping := Dictionary new.
|
|
187 |
].
|
|
188 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
|
|
189 |
|
|
190 |
"Modified: 30.6.1997 / 21:51:44 / cg"
|
|
191 |
"Created: 30.6.1997 / 21:56:11 / cg"
|
|
192 |
!
|
|
193 |
|
|
194 |
mimeTypeForSuffix:suffix
|
|
195 |
^ FileSuffixToTypeMapping at:suffix asLowercase ifAbsent:nil
|
|
196 |
|
|
197 |
"Created: 30.6.1997 / 21:55:51 / cg"
|
|
198 |
"Modified: 30.6.1997 / 21:58:13 / cg"
|
|
199 |
!
|
|
200 |
|
|
201 |
mimeTypeForSuffix:suffix put:mimeType
|
|
202 |
FileSuffixToTypeMapping isNil ifTrue:[
|
|
203 |
FileSuffixToTypeMapping := Dictionary new
|
|
204 |
].
|
|
205 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
|
|
206 |
|
|
207 |
"Created: 30.6.1997 / 21:56:20 / cg"
|
|
208 |
"Modified: 30.6.1997 / 21:58:19 / cg"
|
|
209 |
! !
|
|
210 |
|
|
211 |
!MIMETypes class methodsFor:'documentation'!
|
|
212 |
|
|
213 |
version
|
648
|
214 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.5 1997-06-30 21:26:36 cg Exp $'
|
643
|
215 |
! !
|
|
216 |
MIMETypes initialize!
|