All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class au.com.pharos.packing.StringPacking

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

public class StringPacking
extends Packing
StringPacking converts Java Strings to and from byte arrays using the default UTF-8 encoding.

For strings containing only ASCII-7 characters, this is equivalent to NativeStringPacking but probably somewhat slower. However, it will safely handle non-ASCII characters, or unusual locales.

See Also:
Packing, NativeStringPacking

Constructor Index

 o StringPacking()

Method Index

 o fromBytes(byte[])
Decode an array of bytes using the default String encoding.
 o toBytes(Object)
Convert a String to an array of bytes using Java's default encoding.

Constructors

 o StringPacking
 public StringPacking()

Methods

 o toBytes
 public byte[] toBytes(Object obj)
Convert a String to an array of bytes using Java's default encoding.

If obj is not a String, array of bytes, or null then it's toString() method is called first to convert it to an array of bytes. This will lose information in many cases.

Parameters:
obj - The object to convert.
Returns:
obj converted to an array of bytes; or null if obj is null.
Overrides:
toBytes in class Packing
 o fromBytes
 public Object fromBytes(byte raw[])
Decode an array of bytes using the default String encoding.

Parameters:
raw - An array of bytes to decode.
Returns:
A String representation of raw; or null if raw is null.
Overrides:
fromBytes in class Packing

All Packages  Class Hierarchy  This Package  Previous  Next  Index