com.boylesoftware.cb2.util
Class CodeUtils

java.lang.Object
  extended bycom.boylesoftware.cb2.util.CodeUtils

public class CodeUtils
extends java.lang.Object

Collection of data encoding/decoding utility functions.

Version:
$Id: CodeUtils.java,v 1.1 2003/07/20 16:04:19 levahim Exp $
Author:
Lev Himmelfarb

Constructor Summary
CodeUtils()
           
 
Method Summary
static java.lang.String bytesToString(byte[] input)
          Converts a byte array to a string of printable characters consisting of symbols A-Z, a-z, 0-9, + and *.
static java.lang.String objectToString(java.lang.Object o)
          Serializes an object and returns string representation of its data.
static byte[] stringToBytes(java.lang.String input)
          Restores a byte array from a string created by bytesToString method.
static java.lang.Object stringToObject(java.lang.String input)
          Restores an object instance from the string generated by the objectToString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeUtils

public CodeUtils()
Method Detail

bytesToString

public static java.lang.String bytesToString(byte[] input)
Converts a byte array to a string of printable characters consisting of symbols A-Z, a-z, 0-9, + and *. Later the bytes can be restored from the string by stringToBytes method.

Parameters:
input - input bytes.
Returns:
string representation of the bytes.
See Also:
stringToBytes(java.lang.String)

stringToBytes

public static byte[] stringToBytes(java.lang.String input)
Restores a byte array from a string created by bytesToString method.

Parameters:
input - the encoded string.
Returns:
restored binary data.
See Also:
bytesToString(byte[])

objectToString

public static java.lang.String objectToString(java.lang.Object o)
                                       throws java.io.ObjectStreamException
Serializes an object and returns string representation of its data. The result string contains only symbols that may appear in the output of bytesToString method. The object instance can be restored with the stringToObject method.

Parameters:
o - the object to serialize.
Returns:
string representation of the serialized object.
Throws:
java.io.ObjectStreamException - if an error happened serializing the object.
See Also:
stringToObject(java.lang.String)

stringToObject

public static java.lang.Object stringToObject(java.lang.String input)
                                       throws java.io.ObjectStreamException,
                                              java.lang.ClassNotFoundException
Restores an object instance from the string generated by the objectToString method.

Parameters:
input - the encoded string.
Returns:
a new instance of the object.
Throws:
java.io.ObjectStreamException - if an error happened deserializing the object.
java.lang.ClassNotFoundException - the object's class not found.


Copyright © 2002,2003,2004 - Boyle Software, Inc.