All Packages  This Package  Class Hierarchy  Class Search  Index

Class edu.utah.janos.ants.ants.TypeID
java.lang.Object
   |
   +----edu.utah.janos.ants.ants.TypeID

  Summary

public final class  TypeID
     extends java.lang.Object
{
          // Fields 2
     private final byte[] bits;
     private static final Hashtable interned;

          // Constructors 3
     private TypeID();
     private TypeID(boolean, byte[], int);
     public TypeID(byte[], int);

          // Methods 9
     public static TypeID computeFromIDs(TypeID[]);
     public static void sortArray(TypeID[]);
     public static TypeID wrap(byte[]);

     public int compare(TypeID);
     public boolean equals(Object);
     public int hashCode();
     public TypeID intern();
     public String toString();
     public byte[] unwrap();
}

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


  Cross Reference

Returned By:
CapsuleClass.computeMethodID(), CapsuleClass.protocolID(), Node.findMID(), Node.findPID(), TypeID.computeFromIDs(), TypeID.intern(), TypeID.wrap(), Xdr.TYPEID()





  Fields

· bits

Summary  |  Top
   private final byte[] bits

We only use the first 16 bytes (128 bits)


· interned

Summary  |  Top
   private static final Hashtable interned

Table of known TypeIDs. Used to keep/find canonical versions of TypeIDs. XXX A global table. Not clear if this really should be global.


  Constructors

· TypeID

Summary  |  Top

   private TypeID() 

No-arg constructor is private to prevent construction of invalid TypeIDs.



· TypeID

Summary  |  Top
   public TypeID(byte[] buf, 
                 int offset) 

Construct a new TypeID and initialize by deep copy.

Parameter Description
buf the byte[] to copy into this new TypeID.
offset offset in buf to copy from

Throws: IndexOutOfBoundsException
if buf is too short


· TypeID

Summary  |  Top
   private TypeID(boolean copybuf, 
                  byte[] buf, 
                  int offset) 

Construct a new type id. Use the given buffer. The copybuf argument indicates if the buffer is copied or simply pointed to.



  Methods

· hashCode

Summary  |  Top
   public int hashCode() 
Overrides:
hashCode in class Object


· equals

Summary  |  Top
   public boolean equals(Object obj) 

Compare this TypeID with the given one. The given TypeID must match all 16 bytes.

Overrides:
equals in class Object


· intern

Summary  |  Top
   public TypeID intern() 

Intern a TypeID and return its canonical value.

Returns:
the canonical version of this TypeID.


· compare

Summary  |  Top
   public int compare(TypeID t) 

Compare two TypeIDs

Returns:
-1 (this < t), 0 (this.equals(t), 1 (this > t)


· sortArray

Summary  |  Top
   public static void sortArray(TypeID[] ids) 

Sort an array of TypeIDs. Good for short vectors only -- uses insertion sort. Sorts the array inline.



· computeFromIDs

Summary  |  Top
   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

Summary  |  Top
   public String toString() 
Overrides:
toString in class Object


· unwrap

Summary  |  Top
   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

Summary  |  Top
   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.

Parameter Description
buf Byte[] containing an MD5 checksum.



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7