com.beetstra.jutf7
Class UTF7StyleCharset

java.lang.Object
  extended by java.nio.charset.Charset
      extended by com.beetstra.jutf7.UTF7StyleCharset
All Implemented Interfaces:
Comparable<Charset>
Direct Known Subclasses:
ModifiedUTF7Charset, UTF7Charset

abstract class UTF7StyleCharset
extends Charset

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

Author:
Jaap Beetstra

Field Summary
(package private)  Base64Util base64
           
(package private)  boolean strict
           
 
Constructor Summary
protected UTF7StyleCharset(String canonicalName, String[] aliases, String alphabet, boolean strict)
          Besides the name and aliases, two additional parameters are required.
 
Method Summary
(package private) abstract  boolean canEncodeDirectly(char ch)
          Tells if a character can be encoded using simple (US-ASCII) encoding or requires base 64 encoding.
 boolean contains(Charset cs)
           
 CharsetDecoder newDecoder()
           
 CharsetEncoder newEncoder()
           
(package private) abstract  byte shift()
          Returns character used to switch to base 64 encoding.
(package private) abstract  byte unshift()
          Returns character used to switch from base 64 encoding to simple encoding.
 
Methods inherited from class java.nio.charset.Charset
aliases, availableCharsets, canEncode, compareTo, decode, defaultCharset, displayName, displayName, encode, encode, equals, forName, hashCode, isRegistered, isSupported, name, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

strict

final boolean strict

base64

Base64Util base64
Constructor Detail

UTF7StyleCharset

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).

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

contains

public boolean contains(Charset cs)
Specified by:
contains in class Charset

newDecoder

public CharsetDecoder newDecoder()
Specified by:
newDecoder in class Charset

newEncoder

public CharsetEncoder newEncoder()
Specified by:
newEncoder in class Charset

canEncodeDirectly

abstract boolean canEncodeDirectly(char ch)
Tells if a character can be encoded using simple (US-ASCII) encoding or requires base 64 encoding.

Parameters:
ch - The character
Returns:
True if the character can be encoded directly, false otherwise

shift

abstract byte shift()
Returns character used to switch to base 64 encoding.

Returns:
The shift character

unshift

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

Returns:
The unshift character


Copyright © 2008 sourceforge. All Rights Reserved.