Mimetype Service

MIMEタイプサービス

The MimeType Service maintains mappings between MIME types and the corresponding file name extensions, and between locales and character encodings. The mappings are typically defined in properties or files located in user's home directory, Java home directory or the current class jar depending on the implementation.

MIMEタイプサービスはMIMEタイプと一致するファイル名の拡張子、 ロケールとキャラクタエンコーディングのマッピングを保持します。 マッピングは通常、ユーザのホームディレクトリ、Javaのホームディレクトリ、 または実行時に依存しているjarに存在するプロパティまたはファイルで定義されます。

Configuration

設定

# -------------------------------------------------------------------
#
#  S E R V I C E S
#
# -------------------------------------------------------------------

# Classes for Turbine Services should be defined here.
# Format: services.[name].classname=[implementing class]
#
# To specify properties of a service use the following syntax:
# service.[name].[property]=[value]

# Turbineのサービスのためのクラス群はここに定義します。
# フォーマット: services.[name].classname=[implementing class]
#
# サービスのプロパティを設定するには、以下の書式を使用します:
# service.[name].[property]=[value]

services.MimeTypeService.classname=org.apache.fulcrum.mimetype.TurbineMimeTypeService
.
.
.
# -------------------------------------------------------------------
#
#  M I M E T Y P E  S E R V I C E
#
# -------------------------------------------------------------------


# This property specifies a file containing mappings between MIME
# content types and the corresponding file name extensions. The
# service itself contains a hardcoded set of most common mappings.
# The file must use the same syntax as the mime.types file of
# the Apache Server, i.e.
# <mimetype> <ext1> <ext2>...
#

# このプロパティはMIMEタイプと対応するファイル名の拡張子の
# マッピングを含んでいるファイルを指定します。
# サービスはそれ自身に、ハードコーディングされた
# ごく一般的なマッピングのセットを含んでいます。
# ファイルはApacheサーバのmime.typesと同じ書式を使用しなければなりません。
# すなわち、
# <mimetype> <ext1> <ext2>...
#
#services.MimeTypeService.mime.types=/WEB-INF/conf/mime.types


# This property specifies a file containing mappings between locales
# and the corresponding character encodings. The service itself
# contains a hardcoded set of most common mappings.
# The file should use the Java property file syntax, i.e.
# <lang_country_variant>=<charset>
#

# このプロパティはロケールと対応するキャラクタエンコーディングの
# マッピングを含んでいるファイルを指定します。
# サービスはそれ自身に、ハードコーディングされた
# ごく一般的なマッピングのセットを含んでいます。
# ファイルはJavaのプロパティファイルの書式を用います。
# すなわち、
# <lang_country_variant>=<charset>
#
#services.MimeTypeService.charsets=/WEB-INF/conf/charset.properties

Usage

使用方法

The default RunData implementation uses the MimeType Service internally when resolving the character encoding of the servlet response. In addition, applications can use it for customized encoding and content type resolving.

デフォルトのRunDataの実装は、サーブレットレスポンスのキャラクタエンコーディングを解決するときにMIMEタイプサービスを内部的に使用します。 さらに、アプリケーションもエンコーディングとコンテントタイプのカスタマイズに使用することができます。

The mappings between locales and the corresponding character encodings are specified using the Java property file syntax, where the locale specification is the key of the property key and the charset is the value of the property. The locale specification consists of three parts:

ロケールと対応するキャラクタエンコーディングのマッピングは、Javaのプロパティファイルの書式を用いて指定され、ロケールの設定はプロパティーのキー、キャラクタセットはプロパティの値の部分となります。 ロケールの設定は3つの部分で構成されます:

<lang>_<country>_<variant>

The variant can be whatever is appropriate for the application, like a markup language specification, a browser specification, etc. The service looks for charsets using the following search order:

variantはマークアップ言語の仕様、ブラウザの仕様等のような、アプリケーションにとって適当であるどんなものにでもなります。 サービスはキャラクタセットを以下の検索順で探します。

<lang>_<country>_<variant>=<charset>
_<country>_<variant>=<charset>
<lang>__<variant>=<charset>
__<variant>=<charset>
<lang>_<country>=<charset>
_<country>=<charset>
<lang>=<charset>

The service contains defaults for several language mappings and more specific ones can be specified in an optional property file, e.g. __wml=UTF-8. The name of the property file can be given with a service property named "charsets". The service caches results of the search, which should guarantee good performance.

サービスはいくつかの言語のマッピングのデフォルトと、より多くの設定(例えば、__wml=UTF-8)を指定できるオプションのプロパティファイル含みます。 プロパティファイルの名前はサービスのプロパティ、"charsets"で指定することができます。 サービスはパフォーマンスの向上を保証するべきであり、検索の結果をキャッシュします。

The mappings between MIME types and the corresponding file name extensions are specified using the same syntax as the mime.types file of the Apache Server, i.e.:

MIMEタイプと一致するファイル名の拡張子のマッピングは、 ファイルはApacheサーバのmime.typesと同じ書式を使用して設定されます。 すなわち:

<mimetype> <ext1> <ext2>...

The service contains defaults for most common MIME types, like text/plain, text/html, text/x-hdml, text/vnd.wap.wml, image/gif and image/jpeg. More specific ones can be specified in an optional MIME types file. The name of the MIME types file can be given with a service property named "mime.types".

サービスはtext/plain、text/html、text/x-hdml、text/vnd.wap.wml、image/gifや、image/jpegなどのごく一般的なMIMEタイプのデフォルトを含みます。 より多くの設定は、オプションのMIMEタイプファイルに指定できます。 MIMEタイプファイルの名前はサービスのプロパティ、"mime.types"で指定することができます。

The TurbineMimeTypes class is a static accessor for the most common MimeType Service methods.

TurbineMimeTypesクラスは一般的なMIMEタイプサービスメソッドのための静的なアクセッサです。