com.bigdata.io.compression
Class UnicodeHelper

java.lang.Object
  extended by com.bigdata.io.compression.UnicodeHelper

public class UnicodeHelper
extends Object

Utility class for compressed unicode encode/decode.

Version:
$Id: UnicodeHelper.java 4582 2011-05-31 19:12:53Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
UnicodeHelper(IUnicodeCompressor uc)
           
 
Method Summary
 int decode(InputStream in, StringBuilder out)
          Decode a String from the input stream.
 String decode1(DataInputBuffer in, StringBuilder tmp)
          Decode a String from the input stream.
 int encode(String s, OutputStream out, ByteArrayBuffer tmp)
          Encode the String onto the OutputStream.
 byte[] encode1(String s)
          Encode a Unicode string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnicodeHelper

public UnicodeHelper(IUnicodeCompressor uc)
Method Detail

encode

public int encode(String s,
                  OutputStream out,
                  ByteArrayBuffer tmp)
           throws IOException
Encode the String onto the OutputStream. The temporary buffer is used to perform the encoding. The byte length of the encoding is written out using a packed long integer format followed by the coded bytes. This method is capable of writing out very long strings.

Parameters:
s - The character data.
out - The output stream.
tmp - The temporary buffer.
Throws:
IOException

encode1

public byte[] encode1(String s)
Encode a Unicode string.

Parameters:
s - The string.
Returns:
The encoded byte[].

decode

public int decode(InputStream in,
                  StringBuilder out)
           throws IOException
Decode a String from the input stream. The result is appended into the caller's buffer. The caller is responsible for resetting the buffer as necessary.

Parameters:
in - The input stream.
out - The output buffer.
Throws:
IOException

decode1

public String decode1(DataInputBuffer in,
                      StringBuilder tmp)
               throws IOException
Decode a String from the input stream.

Parameters:
in - The input stream.
tmp - The temporary buffer used to decode the data. The buffer will be reset automatically by this method.
Returns:
The decoded data.
Throws:
IOException


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.