FileDocCategorySizeDatePackage
UTF7StyleCharset.javaAPI DocAndroid 1.5 API4239Wed May 06 22:42:46 BST 2009com.beetstra.jutf7

UTF7StyleCharset

public abstract class UTF7StyleCharset extends Charset

Abstract base class for UTF-7 style encoding and decoding.

author
Jaap Beetstra

Fields Summary
private static final List
CONTAINED
final boolean
strict
Base64Util
base64
Constructors Summary
protected UTF7StyleCharset(String canonicalName, String[] aliases, String alphabet, boolean strict)

Besides the name and aliases, two additional parameters are required. First the base 64 alphabet used; in modified UTF-7 a slightly different alphabet is used. Additionally, it should be specified if encoders and decoders should be strict about the interpretation of malformed encoded sequences. This is used since modified UTF-7 specifically disallows some constructs which are allowed (or not specifically disallowed) in UTF-7 (RFC 2152).

param
canonicalName The name as defined in java.nio.charset.Charset
param
aliases The aliases as defined in java.nio.charset.Charset
param
alphabet The base 64 alphabet used
param
strict True if strict handling of sequences is requested


                                                                                                              
          
              
        super(canonicalName, aliases);
        this.base64 = new Base64Util(alphabet);
        this.strict = strict;
    
Methods Summary
abstract booleancanEncodeDirectly(char ch)
Tells if a character can be encoded using simple (US-ASCII) encoding or requires base 64 encoding.

param
ch The character
return
True if the character can be encoded directly, false otherwise

public booleancontains(java.nio.charset.Charset cs)

        return CONTAINED.contains(cs.name());
    
public java.nio.charset.CharsetDecodernewDecoder()

        return new UTF7StyleCharsetDecoder(this, base64, strict);
    
public java.nio.charset.CharsetEncodernewEncoder()

        return new UTF7StyleCharsetEncoder(this, base64, strict);
    
abstract byteshift()
Returns character used to switch to base 64 encoding.

return
The shift character

abstract byteunshift()
Returns character used to switch from base 64 encoding to simple encoding.

return
The unshift character