| java.lang.Object org.apache.turbine.services.mimetype.util.CharSetMap
CharSetMap | public class CharSetMap (Code) | | This class maintains a set of mappers defining mappings
between locales and the corresponding charsets. The mappings
are defined as properties between locale and charset names.
The definitions can be listed in property files located in user's
home directory, Java home directory or the current class jar.
In addition, this class maintains static default mappings
and constructors support application specific mappings.
author: Ilkka Priha version: $Id: CharSetMap.java 534527 2007-05-02 16:10:59Z tv $ |
Constructor Summary | |
public | CharSetMap() Constructs a new charset map with default mappers. | public | CharSetMap(Properties props) Contructs a charset map from properties. | public | CharSetMap(InputStream input) Contructs a charset map read from a stream. | public | CharSetMap(File file) Contructs a charset map read from a property file. | public | CharSetMap(String path) Contructs a charset map read from a property file path. |
CHARSET_RESOURCE | final public static String CHARSET_RESOURCE(Code) | | The name for charset mapper resources.
|
DEFAULT_CHARSET | final public static String DEFAULT_CHARSET(Code) | | The default charset when nothing else is applicable.
|
CharSetMap | public CharSetMap()(Code) | | Constructs a new charset map with default mappers.
|
CharSetMap | public CharSetMap(Properties props)(Code) | | Contructs a charset map from properties.
Parameters: props - charset mapping propeties. |
CharSetMap | public CharSetMap(InputStream input) throws IOException(Code) | | Contructs a charset map read from a stream.
Parameters: input - an input stream. throws: IOException - for an incorrect stream. |
CharSetMap | public CharSetMap(File file) throws IOException(Code) | | Contructs a charset map read from a property file.
Parameters: file - a property file. throws: IOException - for an incorrect property file. |
CharSetMap | public CharSetMap(String path) throws IOException(Code) | | Contructs a charset map read from a property file path.
Parameters: path - a property file path. throws: IOException - for an incorrect property file. |
getCharSet | public String getCharSet(Locale locale)(Code) | | Gets the charset for a locale. First a locale specific charset
is searched for, then a country specific one and lastly a language
specific one. If none is found, the default charset is returned.
Parameters: locale - the locale. the charset. |
getCharSet | public String getCharSet(Locale locale, String variant)(Code) | | Gets the charset for a locale with a variant. The search
is performed in the following order:
"lang"_"country"_"variant"="charset",
_"counry"_"variant"="charset",
"lang"__"variant"="charset",
__"variant"="charset",
"lang"_"country"="charset",
_"country"="charset",
"lang"="charset".
If nothing of the above is found, the default charset is returned.
Parameters: locale - the locale. Parameters: variant - a variant field. the charset. |
getCharSet | public String getCharSet(String key)(Code) | | Gets the charset for a specified key.
Parameters: key - the key for the charset. the found charset or the default one. |
getCharSet | public String getCharSet(String key, String def)(Code) | | Gets the charset for a specified key.
Parameters: key - the key for the charset. Parameters: def - the default charset if none is found. the found charset or the given default. |
loadFile | protected static Map loadFile(File file) throws IOException(Code) | | Loads mappings from a file.
Parameters: file - a file. the mappings. throws: IOException - for an incorrect file. |
loadPath | protected static Map loadPath(String path) throws IOException(Code) | | Loads mappings from a file path.
Parameters: path - a file path. the mappings. throws: IOException - for an incorrect file. |
loadResource | protected static Map loadResource(String name)(Code) | | Loads mappings from a resource.
Parameters: name - a resource name. the mappings. |
loadStream | protected static Map loadStream(InputStream input) throws IOException(Code) | | Loads mappings from a stream.
Parameters: input - an input stream. the mappings. throws: IOException - for an incorrect stream. |
setCharSet | public synchronized void setCharSet(String key, String charset)(Code) | | Sets a locale-charset mapping.
Parameters: key - the key for the charset. Parameters: charset - the corresponding charset. |
setCommonCharSet | protected synchronized void setCommonCharSet(String key, String charset)(Code) | | Sets a common locale-charset mapping.
Parameters: key - the key for the charset. Parameters: charset - the corresponding charset. |
|
|