loci.formats.codec
Class Base64Codec

java.lang.Object
  extended by loci.formats.codec.BaseCodec
      extended by loci.formats.codec.Base64Codec
All Implemented Interfaces:
Codec

public class Base64Codec
extends BaseCodec
implements Codec

Implements encoding (compress) and decoding (decompress) methods for Base64. This code was adapted from the Jakarta Commons Codec source, http://jakarta.apache.org/commons

Source code:
Trac, SVN

Author:
Melissa Linkert linkert at wisc.edu

Constructor Summary
Base64Codec()
           
 
Method Summary
 byte[] base64Decode(String s)
          Decodes a Base64 String by converting to bytes and passing to the decompress method.
 byte[] compress(byte[] input, int x, int y, int[] dims, Object options)
          Encodes a block of data into Base64.
 byte[] decompress(byte[] base64Data, Object options)
          Decompresses a block of data.
static void main(String[] args)
          Main testing method. test is inherited from parent class.
 
Methods inherited from class loci.formats.codec.BaseCodec
compress, decompress, decompress, decompress, test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface loci.formats.codec.Codec
compress, decompress, decompress, decompress
 

Constructor Detail

Base64Codec

public Base64Codec()
Method Detail

compress

public byte[] compress(byte[] input,
                       int x,
                       int y,
                       int[] dims,
                       Object options)
                throws loci.formats.FormatException
Encodes a block of data into Base64.

Specified by:
compress in interface Codec
Parameters:
input - the data to be encoded.
x - ignored.
y - ignored.
dims - ignored.
options - ignored.
Returns:
The encoded data.
Throws:
loci.formats.FormatException - If input is not a compressed data block of the appropriate type.

decompress

public byte[] decompress(byte[] base64Data,
                         Object options)
                  throws loci.formats.FormatException
Decompresses a block of data.

Specified by:
decompress in interface Codec
Parameters:
base64Data - the data to be decoded
options - Options to be used during decompression.
Returns:
The decoded data
Throws:
loci.formats.FormatException - if data is not valid Base64 data

base64Decode

public byte[] base64Decode(String s)
                    throws loci.formats.FormatException
Decodes a Base64 String by converting to bytes and passing to the decompress method.

Parameters:
s - the String to be decoded
Returns:
The decoded data
Throws:
loci.formats.FormatException - if s is not valid Base64 data.

main

public static void main(String[] args)
                 throws loci.formats.FormatException
Main testing method. test is inherited from parent class.

Parameters:
args - ignored
Throws:
loci.formats.FormatException - Can only occur if there is a bug in the compress method.