All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class au.com.pharos.packing.NativeStringPacking

au.com.pharos.packing.Packing
   |
   +----au.com.pharos.packing.NativeStringPacking

public class NativeStringPacking
extends Packing
Convert an array of bytes in a Java string without using String encodings, just using expanding 8-bit bytes to 16-bit chars.

This will only work for ASCII characters, of course, but for moving bulk data around it is considerably faster than using UTF-8 encoding strategies. Naively compressing Unicode into 8-bit characters in this manner is deprecated in JDK1.1 to help ensure that programs are Unicode-safe.

Version:
$Revision: 1.4 $
Author:
Martin Pool
See Also:
Packing, StringPacking

Constructor Index

 o NativeStringPacking()

Method Index

 o fromBytes(byte[])
Convert an array of bytes into a String
 o toBytes(Object)
Convert an object to an ASCII String representation.

Constructors

 o NativeStringPacking
 public NativeStringPacking()

Methods

 o toBytes
 public byte[] toBytes(Object obj)
Convert an object to an ASCII String representation.

Returns:
null if obj is null; obj is obj is already a byte[]; otherwise an native 8-bite encoded version of obj.toString().
Overrides:
toBytes in class Packing
 o fromBytes
 public Object fromBytes(byte raw[])
Convert an array of bytes into a String

Parameters:
raw - the raw data to be decoded.
Returns:
null if raw is null; otherwise a string with the low 8 bits of each character taken from the corresponding byte in raw.
Overrides:
fromBytes in class Packing

All Packages  Class Hierarchy  This Package  Previous  Next  Index