Class UTF7Charset

java.lang.Object
java.nio.charset.Charset
net.freeutils.charset.UTF7Charset
All Implemented Interfaces:
Comparable<Charset>
Direct Known Subclasses:
UTF7OptionalCharset

public class UTF7Charset extends Charset
The UTF7Charset class handles the encoding and decoding of the UTF-7 charset. The encoding and decoding are based on RFC 2152 (http://www.ietf.org/rfc/rfc2152.txt)
Since:
2005-06-10
  • Constructor Details

    • UTF7Charset

      public UTF7Charset()
      Constructs an instance of the UTF7Charset. O-set characters are not directly encoded.
    • UTF7Charset

      public UTF7Charset(String canonicalName, String[] aliases, boolean optionalDirect)
      Constructs an instance of the UTF7Charset, specifying whether the O-set characters are to be encoded directly or using a shift sequence.
      Parameters:
      canonicalName - The canonical name of this charset
      aliases - An array of this charset's aliases, or null if it has no aliases
      optionalDirect - if true, O-set characters are encoded directly, otherwise they are encoded using a shift sequence.
      Throws:
      IllegalCharsetNameException - If the canonical name or any of the aliases are illegal
  • Method Details

    • contains

      public boolean contains(Charset cs)
      Tells whether or not this charset contains the given charset.

      A charset C is said to contain a charset D if, and only if, every character representable in D is also representable in C. If this relationship holds then it is guaranteed that every string that can be encoded in D can also be encoded in C without performing any replacements.

      That C contains D does not imply that each character representable in C by a particular byte sequence is represented in D by the same byte sequence, although sometimes this is the case.

      Every charset contains itself.

      This method computes an approximation of the containment relation: If it returns true then the given charset is known to be contained by this charset; if it returns false, however, then it is not necessarily the case that the given charset is not contained in this charset.

      Specified by:
      contains in class Charset
      Returns:
      true if, and only if, the given charset is contained in this charset
    • canEncode

      public boolean canEncode()
      Tells whether or not this charset supports encoding.
      Overrides:
      canEncode in class Charset
      Returns:
      true if, and only if, this charset supports encoding
    • newDecoder

      public CharsetDecoder newDecoder()
      Constructs a new decoder for this charset.
      Specified by:
      newDecoder in class Charset
      Returns:
      A new decoder for this charset
    • newEncoder

      public CharsetEncoder newEncoder()
      Constructs a new encoder for this charset.
      Specified by:
      newEncoder in class Charset
      Returns:
      A new encoder for this charset
      Throws:
      UnsupportedOperationException - If this charset does not support encoding