jist.swans.misc
Class Pickle

java.lang.Object
  extended by jist.swans.misc.Pickle

public final class Pickle
extends java.lang.Object

Utility class to simplify the serialization and deserialization of various data types.

Since:
SWANS1.0
Version:
$Id: Pickle.java,v 1.7 2004/04/06 16:07:49 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Constructor Summary
Pickle()
           
 
Method Summary
static java.net.InetAddress arrayToInetAddress(byte[] addr, int offset)
           
static int arrayToInteger(byte[] b, int offset)
           
static java.lang.Object arrayToObject(byte[] b)
           
static java.lang.Object arrayToObject(byte[] b, int offset)
           
static short arrayToShort(byte[] b, int offset)
           
static java.lang.String arrayToString(byte[] b, int offset)
           
static int arrayToUByte(byte[] b, int offset)
           
static long arrayToUInt(byte[] b, int offset)
           
static int arrayToUShort(byte[] b, int offset)
           
static int[] byteToIntArray(byte[] data)
           
static int[] byteToIntArray(byte[] data, int offset, int length)
          Handle "unsigned" byte arrays containing numbers larger than 128 (bytes are signed, so convert into ints)
static byte[] concat(byte[] b1, byte[] b2)
           
static java.util.Vector Enum2Vector(java.util.Enumeration e)
          Utility method to stuff an entire enumeration into a vector
static int getLength(byte[] b, int offset)
          String: size = variable
static void InetAddressToArray(java.net.InetAddress inet, byte[] b, int offset)
          InetAddress: size = 4
static void integerToArray(int integer, byte[] b, int offset)
          Integer: size = 4
static byte[] intToByteArray(int[] data)
           
static byte[] intToByteArray(int[] data, int offset, int length)
           
static byte[] messageBytes(Message m)
           
static byte[] objectToArray(java.lang.Object s)
          Object: size = variable
static void printByteArrayNicely(byte[] a)
           
static void printByteArrayNicely(byte[] a, int offset, int length)
           
static void printlnByteArrayNicely(byte[] a)
           
static void printlnByteArrayNicely(byte[] a, int offset, int length)
           
static void shortToArray(short i, byte[] b, int offset)
          Short: size = 2
static byte[] stringToArray(java.lang.String s)
           
static void ubyteToArray(int ubyte, byte[] b, int offset)
           
static void uintToArray(long uint, byte[] b, int offset)
           
static void ushortToArray(int ushort, byte[] b, int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pickle

public Pickle()
Method Detail

printByteArrayNicely

public static void printByteArrayNicely(byte[] a)

printByteArrayNicely

public static void printByteArrayNicely(byte[] a,
                                        int offset,
                                        int length)

printlnByteArrayNicely

public static void printlnByteArrayNicely(byte[] a,
                                          int offset,
                                          int length)

printlnByteArrayNicely

public static void printlnByteArrayNicely(byte[] a)

Enum2Vector

public static java.util.Vector Enum2Vector(java.util.Enumeration e)
Utility method to stuff an entire enumeration into a vector


byteToIntArray

public static int[] byteToIntArray(byte[] data,
                                   int offset,
                                   int length)
Handle "unsigned" byte arrays containing numbers larger than 128 (bytes are signed, so convert into ints)


intToByteArray

public static byte[] intToByteArray(int[] data,
                                    int offset,
                                    int length)

byteToIntArray

public static int[] byteToIntArray(byte[] data)

intToByteArray

public static byte[] intToByteArray(int[] data)

concat

public static byte[] concat(byte[] b1,
                            byte[] b2)

ubyteToArray

public static final void ubyteToArray(int ubyte,
                                      byte[] b,
                                      int offset)

arrayToUByte

public static final int arrayToUByte(byte[] b,
                                     int offset)

ushortToArray

public static final void ushortToArray(int ushort,
                                       byte[] b,
                                       int offset)

arrayToUShort

public static final int arrayToUShort(byte[] b,
                                      int offset)

uintToArray

public static final void uintToArray(long uint,
                                     byte[] b,
                                     int offset)

arrayToUInt

public static final long arrayToUInt(byte[] b,
                                     int offset)

integerToArray

public static void integerToArray(int integer,
                                  byte[] b,
                                  int offset)
Integer: size = 4


arrayToInteger

public static int arrayToInteger(byte[] b,
                                 int offset)

shortToArray

public static void shortToArray(short i,
                                byte[] b,
                                int offset)
Short: size = 2


arrayToShort

public static short arrayToShort(byte[] b,
                                 int offset)

InetAddressToArray

public static void InetAddressToArray(java.net.InetAddress inet,
                                      byte[] b,
                                      int offset)
InetAddress: size = 4


arrayToInetAddress

public static java.net.InetAddress arrayToInetAddress(byte[] addr,
                                                      int offset)

getLength

public static int getLength(byte[] b,
                            int offset)
String: size = variable


stringToArray

public static byte[] stringToArray(java.lang.String s)

arrayToString

public static java.lang.String arrayToString(byte[] b,
                                             int offset)

objectToArray

public static byte[] objectToArray(java.lang.Object s)
Object: size = variable


arrayToObject

public static java.lang.Object arrayToObject(byte[] b,
                                             int offset)

arrayToObject

public static java.lang.Object arrayToObject(byte[] b)

messageBytes

public static byte[] messageBytes(Message m)