cryptix.util.mime
Class CRLF

java.lang.Object
  extended bycryptix.util.mime.CRLF

public class CRLF
extends java.lang.Object

This class provides static methods to convert strings to and from the MIME "canonical" form, in which all line breaks are represented as ASCII CR followed by ASCII LF.

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1.1.1 $

Since:
Cryptix 2.2
Author:
Jill Baker

Method Summary
static byte[] decode(byte[] b)
          Convert all canonical line breaks with a byte array (represented by "\r\n") to machine-specific linebreaks.
static java.lang.String decode(java.lang.String s)
          Converts all canonical line breaks with a string (represented by "\r\n") to machine-specific linebreaks.
static byte[] encode(byte[] b)
          Converts all line breaks within a byte array (represented by either "\r", "\n" or "\r\n") to canonical ("\r\n") linebreaks.
static java.lang.String encode(java.lang.String s)
          Converts all line breaks within a string (represented by either "\r", "\n" or "\r\n") to canonical ("\r\n") linebreaks.
static boolean isProbablyEncoded(byte[] b)
          Tests whether or not all line breaks within a byte array are of the form "\r\n".
static boolean isProbablyEncoded(java.lang.String s)
          Test whether or not all line breaks within a String are of the form "\r\n".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Converts all line breaks within a string (represented by either "\r", "\n" or "\r\n") to canonical ("\r\n") linebreaks.

Parameters:
s - text to be converted
Returns:
text with canonical line breaks

encode

public static byte[] encode(byte[] b)
Converts all line breaks within a byte array (represented by either "\r", "\n" or "\r\n") to canonical ("\r\n") linebreaks.

The byte array can be in ASCII, ISO-Latin-x, UTF8, UTF7, or Quoted-Printable encoding, or any similar character encoding for which CR and LF are represented in the same way as ASCII, and no other bytes can have the values 10 or 13.

Parameters:
b - text to be converted
Returns:
text with canonical line breaks

decode

public static java.lang.String decode(java.lang.String s)
Converts all canonical line breaks with a string (represented by "\r\n") to machine-specific linebreaks.

Parameters:
s - text (with canonical line breaks) to be decoded
Returns:
text with machine-specific line breaks

decode

public static byte[] decode(byte[] b)
Convert all canonical line breaks with a byte array (represented by "\r\n") to machine-specific linebreaks.

The byte array can be in ASCII, ISO-Latin-x, UTF8, UTF7, or Quoted-Printable encoding, or any similar character encoding for which CR and LF are represented in the same way as ASCII, and no other bytes can have the values 10 or 13.

Parameters:
b - text (with canonical line breaks) to be decoded
Returns:
text with machine-specific line breaks

isProbablyEncoded

public static boolean isProbablyEncoded(java.lang.String s)
Test whether or not all line breaks within a String are of the form "\r\n".

Parameters:
s - String to be tested.
Returns:
true if all line breaks are of the form "\r\n".

isProbablyEncoded

public static boolean isProbablyEncoded(byte[] b)
Tests whether or not all line breaks within a byte array are of the form "\r\n".

The byte array can be in ASCII, ISO-Latin-x, UTF8, UTF7, or Quoted-Printable encoding, or any similar character encoding for which CR and LF are represented in the same way as ASCII, and no other bytes can have the values 10 or 13.

Parameters:
b - byte array to be tested.
Returns:
true if all line breaks are of the form "\r\n".