com.teraspaces.qwfix.ordermanager
Class NumberPacker

java.lang.Object
  extended by com.teraspaces.qwfix.ordermanager.NumberPacker

public final class NumberPacker
extends Object

Provides methods to encode a non-negative number into (or decode from) an ASCII string based on the specified conversion table. This class cannot be inherited.


Field Summary
static NumberPacker DEFAULT
          A default instance of NumberPacker that uses DefaultTable.
static String DefaultTable
           
 
Constructor Summary
NumberPacker(String table)
          Instantiates a new number packer.
 
Method Summary
 String getTable()
          Gets the table.
 String pack(int number)
          Packs the number into a shorter string.
 int unpack(String s)
          Unpacks the number from a string encoded using pack(int) method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultTable

public static final String DefaultTable
See Also:
Constant Field Values

DEFAULT

public static final NumberPacker DEFAULT
A default instance of NumberPacker that uses DefaultTable.

Constructor Detail

NumberPacker

public NumberPacker(String table)
Instantiates a new number packer.

Parameters:
table - the table
Method Detail

pack

public String pack(int number)
Packs the number into a shorter string.

Parameters:
number - the number (must be non-negative)
Returns:
the packed string that represents the number

unpack

public int unpack(String s)
Unpacks the number from a string encoded using pack(int) method.

Parameters:
s - the input string
Returns:
the number unpacked from the string

getTable

public String getTable()
Gets the table.

Returns:
the table