Class ContentCharsetFinder
java.lang.Object
org.alfresco.repo.content.encoding.ContentCharsetFinder
Utility bean to guess the charset given a stream and a mimetype.
- Since:
- 2.1
- Author:
- Derek Hulley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCharset(InputStream is, String mimetype) Gets the characterset from the stream, if the mimetype is text and the text has enough information to give the encoding away.voidsetCharactersetFinders(List<CharactersetFinder> charactersetFinders) Set the list of characterset finder to execute, in order, for text based content.voidsetDefaultCharset(String defaultCharset) Override the system default charset.voidsetMimetypeService(MimetypeService mimetypeService) Set the mimetype service that will help determine if a particular mimetype can be treated as encoded text or not.
-
Constructor Details
-
ContentCharsetFinder
public ContentCharsetFinder()
-
-
Method Details
-
setDefaultCharset
Override the system default charset. Where the characterset cannot be determined for a mimetype and input stream, this mimetype will be used. The default is 'UTF-8'.- Parameters:
defaultCharset- the default characterset
-
setMimetypeService
Set the mimetype service that will help determine if a particular mimetype can be treated as encoded text or not. -
setCharactersetFinders
Set the list of characterset finder to execute, in order, for text based content.- Parameters:
charactersetFinders- a list of finders
-
getCharset
Gets the characterset from the stream, if the mimetype is text and the text has enough information to give the encoding away. Otherwise, the default is returned.- Parameters:
is- a stream that will not be affected by the call, but must support markingmimetype- the mimetype of the stream data - null if not known- Returns:
- returns a characterset and never null
-