com.amazon.carbonado.raw
Class KeyDecoder

java.lang.Object
  extended by com.amazon.carbonado.raw.KeyDecoder

public class KeyDecoder
extends Object

A very low-level class that decodes key components encoded by methods of KeyEncoder.

Author:
Brian S O'Neill
See Also:
DataDecoder

Constructor Summary
KeyDecoder()
           
 
Method Summary
static int decode(byte[] src, int srcOffset, BigDecimal[] valueRef)
          Decodes the given BigDecimal as originally encoded for ascending order.
static int decode(byte[] src, int srcOffset, BigInteger[] valueRef)
          Decodes the given BigInteger as originally encoded for ascending order.
static int decode(byte[] src, int srcOffset, byte[][] valueRef)
          Decodes the given byte array as originally encoded for ascending order.
static boolean decodeBooleanDesc(byte[] src, int srcOffset)
          Decodes a boolean from exactly 1 byte, as encoded for descending order.
static Boolean decodeBooleanObjDesc(byte[] src, int srcOffset)
          Decodes a Boolean object from exactly 1 byte, as encoded for descending order.
static byte decodeByteDesc(byte[] src, int srcOffset)
          Decodes a signed byte from exactly 1 byte, as encoded for descending order.
static Byte decodeByteObjDesc(byte[] src, int srcOffset)
          Decodes a signed Byte object from exactly 1 or 2 bytes, as encoded for descending order.
static Character decodeCharacterObjDesc(byte[] src, int srcOffset)
          Decodes a Character object from exactly 1 or 3 bytes, as encoded for descending order.
static char decodeCharDesc(byte[] src, int srcOffset)
          Decodes a char from exactly 2 bytes, as encoded for descending order.
static int decodeDesc(byte[] src, int srcOffset, BigDecimal[] valueRef)
          Decodes the given BigDecimal as originally encoded for descending order.
static int decodeDesc(byte[] src, int srcOffset, BigInteger[] valueRef)
          Decodes the given BigInteger as originally encoded for descending order.
static int decodeDesc(byte[] src, int srcOffset, byte[][] valueRef)
          Decodes the given byte array as originally encoded for descending order.
static double decodeDoubleDesc(byte[] src, int srcOffset)
          Decodes a double from exactly 8 bytes, as encoded for descending order.
static Double decodeDoubleObjDesc(byte[] src, int srcOffset)
          Decodes a Double object from exactly 8 bytes.
static float decodeFloatDesc(byte[] src, int srcOffset)
          Decodes a float from exactly 4 bytes, as encoded for descending order.
static Float decodeFloatObjDesc(byte[] src, int srcOffset)
          Decodes a Float object from exactly 4 bytes.
static int decodeIntDesc(byte[] src, int srcOffset)
          Decodes a signed integer from exactly 4 bytes, as encoded for descending order.
static Integer decodeIntegerObjDesc(byte[] src, int srcOffset)
          Decodes a signed Integer object from exactly 1 or 5 bytes, as encoded for descending order.
static long decodeLongDesc(byte[] src, int srcOffset)
          Decodes a signed long from exactly 8 bytes, as encoded for descending order.
static Long decodeLongObjDesc(byte[] src, int srcOffset)
          Decodes a signed Long object from exactly 1 or 9 bytes, as encoded for descending order.
static short decodeShortDesc(byte[] src, int srcOffset)
          Decodes a signed short from exactly 2 bytes, as encoded for descending order.
static Short decodeShortObjDesc(byte[] src, int srcOffset)
          Decodes a signed Short object from exactly 1 or 3 bytes, as encoded for descending order.
static byte[] decodeSingleDesc(byte[] src)
          Decodes the given byte array which was encoded by KeyEncoder.encodeSingleDesc(byte[]).
static byte[] decodeSingleDesc(byte[] src, int prefixPadding, int suffixPadding)
          Decodes the given byte array which was encoded by KeyEncoder.encodeSingleDesc(byte[]).
static byte[] decodeSingleNullableDesc(byte[] src)
          Decodes the given byte array which was encoded by KeyEncoder.encodeSingleNullableDesc(byte[]).
static byte[] decodeSingleNullableDesc(byte[] src, int prefixPadding, int suffixPadding)
          Decodes the given byte array which was encoded by KeyEncoder.encodeSingleNullableDesc(byte[]).
static int decodeString(byte[] src, int srcOffset, String[] valueRef)
          Decodes an encoded string from the given byte array.
static int decodeStringDesc(byte[] src, int srcOffset, String[] valueRef)
          Decodes an encoded string from the given byte array as originally encoded for descending order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyDecoder

public KeyDecoder()
Method Detail

decodeIntDesc

public static int decodeIntDesc(byte[] src,
                                int srcOffset)
                         throws CorruptEncodingException
Decodes a signed integer from exactly 4 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed integer value
Throws:
CorruptEncodingException

decodeIntegerObjDesc

public static Integer decodeIntegerObjDesc(byte[] src,
                                           int srcOffset)
                                    throws CorruptEncodingException
Decodes a signed Integer object from exactly 1 or 5 bytes, as encoded for descending order. If null is returned, then 1 byte was read.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed Integer object or null
Throws:
CorruptEncodingException

decodeLongDesc

public static long decodeLongDesc(byte[] src,
                                  int srcOffset)
                           throws CorruptEncodingException
Decodes a signed long from exactly 8 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed long value
Throws:
CorruptEncodingException

decodeLongObjDesc

public static Long decodeLongObjDesc(byte[] src,
                                     int srcOffset)
                              throws CorruptEncodingException
Decodes a signed Long object from exactly 1 or 9 bytes, as encoded for descending order. If null is returned, then 1 byte was read.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed Long object or null
Throws:
CorruptEncodingException

decodeByteDesc

public static byte decodeByteDesc(byte[] src,
                                  int srcOffset)
                           throws CorruptEncodingException
Decodes a signed byte from exactly 1 byte, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed byte value
Throws:
CorruptEncodingException

decodeByteObjDesc

public static Byte decodeByteObjDesc(byte[] src,
                                     int srcOffset)
                              throws CorruptEncodingException
Decodes a signed Byte object from exactly 1 or 2 bytes, as encoded for descending order. If null is returned, then 1 byte was read.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed Byte object or null
Throws:
CorruptEncodingException

decodeShortDesc

public static short decodeShortDesc(byte[] src,
                                    int srcOffset)
                             throws CorruptEncodingException
Decodes a signed short from exactly 2 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed short value
Throws:
CorruptEncodingException

decodeShortObjDesc

public static Short decodeShortObjDesc(byte[] src,
                                       int srcOffset)
                                throws CorruptEncodingException
Decodes a signed Short object from exactly 1 or 3 bytes, as encoded for descending order. If null is returned, then 1 byte was read.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
signed Short object or null
Throws:
CorruptEncodingException

decodeCharDesc

public static char decodeCharDesc(byte[] src,
                                  int srcOffset)
                           throws CorruptEncodingException
Decodes a char from exactly 2 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
char value
Throws:
CorruptEncodingException

decodeCharacterObjDesc

public static Character decodeCharacterObjDesc(byte[] src,
                                               int srcOffset)
                                        throws CorruptEncodingException
Decodes a Character object from exactly 1 or 3 bytes, as encoded for descending order. If null is returned, then 1 byte was read.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
Character object or null
Throws:
CorruptEncodingException

decodeBooleanDesc

public static boolean decodeBooleanDesc(byte[] src,
                                        int srcOffset)
                                 throws CorruptEncodingException
Decodes a boolean from exactly 1 byte, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
boolean value
Throws:
CorruptEncodingException

decodeBooleanObjDesc

public static Boolean decodeBooleanObjDesc(byte[] src,
                                           int srcOffset)
                                    throws CorruptEncodingException
Decodes a Boolean object from exactly 1 byte, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
Boolean object or null
Throws:
CorruptEncodingException

decodeFloatDesc

public static float decodeFloatDesc(byte[] src,
                                    int srcOffset)
                             throws CorruptEncodingException
Decodes a float from exactly 4 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
float value
Throws:
CorruptEncodingException

decodeFloatObjDesc

public static Float decodeFloatObjDesc(byte[] src,
                                       int srcOffset)
                                throws CorruptEncodingException
Decodes a Float object from exactly 4 bytes.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
Float object or null
Throws:
CorruptEncodingException

decodeDoubleDesc

public static double decodeDoubleDesc(byte[] src,
                                      int srcOffset)
                               throws CorruptEncodingException
Decodes a double from exactly 8 bytes, as encoded for descending order.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
double value
Throws:
CorruptEncodingException

decodeDoubleObjDesc

public static Double decodeDoubleObjDesc(byte[] src,
                                         int srcOffset)
                                  throws CorruptEncodingException
Decodes a Double object from exactly 8 bytes.

Parameters:
src - source of encoded bytes
srcOffset - offset into source array
Returns:
Double object or null
Throws:
CorruptEncodingException

decode

public static int decode(byte[] src,
                         int srcOffset,
                         BigInteger[] valueRef)
                  throws CorruptEncodingException
Decodes the given BigInteger as originally encoded for ascending order.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded BigInteger is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt
Since:
1.2

decodeDesc

public static int decodeDesc(byte[] src,
                             int srcOffset,
                             BigInteger[] valueRef)
                      throws CorruptEncodingException
Decodes the given BigInteger as originally encoded for descending order.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded BigInteger is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt
Since:
1.2

decode

public static int decode(byte[] src,
                         int srcOffset,
                         BigDecimal[] valueRef)
                  throws CorruptEncodingException
Decodes the given BigDecimal as originally encoded for ascending order.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded BigDecimal is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt
Since:
1.2

decodeDesc

public static int decodeDesc(byte[] src,
                             int srcOffset,
                             BigDecimal[] valueRef)
                      throws CorruptEncodingException
Decodes the given BigDecimal as originally encoded for descending order.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded BigDecimal is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt
Since:
1.2

decode

public static int decode(byte[] src,
                         int srcOffset,
                         byte[][] valueRef)
                  throws CorruptEncodingException
Decodes the given byte array as originally encoded for ascending order. The decoding stops when any kind of terminator or illegal byte has been read. The decoded bytes are stored in valueRef.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded byte array is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt

decodeDesc

public static int decodeDesc(byte[] src,
                             int srcOffset,
                             byte[][] valueRef)
                      throws CorruptEncodingException
Decodes the given byte array as originally encoded for descending order. The decoding stops when any kind of terminator or illegal byte has been read. The decoded bytes are stored in valueRef.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded byte array is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt

decodeString

public static int decodeString(byte[] src,
                               int srcOffset,
                               String[] valueRef)
                        throws CorruptEncodingException
Decodes an encoded string from the given byte array.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded string is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt

decodeStringDesc

public static int decodeStringDesc(byte[] src,
                                   int srcOffset,
                                   String[] valueRef)
                            throws CorruptEncodingException
Decodes an encoded string from the given byte array as originally encoded for descending order.

Parameters:
src - source of encoded data
srcOffset - offset into encoded data
valueRef - decoded string is stored in element 0, which may be null
Returns:
amount of bytes read from source
Throws:
CorruptEncodingException - if source data is corrupt

decodeSingleDesc

public static byte[] decodeSingleDesc(byte[] src)
                               throws CorruptEncodingException
Decodes the given byte array which was encoded by KeyEncoder.encodeSingleDesc(byte[]). Always returns a new byte array instance.

Throws:
CorruptEncodingException

decodeSingleDesc

public static byte[] decodeSingleDesc(byte[] src,
                                      int prefixPadding,
                                      int suffixPadding)
                               throws CorruptEncodingException
Decodes the given byte array which was encoded by KeyEncoder.encodeSingleDesc(byte[]). Always returns a new byte array instance.

Parameters:
prefixPadding - amount of extra bytes to skip from start of encoded byte array
suffixPadding - amount of extra bytes to skip at end of encoded byte array
Throws:
CorruptEncodingException

decodeSingleNullableDesc

public static byte[] decodeSingleNullableDesc(byte[] src)
                                       throws CorruptEncodingException
Decodes the given byte array which was encoded by KeyEncoder.encodeSingleNullableDesc(byte[]). Always returns a new byte array instance.

Throws:
CorruptEncodingException

decodeSingleNullableDesc

public static byte[] decodeSingleNullableDesc(byte[] src,
                                              int prefixPadding,
                                              int suffixPadding)
                                       throws CorruptEncodingException
Decodes the given byte array which was encoded by KeyEncoder.encodeSingleNullableDesc(byte[]). Always returns a new byte array instance.

Parameters:
prefixPadding - amount of extra bytes to skip from start of encoded byte array
suffixPadding - amount of extra bytes to skip at end of encoded byte array
Throws:
CorruptEncodingException


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.