public class ConfigurableMimeFileTypeMap extends FileTypeMapSE implements InitializingBean
MimetypesFileTypeMap
を使用して、標準の JavaMail MIME 型のマッピングファイルから MIME 型からファイル拡張子へのマッピングを読み取る、Spring で構成可能な FileTypeMap
実装。マッピングファイルは、Java Activation フレームワークで指定されている次の形式である必要があります。
# map text/html to .htm and .html files text/html html htm HTML HTM
#
で始まる行はコメントとして扱われ、無視されます。他のすべての行はマッピングとして扱われます。各マッピング行には、MIME 型を最初のエントリとして、次に各ファイル拡張子を後続のエントリとしてその MIME 型にマップする必要があります。各エントリはスペースまたはタブで区切られています。 デフォルトでは、このクラスと同じパッケージにある mime.types
ファイルのマッピングが使用され、多くの一般的なファイル拡張子をカバーします(activation.jar
のすぐに使用可能なマッピングとは対照的)。これは、mappingLocation
プロパティを使用してオーバーライドできます。
mime.types
ファイル形式に続く行として、mappings
Bean プロパティを介して追加のマッピングを追加できます。
setMappingLocation(org.springframework.core.io.Resource)
, setMappings(java.lang.String...)
, MimetypesFileTypeMap
SEコンストラクターと説明 |
---|
ConfigurableMimeFileTypeMap() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() 最終的なマージされたマッピングセットを作成します。 |
protected FileTypeMapSE | createFileTypeMap(Resource mappingLocation, StringSE[] mappings) 指定されたマッピングファイルのマッピングと指定されたマッピングエントリから FileTypeMap SE をコンパイルします。 |
StringSE | getContentType(FileSE file) 基になる FileTypeMap へのデリゲート。 |
StringSE | getContentType(StringSE fileName) 基になる FileTypeMap へのデリゲート。 |
protected FileTypeMapSE | getFileTypeMap() マッピングファイルのマッピングと mappings プロパティのエントリからコンパイルされたデリゲート FileTypeMap を返します。 |
void | setMappingLocation(Resource mappingLocation) マッピングのロード元の Resource を指定します。 |
void | setMappings(StringSE... mappings) Java Activation フレームワークで指定されているように、 mime.types ファイル形式に従う行として追加の MIME 型マッピングを指定します。 |
getDefaultFileTypeMapSE, setDefaultFileTypeMapSE
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setMappingLocation(Resource mappingLocation)
Resource
を指定します。Java Activation フレームワークで指定されている mime.types
ファイル形式に従う必要があり、次のような行が含まれます。
text/html html htm HTML HTM
public void setMappings(StringSE... mappings)
mime.types
ファイル形式に従う行として追加の MIME 型マッピングを指定します。例: text/html html htm HTML HTM
public void afterPropertiesSet()
InitializingBean
の afterPropertiesSet
protected final FileTypeMapSE getFileTypeMap()
mappings
プロパティのエントリからコンパイルされたデリゲート FileTypeMap を返します。protected FileTypeMapSE createFileTypeMap(@Nullable Resource mappingLocation, @Nullable StringSE[] mappings) throws IOExceptionSE
FileTypeMap
SE をコンパイルします。 デフォルトの実装では、アクティベーションフレームワーク MimetypesFileTypeMap
SE を作成し、マッピングリソース(存在する場合)から InputStream を渡し、マッピング行をプログラムで登録します。
mappingLocation
- mime.types
マッピングリソース (null
にすることができます)mappings
- MIME 型マッピング行の配列 (null
にすることができます)IOExceptionSE
- リソースへのアクセスに失敗した場合 MimetypesFileTypeMap.MimetypesFileTypeMap(java.io.InputStream)
SE, MimetypesFileTypeMap.addMimeTypes(String)
SEpublic StringSE getContentType(FileSE file)
FileTypeMapSE
の getContentTypeSE
getFileTypeMap()
public StringSE getContentType(StringSE fileName)
FileTypeMapSE
の getContentTypeSE
getFileTypeMap()