ANTS v2.0 API

ants.core
Class TypeID

java.lang.Object
  |
  +--ants.core.TypeID

public final class TypeID
extends java.lang.Object

Capsule, CapsuleClass, CodeGroup and Protocol identifiers. This class wraps 128 bit MD5 hashes stored in byte arrays.

See the text file On_IDs.txt for a description of how these IDs are used.

Author:
David Wetherall

Constructor Summary
TypeID(byte[] buf, int offset)
          Construct a new TypeID and initialize by deep copy.
 
Method Summary
 int compare(TypeID t)
          Compare two TypeIDs
static TypeID computeFromIDs(TypeID[] ids)
          Compute an ID from a vector of codeIDs.
 boolean equals(java.lang.Object obj)
          Compare this TypeID with the given one.
 int hashCode()
           
 TypeID intern()
          Intern a TypeID and return its canonical value.
static void sortArray(TypeID[] ids)
          Sort an array of TypeIDs.
 java.lang.String toString()
           
 byte[] unwrap()
          Unwrap this TypeID, returning the inner byte array.
static TypeID wrap(byte[] buf)
          Construct and initialize by shallow copy.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeID

public TypeID(byte[] buf,
              int offset)
Construct a new TypeID and initialize by deep copy.
Parameters:
buf - the byte[] to copy into this new TypeID.
offset - offset in buf to copy from
Throws:
java.lang.IndexOutOfBoundsException - if buf is too short
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compare this TypeID with the given one. The given TypeID must match all 16 bytes.
Overrides:
equals in class java.lang.Object

intern

public TypeID intern()
Intern a TypeID and return its canonical value. The intern table is flow-private.
Returns:
the canonical version of this TypeID.

compare

public int compare(TypeID t)
Compare two TypeIDs
Returns:
-1 (this < t), 0 (this.equals(t), 1 (this > t)

sortArray

public static void sortArray(TypeID[] ids)
Sort an array of TypeIDs. Good for short vectors only -- uses insertion sort. Sorts the array inline.

computeFromIDs

public static TypeID computeFromIDs(TypeID[] ids)
Compute an ID from a vector of codeIDs.

This is done by computing a multiple-element md5 hash over a sorted list of code ids.

XXX Combine the insertion sort and the id.update() step from this function. Should only have to iterate over the list once.

Returns:
a TypeID representing this vector's ID.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unwrap

public byte[] unwrap()
Unwrap this TypeID, returning the inner byte array. Does not return a copy, returns the actual array.
Returns:
the byte[] representing this TypeID.

wrap

public static TypeID wrap(byte[] buf)
Construct and initialize by shallow copy. The different notation is meant to emphasize that a complete object is not being created but rather an existing object is being packaged for convenience.

The length of the buf is not checked.

Parameters:
buf - 16-byte byte[] containing an MD5 checksum.

ANTS v2.0 API

This documentation is Copyright (C) 1998-2001 The University of Utah and the University of Washington. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for ANTS v2.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/