| java.lang.Object com.sun.portal.util.Encoder
Encoder | public class Encoder extends Object (Code) | | Static utility class for Base64 encoding/decoding a byte array or
Serializable object with support for compression and escaped HTTP
strings using a variant of Base64 encoding. The Base64 implementation
relies on the sun.misc.* package included with Sun's
implementation of the Java Platform; there is no guarantee that this
implementation will be used in future versions of this class. The
compression features use the java.util.zip package. This
class provides static methods only and the default constructor is hidden.
Base64 encoding essentially transforms binary data into ASCII; very helpful
in cases where binary data needs to be stored in documents. In support of
Html documents, a variant of Base64 encoding is used which ensures that
encoded Strings can be stored in HTTP/HTML constructs; these strings are
referred to as Http64 strings in this API.
See Also: Http64Decoder See Also: Decoding Http64 strings See Also: Http64Encoder See Also: Encoding Http64 strings author: Todd Fast, todd.fast@sun.com author: Mike Frisino, michael.frisino@sun.com version: JATO/1.2.2 $Id: Encoder.java,v 1.1 2005/06/15 22:23:15 rt94277 Exp $ version: This class is copied from JATO 1.2.2 util package |
Method Summary | |
public static byte[] | compress(byte[] in) Compresses array of bytes. | public static byte[] | decode(String s) Decodes an Http64 string to an array of bytes using a variant of Base64
encoding. | public static byte[] | decodeBase64(String s) Decodes a string using Base64 decoding into an array of bytes
without compression. | public static byte[] | decodeHttp64(String s) Decode an Http64 string to an array of bytes using a variant of Base64
encoding. | public static byte[] | decompress(byte[] in) Decompressed array of bytes using ZLIB. | public static Object | deserialize(byte[] b, boolean compressed) Deserialize or 'reconstitute' an object from an array of bytes,
which may be have been previously compressed. | public static String | encode(byte[] bytes) Encodes an array of bytes into a Http64 string without
compression using a variant of Base64 encoding. | public static String | encodeBase64(byte[] bytes) Encodes an array of bytes into a Base64 string, without compression. | public static String | encodeHttp64(byte[] bytes, int compressThreshold) Encodes an array of bytes into a compressed Http64 string using
a variant of Base64 encoding, performing compression if the byte
array exceeds the length specified by the threshold parameter. | public static byte[] | serialize(Serializable o, boolean compress) Serialize or 'flatten' an object to an array of bytes with
optional compression. |
compress | public static byte[] compress(byte[] in)(Code) | | Compresses array of bytes. Handles cases where compression is
counterproductive or when there is no compression yield.
Parameters: in - array of bytes to be compressed (should not be null) array of bytes in ZLIB compression format |
decode | public static byte[] decode(String s)(Code) | | Decodes an Http64 string to an array of bytes using a variant of Base64
encoding. Shortcut for calling
Encoder.decodeHttp64(String) decodeHttp64(String)
Parameters: s - Http64 string to be decoded decoded array of bytes or s.getBytes() on exception during execution |
decodeBase64 | public static byte[] decodeBase64(String s)(Code) | | Decodes a string using Base64 decoding into an array of bytes
without compression. Strings not previously Base64 encoded will
succeed.
Parameters: s - string to be decoded (assumed to be Base64 encoded string) decoded array of bytes or s.getBytes() on exception during execution |
decodeHttp64 | public static byte[] decodeHttp64(String s)(Code) | | Decode an Http64 string to an array of bytes using a variant of Base64
encoding.
Parameters: s - Http64 string to be decoded decoded array of bytes or s.getBytes() on exception during execution |
decompress | public static byte[] decompress(byte[] in)(Code) | | Decompressed array of bytes using ZLIB.
Parameters: in - array of bytes to be decompressed (should not be null) decompressed array of bytes |
deserialize | public static Object deserialize(byte[] b, boolean compressed) throws IOException, ClassNotFoundException(Code) | | Deserialize or 'reconstitute' an object from an array of bytes,
which may be have been previously compressed.
Parameters: b - array of bytes representing previously serialized object Parameters: compressed - flag indicating need to decompress bytes first reconstituted object |
encode | public static String encode(byte[] bytes)(Code) | | Encodes an array of bytes into a Http64 string without
compression using a variant of Base64 encoding. Shortcut for calling
Encoder.encodeHttp64(byte[],int) encodeHttp64(byte[],int)
Parameters: bytes - binary data to be encoded, should not be null encoded Http64 string |
encodeBase64 | public static String encodeBase64(byte[] bytes)(Code) | | Encodes an array of bytes into a Base64 string, without compression.
Resulting string is uniform with no carriage returns.
Parameters: bytes - binary data to be encoded Base64 encoded string |
encodeHttp64 | public static String encodeHttp64(byte[] bytes, int compressThreshold)(Code) | | Encodes an array of bytes into a compressed Http64 string using
a variant of Base64 encoding, performing compression if the byte
array exceeds the length specified by the threshold parameter.
Parameters: bytes - binary data to be encoded, should not be null Parameters: compressThreshold - compression peformed when byte array exceeds this value encoded Http64 string |
serialize | public static byte[] serialize(Serializable o, boolean compress) throws IOException(Code) | | Serialize or 'flatten' an object to an array of bytes with
optional compression.
Parameters: o - object to be flattened (should be Serializable) Parameters: compress - flag indicating need to compress results serialized array of bytes from input object , optionally compressed, |
|
|