All Packages Class Hierarchy This Package Previous Next Index
Class au.com.pharos.packing.QuotedVectorPacking
au.com.pharos.packing.Packing
|
+----au.com.pharos.packing.QuotedVectorPacking
- public class QuotedVectorPacking
- extends Packing
Stores Vectors of strings, packed into a single string, as used by
some Perl code. The encoding format is similar to that used in
Unix databases like
/etc/passwd
, except that
it uses escape sequences to represent characters that would
normally not be allowed.
The strings within the vector are separated by separator characters,
which default to colons.
The resulting packed string is UTF encoded after escaping
control-characters, so non-ASCII characters should be passed through
unchanged.
Certain characters are escaped as quoted-printable strings.
These characters include colon, equals, and escape characters. The
encoding accepts and interprets any hex escape when reading data.
If any elements of the vector are null, they are stored as empty
strings. On unpacking, empty strings are returned as such.
An example of a vector encoded in this manner is:
oC7okz059wGnQ:vf:Peter Barnes%2c Pharos Business Solutions
- Version:
- $Revision: 1.3 $ $Date: 1997-10-21 13:53:20+10 $
- Author:
- Martin Pool
- See Also:
- Vector
-
QuotedVectorPacking()
- Constructs a QuotedVectorPacking using the default separator
character ':' and escape character '%'.
-
QuotedVectorPacking(char, char)
- Constructs a QuotedVectorPacking with specified separator and
hex-escape characters.
-
fromBytes(byte[])
- Interprets raw as a packed quoted Vector, and
returns the unpacked Vector of strings.
-
toBytes(Object)
- Convert a Vector of Strings to a QuotedVector represented as an
array of bytes.
QuotedVectorPacking
public QuotedVectorPacking()
- Constructs a QuotedVectorPacking using the default separator
character ':' and escape character '%'.
QuotedVectorPacking
public QuotedVectorPacking(char hexEscape,
char separator)
- Constructs a QuotedVectorPacking with specified separator and
hex-escape characters.
- Parameters:
- hexEscape - the character used to begin a three-character
hex escape
- separator - the character used to separate elements in the
vector.
toBytes
public byte[] toBytes(Object obj)
- Convert a Vector of Strings to a QuotedVector represented as an
array of bytes.
- Parameters:
- obj - the Vector to encode; or null.
- Returns:
- s an array of bytes containing a packed representation of
obj; or null if obj is null.
- Throws: ClassCastException
- if obj is not a Vector
or null; or if any element of obj is not a String or
null.
- Overrides:
- toBytes in class Packing
fromBytes
public Object fromBytes(byte raw[])
- Interprets raw as a packed quoted Vector, and
returns the unpacked Vector of strings.
- Overrides:
- fromBytes in class Packing
All Packages Class Hierarchy This Package Previous Next Index