org.apache.geronimo.mail.util
Class RFC2231Encoder

java.lang.Object
  extended by org.apache.geronimo.mail.util.RFC2231Encoder
All Implemented Interfaces:
Encoder

public class RFC2231Encoder
extends Object
implements Encoder

Encoder for RFC2231 encoded parameters RFC2231 string are encoded as charset'language'encoded-text and encoded-text = *(char / hexchar) where char is any ASCII character in the range 33-126, EXCEPT the characters "%" and " ". hexchar is an ASCII "%" followed by two upper case hexadecimal digits.


Field Summary
protected  byte[] decodingTable
           
protected  String DEFAULT_SPECIALS
           
protected  byte[] encodingTable
           
protected  String specials
           
 
Constructor Summary
RFC2231Encoder()
           
RFC2231Encoder(String specials)
           
 
Method Summary
 int decode(byte[] data, int off, int length, OutputStream out)
          decode the RFC2231 encoded byte data writing it to the given output stream
 String decode(String data)
          Decode an RFC2231 encoded string.
 int decode(String data, OutputStream out)
          decode the RFC2231 encoded String data writing it to the given output stream.
 int encode(byte[] data, int off, int length, OutputStream out)
          encode the input data producing an RFC2231 output stream.
 String encode(String charset, String language, String data)
          Encode a string as an RFC2231 encoded parameter, using the given character set and language.
protected  void initialiseDecodingTable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encodingTable

protected final byte[] encodingTable

DEFAULT_SPECIALS

protected String DEFAULT_SPECIALS

specials

protected String specials

decodingTable

protected final byte[] decodingTable
Constructor Detail

RFC2231Encoder

public RFC2231Encoder()

RFC2231Encoder

public RFC2231Encoder(String specials)
Method Detail

initialiseDecodingTable

protected void initialiseDecodingTable()

encode

public int encode(byte[] data,
                  int off,
                  int length,
                  OutputStream out)
           throws IOException
encode the input data producing an RFC2231 output stream.

Specified by:
encode in interface Encoder
Returns:
the number of bytes produced.
Throws:
IOException

decode

public int decode(byte[] data,
                  int off,
                  int length,
                  OutputStream out)
           throws IOException
decode the RFC2231 encoded byte data writing it to the given output stream

Specified by:
decode in interface Encoder
Returns:
the number of bytes produced.
Throws:
IOException

decode

public int decode(String data,
                  OutputStream out)
           throws IOException
decode the RFC2231 encoded String data writing it to the given output stream.

Specified by:
decode in interface Encoder
Returns:
the number of bytes produced.
Throws:
IOException

encode

public String encode(String charset,
                     String language,
                     String data)
              throws IOException
Encode a string as an RFC2231 encoded parameter, using the given character set and language.

Parameters:
charset - The source character set (the MIME version).
language - The encoding language.
data - The data to encode.
Returns:
The encoded string.
Throws:
IOException

decode

public String decode(String data)
              throws IOException,
                     UnsupportedEncodingException
Decode an RFC2231 encoded string.

Parameters:
data - The data to decode.
Returns:
The decoded string.
Throws:
IOException
UnsupportedEncodingException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.