Class ContentCharsetFinder
- java.lang.Object
-
- org.alfresco.repo.content.encoding.ContentCharsetFinder
-
public class ContentCharsetFinder extends Object
Utility bean to guess the charset given a stream and a mimetype.- Since:
- 2.1
- Author:
- Derek Hulley
-
-
Constructor Summary
Constructors Constructor Description ContentCharsetFinder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Charset
getCharset(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.void
setCharactersetFinders(List<CharactersetFinder> charactersetFinders)
Set the list of characterset finder to execute, in order, for text based content.void
setDefaultCharset(String defaultCharset)
Override the system default charset.void
setMimetypeService(MimetypeService mimetypeService)
Set the mimetype service that will help determine if a particular mimetype can be treated as encoded text or not.
-
-
-
Method Detail
-
setDefaultCharset
public void setDefaultCharset(String defaultCharset)
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
public void setMimetypeService(MimetypeService mimetypeService)
Set the mimetype service that will help determine if a particular mimetype can be treated as encoded text or not.
-
setCharactersetFinders
public void setCharactersetFinders(List<CharactersetFinder> charactersetFinders)
Set the list of characterset finder to execute, in order, for text based content.- Parameters:
charactersetFinders
- a list of finders
-
getCharset
public Charset getCharset(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. 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
-
-