org.alfresco.repo.content.encoding
Class ContentCharsetFinder

java.lang.Object
  extended by org.alfresco.repo.content.encoding.ContentCharsetFinder

public class ContentCharsetFinder
extends java.lang.Object

Utility bean to guess the charset given a stream and a mimetype.

Since:
2.1

Constructor Summary
ContentCharsetFinder()
           
 
Method Summary
 java.nio.charset.Charset getCharset(java.io.InputStream is, java.lang.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(java.util.List charactersetFinders)
          Set the list of characterset finder to execute, in order, for text based content.
 void setDefaultCharset(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentCharsetFinder

public ContentCharsetFinder()
Method Detail

setDefaultCharset

public void setDefaultCharset(java.lang.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(java.util.List charactersetFinders)
Set the list of characterset finder to execute, in order, for text based content.

Parameters:
charactersetFinders - a list of finders

getCharset

public java.nio.charset.Charset getCharset(java.io.InputStream is,
                                           java.lang.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 marking
mimetype - the mimetype of the stream data - null if not known
Returns:
returns a characterset and never null


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.