Top Description Fields Constructors Methods
org.apache.catalina.util

public Class CharsetMapper

extends Object
Class Inheritance
Imports
java.io.InputStream, java.util.Locale, .Properties, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.compat.JreCompat

Utility class that attempts to map from a Locale to the corresponding character set to be used for interpreting input text (or generating output text) when the Content-Type header does not include one. You can customize the behavior of this class by modifying the mapping data it loads, or by subclassing it (to change the algorithm) and then using your own version for a particular web application.
Author
Craig R. McClanahan

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_RESOURCE

Default properties resource name.

private Properties
map

The mapping properties that have been initialized from the specified or default properties resource.

Constructor Summary

AccessConstructor and Description
public
CharsetMapper()

Construct a new CharsetMapper using the default properties resource.

public
CharsetMapper(String
Name of a properties resource to be loaded
name
)

Construct a new CharsetMapper using the specified properties resource.

Method Summary

Modifier and TypeMethod and Description
public void
addCharsetMappingFromDeploymentDescriptor(String
The locale for a character set
locale
,
String
The charset to be associated with the locale
charset
)

The deployment descriptor can have a locale-encoding-mapping-list element which describes the webapp's desired mapping from locale to charset.

public String

Returns:

the charset name
getCharset
(Locale
The locale for which to calculate a character set
locale
)

Calculate the name of a character set to be assumed, given the specified Locale and the absence of a character set specified as part of the content type header.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_RESOURCEback to summary
public static final String DEFAULT_RESOURCE

Default properties resource name.

mapback to summary
private Properties map

The mapping properties that have been initialized from the specified or default properties resource.

Constructor Detail

CharsetMapperback to summary
public CharsetMapper()

Construct a new CharsetMapper using the default properties resource.

CharsetMapperback to summary
public CharsetMapper(String name)

Construct a new CharsetMapper using the specified properties resource.

Parameters
name:String

Name of a properties resource to be loaded

Exceptions
IllegalArgumentException:
if the specified properties resource could not be loaded for any reason.

Method Detail

addCharsetMappingFromDeploymentDescriptorback to summary
public void addCharsetMappingFromDeploymentDescriptor(String locale, String charset)

The deployment descriptor can have a locale-encoding-mapping-list element which describes the webapp's desired mapping from locale to charset. This method gets called when processing the web.xml file for a context

Parameters
locale:String

The locale for a character set

charset:String

The charset to be associated with the locale

getCharsetback to summary
public String getCharset(Locale locale)

Calculate the name of a character set to be assumed, given the specified Locale and the absence of a character set specified as part of the content type header.

Parameters
locale:Locale

The locale for which to calculate a character set

Returns:String

the charset name