org.apache.jackrabbit.test.api
Class Base64

java.lang.Object
  extended by org.apache.jackrabbit.test.api.Base64

public class Base64
extends Object

Base64 provides Base64 encoding/decoding of strings and streams. NOTE: This is a copy of the original org.apache.jackrabbit.core.util.Base64 class to not introduce a dependency to jackrabbit from the test classes.


Method Summary
static long calcEncodedLength(long dataLength)
          Calculates the size (i.e.
static void decode(char[] chars, int off, int len, OutputStream out)
          Decode base64 encoded data.
static void decode(char[] chars, OutputStream out)
          Decode base64 encoded data.
static void decode(InputStream in, OutputStream out)
          Decode base64 encoded data.
static void decode(Reader reader, OutputStream out)
          Decode base64 encoded data.
static void decode(String data, OutputStream out)
          Decode base64 encoded data.
static void encode(byte[] data, int off, int len, Writer writer)
          Outputs base64 representation of the specified data to an OutputStream.
static void encode(InputStream in, OutputStream out)
          Outputs base64 representation of the specified stream data to an OutputStream.
static void encode(InputStream in, Writer writer)
          Outputs base64 representation of the specified stream data to an OutputStream.
static long guessDecodedLength(long encLength)
          Pessimistically guesses the size (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calcEncodedLength

public static long calcEncodedLength(long dataLength)
Calculates the size (i.e. number of bytes) of the base64 encoded output given the length (i.e. number of bytes) of the data to be encoded.

Parameters:
dataLength - length (i.e. number of bytes) of the data to be encoded
Returns:
size (i.e. number of bytes) of the base64 encoded output

guessDecodedLength

public static long guessDecodedLength(long encLength)
Pessimistically guesses the size (i.e. number of bytes) of the decoded output given the length (i.e. number of bytes) of the base64 encoded data.

Parameters:
encLength - length (i.e. number of bytes) of the base64 encoded data
Returns:
size (i.e. number of bytes) of the decoded output

encode

public static void encode(InputStream in,
                          Writer writer)
                   throws IOException
Outputs base64 representation of the specified stream data to an OutputStream.

Parameters:
in - stream data to be encoded
writer - writer to output the encoded data
Throws:
IOException

encode

public static void encode(InputStream in,
                          OutputStream out)
                   throws IOException
Outputs base64 representation of the specified stream data to an OutputStream.

Parameters:
in - stream data to be encoded
out - stream where the encoded data should be written to
Throws:
IOException

encode

public static void encode(byte[] data,
                          int off,
                          int len,
                          Writer writer)
                   throws IOException
Outputs base64 representation of the specified data to an OutputStream.

Parameters:
data - data to be encoded
off - offset within data at which to start encoding
len - length of data to encode
writer - writer to output the encoded data
Throws:
IOException

decode

public static void decode(Reader reader,
                          OutputStream out)
                   throws IOException
Decode base64 encoded data.

Parameters:
reader - reader for the base64 encoded data to be decoded
out - stream where the decoded data should be written to
Throws:
IOException

decode

public static void decode(InputStream in,
                          OutputStream out)
                   throws IOException
Decode base64 encoded data. The data read from the inputstream is assumed to be of charset "US-ASCII".

Parameters:
in - inputstream of the base64 encoded data to be decoded
out - stream where the decoded data should be written to
Throws:
IOException

decode

public static void decode(String data,
                          OutputStream out)
                   throws IOException
Decode base64 encoded data.

Parameters:
data - the base64 encoded data to be decoded
out - stream where the decoded data should be written to
Throws:
IOException

decode

public static void decode(char[] chars,
                          OutputStream out)
                   throws IOException
Decode base64 encoded data.

Parameters:
chars - the base64 encoded data to be decoded
out - stream where the decoded data should be written to
Throws:
IOException

decode

public static void decode(char[] chars,
                          int off,
                          int len,
                          OutputStream out)
                   throws IOException
Decode base64 encoded data.

Parameters:
chars - the base64 encoded data to be decoded
off - offset within data at which to start decoding
len - length of data to decode
out - stream where the decoded data should be written to
Throws:
IOException


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.