com.virtuosotechnologies.lib.conversion
Class Base64Stringizer

java.lang.Object
  extended bycom.virtuosotechnologies.lib.conversion.Base64Stringizer
All Implemented Interfaces:
Stringizer

public class Base64Stringizer
extends Object
implements Stringizer

A Stringizer that uses Base64 conversion. This class is fully synchronized and thread safe.


Constructor Summary
Base64Stringizer()
          Constructor
 
Method Summary
 void addBytes(byte[] data, int start, int length)
          Add binary data to the Stringizer
 void finish()
          Finish the conversion
 int getTotalDataLength()
          Get the total number of bytes of binary data that have been added.
 int getWaitingCharacterCount()
          Get the number of encoded characters ready to be fetched
 String getWaitingCharacters(int count)
          Get the given number of characters as a String.
 int getWaitingCharacters(int count, StringBuffer buffer)
          Add the given number of characters to a StringBuffer.
 boolean isFinished()
          Is the Stringizer finished?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64Stringizer

public Base64Stringizer()
Constructor

Method Detail

isFinished

public boolean isFinished()
Is the Stringizer finished?

Specified by:
isFinished in interface Stringizer
Returns:
true if the Stringizer is finished.

finish

public void finish()
Finish the conversion

Specified by:
finish in interface Stringizer
Throws:
IllegalStateException - Stringizer is already finished.

addBytes

public void addBytes(byte[] data,
                     int start,
                     int length)
Add binary data to the Stringizer

Specified by:
addBytes in interface Stringizer
Parameters:
data - data array
start - index into data array
length - number of bytes to add
Throws:
IllegalStateException - Stringizer is already finished.
ArrayIndexOutOfBoundsException - bad start and/or length value.

getTotalDataLength

public int getTotalDataLength()
Get the total number of bytes of binary data that have been added.

Specified by:
getTotalDataLength in interface Stringizer
Returns:
number of bytes

getWaitingCharacterCount

public int getWaitingCharacterCount()
Get the number of encoded characters ready to be fetched

Specified by:
getWaitingCharacterCount in interface Stringizer
Returns:
number of waiting characters

getWaitingCharacters

public String getWaitingCharacters(int count)
Get the given number of characters as a String.

Specified by:
getWaitingCharacters in interface Stringizer
Parameters:
count - maximum number of characters to get, or -1 to get all characters.
Returns:
a String containing the characters

getWaitingCharacters

public int getWaitingCharacters(int count,
                                StringBuffer buffer)
Add the given number of characters to a StringBuffer.

Specified by:
getWaitingCharacters in interface Stringizer
Parameters:
count - maximum number of characters to get, or -1 to get all characters.
buffer - StringBuffer to add the characters to
Returns:
the actual number of characters gotten.