Enhydra-Oyster 2.1-7 API

org.enhydra.oyster.mail
Class ContentAnalyzer

java.lang.Object
  extended byorg.enhydra.oyster.mail.ContentAnalyzer

public class ContentAnalyzer
extends java.lang.Object

Analyzes content which will be placed in MimeBodyPart and suggests which Content-Transfer-Encoding header parameter should be used (7bit, quoted-printable or base64). ContentAnalyzer makes the following checks, and according to them decisions about which Content-Transfer-Encoding to suggest:

7bit: if all checked characters (or bytes) are in group of ASCII characters which are less than 127 (7F hexadecimal) and higher than 31 (1F hexadecimal). Characters: HT (Horizontal Tab) 9 (09 hexadecimal), and combinaton of CR (Carriage Return) 13 (0D hexadecimal) and LF (Line Feed) 11 (0A hexadecimal) are also allowed. Single usage of CR or LF characters or it's combination LFCR are not permitted for this type Content-Transfer-Encoding. Also, acording to RFC822, no line should be longer than 1000 characters with included trailing CRLF charachters.

quoted-printable: if at least one character does not satisfy previous condition, and if number of those characters do not exceed 30 percent of all characters.

base64: if number of those characters which do not satisfy 7bit condition exceed 30 percent of all characters.


Constructor Summary
ContentAnalyzer()
          Simple constructor.
 
Method Summary
 void analyse()
          Performs analyze of content data and accoding to that decides which Content-Transfer-Encoding to suggesst.
 java.lang.String getPreferedEncoding()
          Returns suggested encoding, after finished analyze.
 void isCharFor7BitEncoding(int dataToCheck)
          Method checks one charachter passed as integer, if it passes condition for implementation of 7bit Content-Transfer-Encoding.
 void isFor7BitEncoding(java.io.File fileToCheck)
          Method checks data passed from File which will be used later in the process of creation of content in MimeBodyPart, if it passes condition for implementation of 7bit Content-Transfer-Encoding.
 void isFor7BitEncoding(java.io.InputStream dataToCheck)
          Method checks data passed as InputStream which will be used later in the process of creation of content in MimeBodyPart, if it passes condition for implementation of 7bit Content-Transfer-Encoding.
 void reset()
          Resets all storaged values in ContentAnalyzer object to default values and prepares object for new use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentAnalyzer

public ContentAnalyzer()
Simple constructor.

Method Detail

isCharFor7BitEncoding

public void isCharFor7BitEncoding(int dataToCheck)
Method checks one charachter passed as integer, if it passes condition for implementation of 7bit Content-Transfer-Encoding. For checking content data which is constructed from more than one byte, this method must be called in loop for every byte that belongs to examined content data.

Parameters:
dataToCheck - integer represetation of passed byte for check

isFor7BitEncoding

public void isFor7BitEncoding(java.io.InputStream dataToCheck)
                       throws SMIMEException
Method checks data passed as InputStream which will be used later in the process of creation of content in MimeBodyPart, if it passes condition for implementation of 7bit Content-Transfer-Encoding.

Parameters:
dataToCheck - content data which has to be checked represented as InputStream
Throws:
SMIMEException - caused by non SMIMEException which is IOException

isFor7BitEncoding

public void isFor7BitEncoding(java.io.File fileToCheck)
                       throws SMIMEException
Method checks data passed from File which will be used later in the process of creation of content in MimeBodyPart, if it passes condition for implementation of 7bit Content-Transfer-Encoding.

Parameters:
fileToCheck - pointer to file which data has to be checked.
Throws:
SMIMEException - caused by non SMIMEException which is IOException

analyse

public void analyse()
Performs analyze of content data and accoding to that decides which Content-Transfer-Encoding to suggesst.


getPreferedEncoding

public java.lang.String getPreferedEncoding()
Returns suggested encoding, after finished analyze.

Returns:
the name of Content-Transfer-Encoding header parameter which can take values: 7bit, quoted-printable, base64 or null in case of error.

reset

public void reset()
Resets all storaged values in ContentAnalyzer object to default values and prepares object for new use.


Enhydra-Oyster 2.1-7 API