refactored
authorClaus Gittinger <cg@exept.de>
Fri, 28 Mar 2003 12:30:35 +0100
changeset 1729 5d1b74b8d264
parent 1728 dd330032fae2
child 1730 f6732f77edf8
refactored
MIMETypes.st
--- a/MIMETypes.st	Wed Mar 26 17:46:18 2003 +0100
+++ b/MIMETypes.st	Fri Mar 28 12:30:35 2003 +0100
@@ -16,7 +16,8 @@
 
 Object subclass:#MIMETypes
 	instanceVariableNames:''
-	classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
+	classVariableNames:'TypeToImageReaderClassMapping TypeToCommentStringMapping
+		SuffixToCommentStringMapping FileSuffixToTypeMapping
 		FilenameToTypeMapping FileSuffixToImageReaderClassMapping
 		CharSetToFontMapping LastSuffix LastType
 		DefaultCommandPerMIMEPerOS'
@@ -84,11 +85,177 @@
 
 !MIMETypes class methodsFor:'initialization'!
 
-applicationComprAndArchiveTypeList
-    "compressors and archivers"
+initialize
+    "initialize wellKnown facts"
+
+    MIMEType initialize.   "must be initialized first"
+    LastSuffix := LastType := nil.
+
+    self initializeFileNameToMimeTypeMapping.
+    self initializeImageReaderMappings.
+    self initializeCommentStringMappings.
+
+    "
+     self initialize
+    "
+
+    "Modified: / 19.11.1999 / 15:01:53 / cg"
+!
+
+initializeCommentStringMappings
+    TypeToCommentStringMapping := Dictionary new.
+    SuffixToCommentStringMapping := Dictionary new.
+
+    TypeToCommentStringMapping 
+        at:'application/x-make'
+        put:#('#' (nil nil)).           "/ '#' for EOL comments only
+
+    TypeToCommentStringMapping 
+        at:'application/x-sh'
+        put:#('#' (nil nil)).           "/ '#' for EOL comments only
+
+    #('text/html' 'text/xml' 'application/xml')
+    do:[:eachXMLType |
+        TypeToCommentStringMapping 
+            at:eachXMLType
+            put:#(nil ('<!!-- ' ' -->')). "/ '<!!-- ... -->' delimited comments only
+    ].
+
+    TypeToCommentStringMapping 
+        at:'application/x-batch-script'
+        put:#('rem ' (nil nil)).         "/ 'rem ' for EOL comments only
+
+    "/ the following is ST/X specific
+    TypeToCommentStringMapping 
+        at:'application/x-smalltalk-source'
+        put:#('"/' ('"' '"')).           "/ '"/ ' for EOL; ".." for delimited comments
+
+    "/ this is for standard smalltalk
+"/    TypeToCommentStringMapping 
+"/        at:'application/x-smalltalk-source'
+"/        put:#(nil ('"' '"')).            "/ ".." for delimited comments only
+
+
+    TypeToCommentStringMapping 
+        at:'application/x-pascal-source'
+        put:#(nil ('{' '}')).           "/ '{'..'}' for delimited comments
+
+    "/ the following is k&r
+    TypeToCommentStringMapping 
+        at:'application/x-c-source'
+        put:#(nil ('/*' '*/')).          "/ '/*'..'*/' for delimited comments
+
+    "/ this is ANSI-c
+    TypeToCommentStringMapping 
+        at:'application/x-c-source'
+        put:#('//' ('/*' '*/')).          
+
+    TypeToCommentStringMapping 
+        at:'application/x-cpp-source'
+        put:#('//' ('/*' '*/')).          
+
+    TypeToCommentStringMapping 
+        at:'application/x-java-source'
+        put:#('//' ('/*' '*/')).          
+
+    TypeToCommentStringMapping 
+        at:'application/x-asn1-source'
+        put:#('--' ('--' '--')).          
+
+
+    "/ st/x support files
+    SuffixToCommentStringMapping 
+        at:'style'
+        put:#(';' (nil nil)).          
 
+    SuffixToCommentStringMapping 
+        at:'rs'
+        put:#(';' (nil nil)).          
+!
+
+initializeDefaultCommands
+    "TODO: move this to OS"
+
+    |unixCommands win32Commands|
+
+    DefaultCommandPerMIMEPerOS := Dictionary new.
+    DefaultCommandPerMIMEPerOS at:#unix  put:(unixCommands := Dictionary new).
+    DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new).
+
+    unixCommands at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
+    unixCommands at:'application/pdf'              put:'acroread -display %2 %1'.
+
+    "
+     self initializeDefaultCommands
+    "
+!
+
+initializeFileNameToMimeTypeMapping
+    "initialize wellKnown facts"
+
+    |types|
+
+    FileSuffixToTypeMapping isNil ifTrue:[
+        FileSuffixToTypeMapping := Dictionary new
+    ].
+    FilenameToTypeMapping isNil ifTrue:[
+        FilenameToTypeMapping := Dictionary new.
+    ].
+
+    types := OrderedCollection new.
+    types addAll:self textTypeList.
+    types addAll:self imageTypeList.
+    types addAll:self videoTypeList.
+    types addAll:self audioTypeList.
+    types addAll:self applicationTypeList.
+    types pairWiseDo:[:suff :typeString|
+        |type|
+
+        type := MIMEType fromString:typeString.
+        suff isArray ifTrue:[
+            suff do:[:s | FileSuffixToTypeMapping at:s put:type]
+        ] ifFalse:[
+            FileSuffixToTypeMapping at:suff put:type
+        ]
+    ].
+
+    self miscFilenameList pairWiseDo:[:nm :typeString|
+        |type|
+
+        type := MIMEType fromString:typeString.
+        nm isArray ifTrue:[
+            nm do:[:s | FilenameToTypeMapping at:s put:type]
+        ] ifFalse:[
+            FilenameToTypeMapping at:nm put:type
+        ]
+    ].
+!
+
+initializeImageReaderMappings
+    FileSuffixToImageReaderClassMapping isNil ifTrue:[
+        FileSuffixToImageReaderClassMapping := Dictionary new
+    ].
+    "MIME" TypeToImageReaderClassMapping isNil ifTrue:[
+        TypeToImageReaderClassMapping := Dictionary new
+    ].
+
+    "/ setup mimeType to image reader class mapping ...
+
+    TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
+    TypeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
+    TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
+
+    "/ setup suffix to image reader class mapping ...
+
+    FileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
+    FileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
+    FileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
+! !
+
+!MIMETypes class methodsFor:'initialization-lists'!
+
+applicationCompressorsAndArchiveTypeList
     ^ #(
-
         'tar'                   'application/x-tar'
         'gtar'                  'application/x-gtar'
         'tgz'                   'application/x-tar-compressed'
@@ -146,15 +313,15 @@
 applicationTypeList
     "applications"
 
-    |typeStrings|                            
+    |typeList|                            
 
-    typeStrings := OrderedCollection new.
-    typeStrings addAll:self applicationProgLangTypeList.
-    typeStrings addAll:self applicationTextTypeList.
-    typeStrings addAll:self applicationComprAndArchiveTypeList.
-    typeStrings addAll:self applicationMiscTypeList.
+    typeList := OrderedCollection new.
+    typeList addAll:self applicationProgLangTypeList.
+    typeList addAll:self applicationTextTypeList.
+    typeList addAll:self applicationCompressorsAndArchiveTypeList.
+    typeList addAll:self applicationMiscTypeList.
 
-    ^ typeStrings
+    ^ typeList
 !
 
 audioTypeList
@@ -195,123 +362,6 @@
     ) 
 !
 
-initialize
-    "initialize wellKnown facts"
-
-    |typeToImageReaderClassMapping fileSuffixToTypeMapping
-     fileSuffixToImageReaderClassMapping charSetToFontMapping types|
-
-    MIMEType initialize.   "must be initialized first"
-    LastSuffix := LastType := nil.
-
-    (fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
-        FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
-    ].
-    (typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
-        TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
-    ].
-    (fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
-        FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
-    ].
-
-    "/ setup file-suffix to mimeType mapping ...
-
-    types := OrderedCollection new.
-    types addAll:self textTypeList.
-    types addAll:self imageTypeList.
-    types addAll:self videoTypeList.
-    types addAll:self audioTypeList.
-    types addAll:self applicationTypeList.
-    types pairWiseDo:[:suff :typeString|
-        |type|
-
-        type := MIMEType fromString:typeString.
-        suff isArray ifTrue:[
-            suff do:[:s | fileSuffixToTypeMapping at:s put:type]
-        ] ifFalse:[
-            fileSuffixToTypeMapping at:suff put:type
-        ]
-    ].
-
-    FilenameToTypeMapping := Dictionary new.
-    self miscFilenameList pairWiseDo:[:nm :typeString|
-        |type|
-
-        type := MIMEType fromString:typeString.
-        nm isArray ifTrue:[
-            nm do:[:s | FilenameToTypeMapping at:s put:type]
-        ] ifFalse:[
-            FilenameToTypeMapping at:nm put:type
-        ]
-    ].
-
-    "/ setup mimeType to image reader class mapping ...
-
-    typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
-    typeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
-    typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
-
-    "/ setup suffix to image reader class mapping ...
-
-    fileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
-    fileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
-    fileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
-
-
-    "/ character sets (not really mime stuff, but also placed here)
-
-    (charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
-        CharSetToFontMapping := charSetToFontMapping := Dictionary new
-    ].
-
-    #(
-        'iso2022-jp'   'jis*0208*'
-        'x-iso2022-jp' 'jis*0208*'
-        'x-euc-jp'     'jis*0208*'
-        'x-shift-jis'  'jis*0208*'
-        'x-sjis'       'jis*0208*'
-        'x-jis7'       'jis*0208*'
-        'jis7'         'jis*0208*'
-        'euc'          'jis*0208*'
-        'euc-jp'       'jis*0208*'
-        'sjis'         'jis*0208*'
-
-        'big5'         'big5*'
-
-        'gb2312'       'gb*'
-        'hz-gb-2312'   'gb*'
-        'x-gbk'        'gb*'
-
-        'iso2022-kr'   'ksc*'
-        'x-euc-kr'     'ksc*'
-    ) pairWiseDo:[:charSet :fontEncoding|
-         charSetToFontMapping at:charSet put:fontEncoding
-    ].
-
-    "
-     self initialize
-    "
-
-    "Modified: / 19.11.1999 / 15:01:53 / cg"
-!
-
-initializeDefaultCommands
-    "TODO: move this to OS"
-
-    |unixCommands win32Commands|
-
-    DefaultCommandPerMIMEPerOS := Dictionary new.
-    DefaultCommandPerMIMEPerOS at:#unix  put:(unixCommands := Dictionary new).
-    DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new).
-
-    unixCommands at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
-    unixCommands at:'application/pdf'              put:'acroread -display %2 %1'.
-
-    "
-     self initializeDefaultCommands
-    "
-!
-
 miscFilenameList
     "other formats (not by suffix, but by fileName isnstead) ..."
 
@@ -346,137 +396,26 @@
     )
 ! !
 
-!MIMETypes class methodsFor:'accessing'!
-
-commentStringsForFilename:aFilename
-    "return a useful comment definition; heuristics for now.
-     The returned value is an array of 2 elements;
-     the first is the end-of-line comment string (or nil);
-     the second an array of opening/closing delimiters (or an array of nils)"
-
-     |mime|
-
-     mime := MIMETypes mimeTypeForFilename:aFilename.
-     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
-
-    "
-     MIMETypes commentStringsForFilename:'Makefile'.
-     MIMETypes commentStringsForFilename:'Object.st'. 
-     MIMETypes commentStringsForFilename:'Foo.java'. 
-    "
-!
-
-commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
-    "return a useful comment definition; heuristics for now.
-     The returned value is an array of 2 elements;
-     the first is the end-of-line comment string (or nil);
-     the second an array of opening/closing delimiters (or an array of nils)"
+!MIMETypes class methodsFor:'obsolete'!
 
-     |mime|
-
-     mime := MIMETypes mimeTypeForFilename:aFilename.
-     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
-
-    "
-     MIMETypes commentStringsForFilename:'Makefile'.
-     MIMETypes commentStringsForFilename:'Object.st'. 
-     MIMETypes commentStringsForFilename:'Foo.java'. 
-    "
-!
+fontForCharset:aCharSetName
+    "return the font-encoding for an iso-charset"
 
-commentStringsForMimeType:mime suffix:suff
-    "return a useful comment definition; heuristics for now.
-     The returned value is an array of 2 elements;
-     the first is the end-of-line comment string (or nil);
-     the second an array of opening/closing delimiters (or an array of nils)"
-
-    ^ self
-        commentStringsForMimeType:mime suffix:suff 
-        ifUnknown: #(';' (nil nil))  
-
-    "
-     |mime|
-
-     mime := MIMETypes mimeTypeForFilename:'Makefile'.
-     MIMETypes commentStringsForMimeType:mime suffix:nil.     
-    "
+    self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'.
+    ^ FontDescription fontNamePatternForCharset:aCharSetName.
 
     "
-     |mime|
-
-     mime := MIMETypes mimeTypeForFilename:'Object.st'.
-     MIMETypes commentStringsForMimeType:mime suffix:nil.    
-    "
-!
-
-commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
-    "return a useful comment definition; heuristics for now.
-     The returned value is an array of 2 elements;
-     the first is the end-of-line comment string (or nil);
-     the second an array of opening/closing delimiters (or an array of nils)"
-
-    (mime = 'application/x-make') ifTrue:[
-        "/ makefile
-        ^ #('#' (nil nil)).
-    ].
-    (mime = 'application/x-sh') ifTrue:[
-        "/ shell script
-        ^ #('#' (nil nil)).
-    ].
-    ((mime = 'text/html') 
-    or:[(mime = 'text/xml')
-    or:[(mime = 'application/xml')]]) ifTrue:[
-        ^ #(nil ('<!!-- ' ' -->')).
-    ].
-    (mime = 'application/x-batch-script') ifTrue:[
-        ^ #('rem ' (nil nil)).
-    ].
-    (mime = 'application/x-smalltalk-source') ifTrue:[
-        ^ #('"/' ('"' '"')).
-    ].
-    (mime = 'application/x-pascal-source') ifTrue:[
-        ^ #(nil ('{' '}')).
-    ].
-    (mime = 'application/x-c-source') ifTrue:[
-        ^ #(nil ('/*' '*/')).
-    ].
-    (mime = 'application/x-cpp-source') ifTrue:[
-        ^ #('//' ('/*' '*/')).
-    ].
-    (mime = 'application/x-java-source') ifTrue:[
-        ^ #('//' ('/*' '*/')).
-    ].
-    (mime = 'application/x-asn1-source') ifTrue:[
-        ^ #('--' ('--' '--')).
-    ].
-
-    "/ st/x support files
-    (suff = 'style') ifTrue:[
-        ^ #(';' (nil nil)).
-    ].
-    (suff = 'rs') ifTrue:[
-        ^ #(';' (nil nil)).
-    ].
-
-    ^ alternativeBlockReturningCommentString value
-
-    "
-     |mime|
-
-     mime := MIMETypes mimeTypeForFilename:'Makefile'.
-     MIMETypes commentStringsForMimeType:mime suffix:nil.     
+     MIMETypes fontForCharset:'iso2022-jp'       
+     MIMETypes fontForCharset:'euc-jp'     
     "
 
-    "
-     |mime|
+    "Modified: / 1.8.1998 / 17:00:57 / cg"
+! !
 
-     mime := MIMETypes mimeTypeForFilename:'Object.st'.
-     MIMETypes commentStringsForMimeType:mime suffix:nil.    
-    "
-!
+!MIMETypes class methodsFor:'queries'!
 
 defaultCommandPerMIME
-    "TODO: move this to OS"
+    "TODO: move this to OS/UserPreferences"
 
     DefaultCommandPerMIMEPerOS isNil ifTrue:[
         self initializeDefaultCommands
@@ -511,19 +450,6 @@
     "Modified: / 1.8.1998 / 17:00:11 / cg"
 !
 
-fontForCharset:aCharSet
-    "return the font-encoding for an iso-charset"
-
-    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil
-
-    "
-     MIMETypes fontForCharset:'iso2022-jp'       
-     MIMETypes fontForCharset:'euc-jp'     
-    "
-
-    "Modified: / 1.8.1998 / 17:00:57 / cg"
-!
-
 imageFileSuffixes
     "return a collection with known file suffixes"
 
@@ -534,72 +460,6 @@
     "Modified: / 1.8.1998 / 17:01:26 / cg"
 !
 
-imageReaderClasses
-    "return a collection of registered image reader classes"
-
-    |setOfClasses|
-
-    setOfClasses := IdentitySet new.
-    FileSuffixToImageReaderClassMapping notNil ifTrue:[
-        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
-            setOfClasses add:cls
-        ].
-    ].
-    TypeToImageReaderClassMapping notNil ifTrue:[
-        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
-            setOfClasses add:cls
-        ].
-    ].
-    ^ setOfClasses
-
-    "Created: / 30.6.1997 / 22:03:42 / cg"
-    "Modified: / 1.8.1998 / 16:59:52 / cg"
-!
-
-imageReaderForSuffix:aSuffix
-    "given a file suffix, return an approriate image reader class"
-
-    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
-    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
-
-    "Created: / 30.6.1997 / 21:59:11 / cg"
-    "Modified: / 1.8.1998 / 17:01:58 / cg"
-!
-
-imageReaderForSuffix:aSuffix put:aReaderClass
-    "register an image reader for a file suffix"
-
-    FileSuffixToImageReaderClassMapping isNil ifTrue:[
-        FileSuffixToImageReaderClassMapping := Dictionary new.
-    ].
-    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
-
-    "Created: / 30.6.1997 / 21:59:43 / cg"
-    "Modified: / 1.8.1998 / 17:02:14 / cg"
-!
-
-imageReaderForType:mimeTypeString
-    "given a mime-type, return an approriate image reader class"
-
-    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
-    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
-
-    "Created: / 30.6.1997 / 21:56:01 / cg"
-    "Modified: / 1.8.1998 / 17:02:28 / cg"
-!
-
-imageReaderForType:mimeTypeString put:aReaderClass
-    "register an image reader for a mime-type"
-
-    TypeToImageReaderClassMapping isNil ifTrue:[
-        TypeToImageReaderClassMapping := Dictionary new.
-    ].
-    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
-
-    "Created: / 30.6.1997 / 21:56:11 / cg"
-    "Modified: / 1.8.1998 / 17:02:40 / cg"
-!
-
 mimeTypeForFilename:filenameArg
     "given a filename, return the mime-type or nil, if unknown"
 
@@ -709,6 +569,172 @@
     ^ MIMEType fromString:typeString.
 ! !
 
+!MIMETypes class methodsFor:'queries-image formats'!
+
+imageReaderClasses
+    "return a collection of registered image reader classes"
+
+    |setOfClasses|
+
+    setOfClasses := IdentitySet new.
+    FileSuffixToImageReaderClassMapping notNil ifTrue:[
+        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
+            setOfClasses add:cls
+        ].
+    ].
+    TypeToImageReaderClassMapping notNil ifTrue:[
+        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
+            setOfClasses add:cls
+        ].
+    ].
+    ^ setOfClasses
+
+    "Created: / 30.6.1997 / 22:03:42 / cg"
+    "Modified: / 1.8.1998 / 16:59:52 / cg"
+!
+
+imageReaderForSuffix:aSuffix
+    "given a file suffix, return an approriate image reader class"
+
+    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
+    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
+
+    "Created: / 30.6.1997 / 21:59:11 / cg"
+    "Modified: / 1.8.1998 / 17:01:58 / cg"
+!
+
+imageReaderForSuffix:aSuffix put:aReaderClass
+    "register an image reader for a file suffix"
+
+    FileSuffixToImageReaderClassMapping isNil ifTrue:[
+        FileSuffixToImageReaderClassMapping := Dictionary new.
+    ].
+    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
+
+    "Created: / 30.6.1997 / 21:59:43 / cg"
+    "Modified: / 1.8.1998 / 17:02:14 / cg"
+!
+
+imageReaderForType:mimeTypeString
+    "given a mime-type, return an approriate image reader class"
+
+    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
+    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
+
+    "Created: / 30.6.1997 / 21:56:01 / cg"
+    "Modified: / 1.8.1998 / 17:02:28 / cg"
+!
+
+imageReaderForType:mimeTypeString put:aReaderClass
+    "register an image reader for a mime-type"
+
+    TypeToImageReaderClassMapping isNil ifTrue:[
+        TypeToImageReaderClassMapping := Dictionary new.
+    ].
+    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
+
+    "Created: / 30.6.1997 / 21:56:11 / cg"
+    "Modified: / 1.8.1998 / 17:02:40 / cg"
+! !
+
+!MIMETypes class methodsFor:'queries-language syntax'!
+
+commentStringsForFilename:aFilename
+    "return a useful comment definition; heuristics for now.
+     The returned value is an array of 2 elements;
+     the first is the end-of-line comment string (or nil);
+     the second an array of opening/closing delimiters (or an array of nils)"
+
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:aFilename.
+     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
+
+    "
+     MIMETypes commentStringsForFilename:'Makefile'.
+     MIMETypes commentStringsForFilename:'Object.st'. 
+     MIMETypes commentStringsForFilename:'Foo.java'. 
+    "
+!
+
+commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
+    "return a useful comment definition; heuristics for now.
+     The returned value is an array of 2 elements;
+     the first is the end-of-line comment string (or nil);
+     the second an array of opening/closing delimiters (or an array of nils)"
+
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:aFilename.
+     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
+
+    "
+     MIMETypes commentStringsForFilename:'Makefile'.
+     MIMETypes commentStringsForFilename:'Object.st'. 
+     MIMETypes commentStringsForFilename:'Foo.java'. 
+    "
+!
+
+commentStringsForMimeType:mime suffix:suff
+    "return a useful comment definition; heuristics for now.
+     The returned value is an array of 2 elements;
+     the first is the end-of-line comment string (or nil);
+     the second an array of opening/closing delimiters (or an array of nils)"
+
+    ^ self
+        commentStringsForMimeType:mime suffix:suff 
+        ifUnknown: #(';' (nil nil))  
+
+    "
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:'Makefile'.
+     MIMETypes commentStringsForMimeType:mime suffix:nil.     
+    "
+
+    "
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:'Object.st'.
+     MIMETypes commentStringsForMimeType:mime suffix:nil.    
+    "
+!
+
+commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
+    "return a useful comment definition; heuristics for now.
+     The returned value is an array of 2 elements;
+     the first is the end-of-line comment string (or nil);
+     the second an array of opening/closing delimiters (or an array of nils)"
+
+    |commentSpec|
+
+    commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil.
+    commentSpec notNil ifTrue:[
+        ^ commentSpec
+    ].
+
+    commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil.
+    commentSpec notNil ifTrue:[
+        ^ commentSpec
+    ].
+
+    ^ alternativeBlockReturningCommentString value
+
+    "
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:'Makefile'.
+     MIMETypes commentStringsForMimeType:mime suffix:nil.     
+    "
+
+    "
+     |mime|
+
+     mime := MIMETypes mimeTypeForFilename:'Object.st'.
+     MIMETypes commentStringsForMimeType:mime suffix:nil.    
+    "
+! !
+
 !MIMETypes::MIMEType class methodsFor:'documentation'!
 
 documentation
@@ -750,7 +776,7 @@
 isArchive
     |archivTypes|
 
-    archivTypes := MIMETypes applicationComprAndArchiveTypeList.
+    archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList.
     archivTypes pairWiseDo:[: ext : type |
         self = type ifTrue:[ ^ true].
     ].
@@ -778,7 +804,7 @@
 !MIMETypes class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.51 2003-03-21 16:55:03 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.52 2003-03-28 11:30:35 cg Exp $'
 ! !
 
 MIMETypes initialize!