MIMETypes.st
author Claus Gittinger <cg@exept.de>
Mon, 11 Nov 2002 10:41:19 +0100
changeset 1666 2fe4fb7be12c
parent 1616 f07466809515
child 1668 070264d3a087
permissions -rw-r--r--
added xml type
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG 
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
     3
	      All Rights Reserved
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1410
faf04ef6892b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
    15
"{ Package: 'stx:libview2' }"
faf04ef6892b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
    16
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
Object subclass:#MIMETypes
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    18
	instanceVariableNames:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    19
	classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    20
		FilenameToTypeMapping FileSuffixToImageReaderClassMapping
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    21
		CharSetToFontMapping LastSuffix LastType'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    22
	poolDictionaries:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    23
	category:'System-Documentation'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    24
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    25
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    26
String variableByteSubclass:#MIMEType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    27
	instanceVariableNames:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    28
	classVariableNames:'CachedTypes'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    29
	poolDictionaries:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    30
	privateIn:MIMETypes
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
copyright
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 COPYRIGHT (c) 1997 by eXept Software AG 
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    38
	      All Rights Reserved
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
documentation
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    just a place to keep MIME information
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    (avoid spreading things at many places)
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    56
    MIMETypes is abstract and functional.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    57
    Actually, in some OperatingSystems, this information may
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    58
    be found in some config files (or registries).
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    59
    Therefore, this class may have to be extended to support this
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    60
    and fetch the information from there eventually.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    61
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    [author:]
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
        Claus Gittinger
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    65
!
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    66
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    67
knownTypes
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    68
"
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    69
    simply a reminder for me ...
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    70
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    71
    application         mime                            file extentsions
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    72
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    73
        powerpoint      application/ms-powerpoint       .pot, .ppz, .ppt, .pps, 
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    74
                        application/mspowerpoint        
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    75
                        application/vnd.ms-powerpoint   
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    76
                        application/x-mspowerpoint
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    77
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    78
        shockwave       application/x-shockwave-flash   .swf     
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    79
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    80
        futuresplash    application/futuresplash        .spl
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    81
"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!MIMETypes class methodsFor:'initialization'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    86
applicationComprAndArchiveTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
    87
    "compressors and archivers"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    88
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    89
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    90
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    91
        'tar'                   'application/x-tar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    92
        'gtar'                  'application/x-gtar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    93
        'tgz'                   'application/x-tar-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    94
        'zip'                   'application/x-zip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    95
        ('gz' 'z')              'application/x-gzip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    96
        'cpio'                  'application/x-cpio'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    97
        'shar'                  'application/x-shar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    98
        'jar'                   'application/java-archive'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    99
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   100
!
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   101
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   102
applicationMiscTypeList
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   103
    "misc applications"
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   104
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   105
    ^ #(
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   106
        ('a' 'o' 'obj' )                        'application/binary'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   107
        'a'                                     'application/library'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   108
        ('dll' 'so')                            'application/shared-library'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   109
    )
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   110
!
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   111
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   112
applicationProgLangTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   113
    "applications for programm languages"
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   114
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   115
    ^ #(
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   116
        ('st' 'cls' 'rc')            'application/x-smalltalk-source'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   117
        'sif'                        'application/x-smalltalk-source-sif'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   118
        'c'                          'application/x-c-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   119
        ('cc' 'cpp')                 'application/x-cpp-source'
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   120
        ('h' 'hi')                   'application/x-c-header'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   121
        ('js' 'mocha')               'application/x-javascript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   122
        ('java' 'jav')               'application/x-java-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   123
        'sh'                         'application/x-sh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   124
        'csh'                        'application/x-csh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   125
        'tcl'                        'application/x-tcl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   126
        'pl'                         'application/x-perl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   127
        'mak'                        'application/x-make'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   128
        'bat'                        'application/x-batch-script'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   129
        ('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   130
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   131
!
1561
942de18a3e3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   132
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   133
applicationTextTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   134
    "text applications"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   135
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   136
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   137
        ('ps' 'eps')                 'application/postscript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   138
        'pdf'                        'application/pdf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   139
        'rtf'                        'application/rtf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   140
        'doc'                        'application/winword'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   141
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   142
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   143
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   144
applicationTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   145
    "applications"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   146
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   147
    |typeStrings|                            
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   148
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   149
    typeStrings := OrderedCollection new.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   150
    typeStrings addAll:self applicationProgLangTypeList.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   151
    typeStrings addAll:self applicationTextTypeList.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   152
    typeStrings addAll:self applicationComprAndArchiveTypeList.
1616
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   153
    typeStrings addAll:self applicationMiscTypeList.
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   154
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   155
    ^ typeStrings
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   156
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   157
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   158
audioTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   159
    "audio formats ..."
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   160
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   161
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   162
        ('ra' 'ram')            'audio/x-pn-realaudio'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   163
        ('mpa' 'mpega')         'audio/x-mpeg'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   164
        ('mp3' )                'audio/x-mp3'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   165
        'wav'                   'audio/x-wav'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   166
        ('aif' 'aiff' 'aifc')   'audio/x-aiff'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   167
        ('au' 'snd')            'audio/basic'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   168
        ('swf')                 'audio/x-shockwave-flash'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   169
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   170
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   171
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   172
imageTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   173
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   174
    ^ #(
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   175
        "/ image formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   176
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   177
        ('jpg' 'jpeg')  'image/jpeg'
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   178
        'gif'           'image/gif'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   179
        ('tif' 'tiff')  'image/tiff'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   180
        'xbm'           'image/x-xbitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   181
        'xpm'           'image/x-xpixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   182
        'png'           'image/x-png'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   183
        'pcd'           'image/x-photo-cd'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   184
        'bmp'           'image/x-MS-bmp'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   185
        'rgb'           'image/x-rgb'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   186
        'ppm'           'image/x-portable-pixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   187
        'pgm'           'image/x-portable-graymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   188
        'pbm'           'image/x-portable-bitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   189
        'pnm'           'image/x-portable-anymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   190
        'xwd'           'image/x-xwindowdump'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   191
        'ras'           'image/x-cmu-raster'
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   192
        'tga'           'image/x-targa'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   193
    ) 
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   194
!
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   195
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   196
initialize
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   197
    "initialize wellKnown facts"
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   198
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   199
    |typeToImageReaderClassMapping fileSuffixToTypeMapping
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   200
     fileSuffixToImageReaderClassMapping charSetToFontMapping types|
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   201
1610
34bb3a9f1379 Fix everything, so that stx can be started
Stefan Vogel <sv@exept.de>
parents: 1609
diff changeset
   202
    MIMEType initialize.   "must be initialized first"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   203
    LastSuffix := LastType := nil.
1411
d72f09a436d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1410
diff changeset
   204
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   205
    (fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   206
        FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   207
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   208
    (typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   209
        TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   210
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   211
    (fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   212
        FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   213
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   214
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   215
    "/ setup file-suffix to mimeType mapping ...
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   216
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   217
    types := OrderedCollection new.
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   218
    types addAll:self textTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   219
    types addAll:self imageTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   220
    types addAll:self videoTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   221
    types addAll:self audioTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   222
    types addAll:self applicationTypeList.
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   223
    types pairWiseDo:[:suff :typeString|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   224
        |type|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   225
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   226
        type := MIMEType fromString:typeString.
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   227
        suff isArray ifTrue:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   228
            suff do:[:s | fileSuffixToTypeMapping at:s put:type]
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   229
        ] ifFalse:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   230
            fileSuffixToTypeMapping at:suff put:type
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   231
        ]
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   232
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   233
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   234
    FilenameToTypeMapping := Dictionary new.
1616
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   235
    self miscFilenameList pairWiseDo:[:nm :typeString|
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   236
        |type|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   237
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   238
        type := MIMEType fromString:typeString.
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   239
        nm isArray ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   240
            nm do:[:s | FilenameToTypeMapping at:s put:type]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   241
        ] ifFalse:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   242
            FilenameToTypeMapping at:nm put:type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   243
        ]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   244
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   245
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   246
    "/ setup mimeType to image reader class mapping ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   247
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   248
    typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   249
    typeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   250
    typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   251
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   252
    "/ setup suffix to image reader class mapping ...
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   253
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   254
    fileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
    fileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   256
    fileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   257
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   258
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   259
    "/ character sets (not really mime stuff, but also placed here)
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   260
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
    (charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
        CharSetToFontMapping := charSetToFontMapping := Dictionary new
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
    ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   264
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   265
    #(
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   266
        'iso2022-jp'   'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   267
        'x-iso2022-jp' 'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   268
        'x-euc-jp'     'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   269
        'x-shift-jis'  'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   270
        'x-sjis'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   271
        'x-jis7'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   272
        'jis7'         'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   273
        'euc'          'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   274
        'euc-jp'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   275
        'sjis'         'jis*0208*'
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   276
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   277
        'big5'         'big5*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   278
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   279
        'gb2312'       'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   280
        'hz-gb-2312'   'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   281
        'x-gbk'        'gb*'
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   282
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   283
        'iso2022-kr'   'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   284
        'x-euc-kr'     'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   285
    ) pairWiseDo:[:charSet :fontEncoding|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   286
         charSetToFontMapping at:charSet put:fontEncoding
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   287
    ].
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
     self initialize
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
1269
4362ec6dd5c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   293
    "Modified: / 19.11.1999 / 15:01:53 / cg"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   294
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   295
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   296
miscFilenameList
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   297
    "other formats (not by suffix, but by fileName isnstead) ..."
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   298
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   299
    ^ #(
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   300
        ('makefile' 'make.proto')  'application/x-make'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   301
    )
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   302
!
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   303
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   304
textTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   305
   "/ misc text ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   306
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   307
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   308
        ('htm' 'html')          'text/html'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   309
        ('shtml')               'text/html'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   310
        ('txt' 'text')          'text/plain'
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   311
        ('xml')                 'text/xml'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   312
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   313
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   314
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   315
videoTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   316
    "/ video formats ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   317
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   318
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   319
        'movie'                            'video/x-sgi-movie'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   320
        'avi'                              'video/x-msvideo'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   321
        ('qt' 'mov' 'moov')                'video/quicktime'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   322
        ('mpv2' 'mp2v' 'mp2' 'mpeg2')      'video/x-mpeg2'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   323
        ('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   324
    )
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
!MIMETypes class methodsFor:'accessing'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   329
commentStringsForFilename:aFilename
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   330
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   331
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   332
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   333
     the second an array of opening/closing delimiters (or an array of nils)"
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   334
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   335
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   336
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   337
     mime := MIMETypes mimeTypeForFilename:aFilename.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   338
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   339
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   340
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   341
     MIMETypes commentStringsForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   342
     MIMETypes commentStringsForFilename:'Object.st'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   343
     MIMETypes commentStringsForFilename:'Foo.java'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   344
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   345
!
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   346
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   347
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   348
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   349
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   350
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   351
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   352
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   353
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   354
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   355
     mime := MIMETypes mimeTypeForFilename:aFilename.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   356
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   357
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   358
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   359
     MIMETypes commentStringsForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   360
     MIMETypes commentStringsForFilename:'Object.st'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   361
     MIMETypes commentStringsForFilename:'Foo.java'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   362
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   363
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   364
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   365
commentStringsForMimeType:mime suffix:suff
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   366
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   367
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   368
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   369
     the second an array of opening/closing delimiters (or an array of nils)"
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   370
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   371
    ^ self
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   372
        commentStringsForMimeType:mime suffix:suff 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   373
        ifUnknown: #(';' (nil nil))  
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   374
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   375
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   376
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   377
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   378
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   379
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   380
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   381
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   382
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   383
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   384
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   385
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   386
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   387
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   388
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   389
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   390
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   391
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   392
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   393
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   394
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   395
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   396
    (mime = 'application/x-make') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   397
        "/ makefile
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   398
        ^ #('#' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   399
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   400
    (mime = 'application/x-sh') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   401
        "/ shell script
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   402
        ^ #('#' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   403
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   404
    ((mime = 'text/html') 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   405
    or:[(mime = 'text/xml')
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   406
    or:[(mime = 'application/xml')]]) ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   407
        ^ #(nil ('<!!-- ' ' -->')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   408
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   409
    (mime = 'application/x-batch-script') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   410
        ^ #('rem ' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   411
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   412
    (mime = 'application/x-smalltalk-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   413
        ^ #('"/' ('"' '"')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   414
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   415
    (mime = 'application/x-pascal-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   416
        ^ #(nil ('{' '}')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   417
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   418
    (mime = 'application/x-c-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   419
        ^ #(nil ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   420
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   421
    (mime = 'application/x-cpp-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   422
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   423
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   424
    (mime = 'application/x-java-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   425
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   426
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   427
    (mime = 'application/x-asn1-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   428
        ^ #('--' ('--' '--')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   429
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   430
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   431
    "/ st/x support files
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   432
    (suff = 'style') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   433
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   434
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   435
    (suff = 'rs') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   436
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   437
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   438
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   439
    ^ alternativeBlockReturningCommentString value
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   440
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   441
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   442
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   443
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   444
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   445
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   446
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   447
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   448
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   449
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   450
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   451
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   452
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   453
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   454
!
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   455
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   456
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   457
    "register an image reader."
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   458
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   459
    aSuffix notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   460
        self imageReaderForSuffix:aSuffix put:aReaderClass.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   461
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   462
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   463
    mimeType notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   464
        self imageReaderForType:mimeType put:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   465
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   466
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   467
    (aSuffix notNil and:[mimeType notNil]) ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   468
        self mimeTypeForSuffix:aSuffix put:mimeType
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   469
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   470
!
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   471
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
fileSuffixToImageReaderMapping
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   473
    "return the suffix-to-imageReader mapping"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   474
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    ^ FileSuffixToImageReaderClassMapping ? #()
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   477
    "Modified: / 1.8.1998 / 17:00:11 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   480
fontForCharset:aCharSet
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   481
    "return the font-encoding for an iso-charset"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   482
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   483
    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   484
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   485
    "
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   486
     MIMETypes fontForCharset:'iso2022-jp'       
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   487
     MIMETypes fontForCharset:'euc-jp'     
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   488
    "
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   489
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   490
    "Modified: / 1.8.1998 / 17:00:57 / cg"
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   491
!
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   492
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
imageFileSuffixes
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   494
    "return a collection with known file suffixes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   495
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
    ^ FileSuffixToImageReaderClassMapping keys
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   499
    "Created: / 30.6.1997 / 22:04:48 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   500
    "Modified: / 1.8.1998 / 17:01:26 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
imageReaderClasses
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   504
    "return a collection of registered image reader classes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   505
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   506
    |setOfClasses|
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   507
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   508
    setOfClasses := IdentitySet new.
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   509
    FileSuffixToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   510
        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   511
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   512
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   513
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   514
    TypeToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   515
        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   516
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   517
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   518
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   519
    ^ setOfClasses
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   521
    "Created: / 30.6.1997 / 22:03:42 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   522
    "Modified: / 1.8.1998 / 16:59:52 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
imageReaderForSuffix:aSuffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   526
    "given a file suffix, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   527
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   531
    "Created: / 30.6.1997 / 21:59:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   532
    "Modified: / 1.8.1998 / 17:01:58 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
imageReaderForSuffix:aSuffix put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   536
    "register an image reader for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   537
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    FileSuffixToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
        FileSuffixToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   543
    "Created: / 30.6.1997 / 21:59:43 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   544
    "Modified: / 1.8.1998 / 17:02:14 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
imageReaderForType:mimeTypeString
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   548
    "given a mime-type, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   549
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   553
    "Created: / 30.6.1997 / 21:56:01 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   554
    "Modified: / 1.8.1998 / 17:02:28 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
imageReaderForType:mimeTypeString put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   558
    "register an image reader for a mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   559
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
    TypeToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
        TypeToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   565
    "Created: / 30.6.1997 / 21:56:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   566
    "Modified: / 1.8.1998 / 17:02:40 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   569
mimeTypeForFilename:filenameArg
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   570
    "given a filename, return the mime-type or nil, if unknown"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   571
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   572
    |type filename lcFilename suff|
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   573
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   574
    filename := filenameArg asFilename.
1474
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   575
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   576
    lcFilename := filename baseName asLowercase.
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   577
    type := FilenameToTypeMapping at:lcFilename ifAbsent:nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   578
    type isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   579
        "/ allow for fallback ...
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   580
        type := OperatingSystem mimeTypeForFilename:lcFilename.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   581
        "/ the special value #unknown is returned as nil;
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   582
        "/ this avoids constant retry if a mimeType is not known in
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   583
        "/ the OS.
1275
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   584
"/        type isNil ifTrue:[
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   585
"/            FilenameToTypeMapping at:lcFilename put:#unknown
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   586
"/        ].
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   587
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   588
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   589
    type == #unknown ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   590
        type := nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   591
    ].
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   592
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   593
    type isNil ifTrue:[
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   594
        suff := filename suffix.
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   595
        suff size ~~ 0 ifTrue:[
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   596
            ^ self mimeTypeForSuffix:suff
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   597
        ]
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   598
    ].
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   599
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   600
    ^ type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   601
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   602
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   603
mimeTypeForFilename:filename put:mimeType
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   604
    "register a mime type for a filename"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   605
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   606
    FilenameToTypeMapping isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   607
        FilenameToTypeMapping := Dictionary new
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   608
    ].
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   609
    FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase)
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   610
!
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   611
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
mimeTypeForSuffix:suffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   613
    "given a file suffix, return the mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   614
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   615
    |type lcSuffix|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   616
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   617
    lcSuffix := suffix asLowercase.
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   618
    lcSuffix = LastSuffix ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   619
        type := LastType
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   620
    ] ifFalse:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   621
        type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   622
        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   623
            "/ allow for fallback ...
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   624
            type := OperatingSystem mimeTypeForSuffix:lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   625
            "/ the special value #unknown is returned as nil;
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   626
            "/ this avoids constant retry if a mimeType is not known in
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   627
            "/ the OS.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   628
    "/        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   629
    "/            FileSuffixToTypeMapping at:lcSuffix put:#unknown
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   630
    "/        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   631
        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   632
        LastSuffix := lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   633
        LastType := type.
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   634
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   635
    type == #unknown ifTrue:[
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   636
        type := nil
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   637
    ].
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   638
    type notNil ifTrue:[
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   639
        ^ MIMEType fromString:type
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   640
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   641
    ^ type
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   643
    "
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   644
     self mimeTypeForSuffix:'xml'
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   645
    "
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   646
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   647
    "Created: / 30.6.1997 / 21:55:51 / cg"
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   648
    "Modified: / 23.12.1999 / 22:30:55 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
mimeTypeForSuffix:suffix put:mimeType
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   652
    "register a mime type for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   653
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    FileSuffixToTypeMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
        FileSuffixToTypeMapping := Dictionary new
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   659
    "Created: / 30.6.1997 / 21:56:20 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   660
    "Modified: / 1.8.1998 / 17:03:18 / cg"
1593
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   661
!
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   662
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   663
mimeTypeForSuffixMapping
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   664
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   665
    ^ FileSuffixToTypeMapping
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   666
!
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   667
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   668
mimeTypeOfContents:filename
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   669
    "given a filename, scan the contents, return the mime-type or nil, if unknown"
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   670
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   671
    |typeString|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   672
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   673
    typeString := filename mimeTypeOfContents.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   674
    typeString isNil ifTrue:[^ nil].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   675
    ^ MIMEType fromString:typeString.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   676
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   677
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   678
!MIMETypes::MIMEType class methodsFor:'documentation'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   679
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   680
documentation
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   681
"
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   682
    like a string, but knows that it represents a mimeType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   683
"
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   684
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   685
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   686
!MIMETypes::MIMEType class methodsFor:'initialization'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   687
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   688
initialize
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   689
    CachedTypes := CacheDictionary new:30.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   690
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   691
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   692
     self initialize
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   693
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   694
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   695
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   696
!MIMETypes::MIMEType class methodsFor:'instance creation'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   697
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   698
fromString:aString
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   699
    |cachedType newType|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   700
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   701
    aString class == self ifTrue:[^ aString].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   702
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   703
    cachedType := CachedTypes at:aString ifAbsent:nil.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   704
    cachedType notNil ifTrue:[^ cachedType].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   705
    newType := aString copy changeClassTo:self.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   706
    CachedTypes at:aString put:newType.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   707
    ^ newType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   708
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   709
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   710
     self fromString:'text/html'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   711
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   712
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   713
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   714
!MIMETypes::MIMEType methodsFor:'queries'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   715
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   716
isArchiv
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   717
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   718
    |archivTypes|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   719
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   720
    archivTypes := MIMETypes applicationComprAndArchiveTypeList.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   721
    archivTypes pairWiseDo:[: ext : type |
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   722
        self = type ifTrue:[ ^ true].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   723
    ].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   724
    ^ false
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   725
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   726
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   727
isHtml
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   728
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   729
    ^ (self = 'text/html')
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   730
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   731
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   732
isImage
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   733
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   734
    ^ (self startsWith:'image')
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   735
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   736
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   737
isPdf
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   738
    ^ (self = 'application/pdf')
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   739
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   740
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   741
isSmalltalkSource
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   742
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   743
    ^ (self = 'application/x-smalltalk-source')
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
version
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   749
    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.44 2002-11-11 09:41:19 cg Exp $'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
! !
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   751
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
MIMETypes initialize!
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   753
MIMETypes::MIMEType initialize!