hypercast.SPT
Class SPT_LogicalAddress

java.lang.Object
  |
  +--hypercast.SPT.SPT_ID
        |
        +--hypercast.SPT.SPT_LogicalAddress
All Implemented Interfaces:
I_Address, I_LogicalAddress

public final class SPT_LogicalAddress
extends hypercast.SPT.SPT_ID
implements I_LogicalAddress

A logical address on the Spanning Tree Network.


Field Summary
static int ADDRESS_ARRAY_SIZE
           
 
Constructor Summary
SPT_LogicalAddress(byte[] array, int offset)
          Constructor Reads id from a byte array.
SPT_LogicalAddress(hypercast.INETv4OnePort a)
          Constructor Construct the address with ip address
SPT_LogicalAddress(int id)
          constructor with the integer value
SPT_LogicalAddress(hypercast.SPT.SPT_LogicalAddress sptla)
          Constructor
SPT_LogicalAddress(java.lang.String s)
          Constructor
 
Method Summary
 void changeLogicalAddress(hypercast.SPT.SPT_LogicalAddress newAddr)
           
 boolean equals(java.lang.Object o)
          Compares to another SPT_ID
 int getId()
           
 int getSize()
          Returns the size of byte[] used to store address.
 boolean greaterThan(hypercast.I_Address a)
          Checks if an I_address object is greater than this one.
static boolean greaterThan(hypercast.SPT.SPT_ID a, hypercast.SPT.SPT_ID b)
           
 int hashCode()
          Returns the hashcode of this object
 boolean isBetterThan(hypercast.I_Address b)
          SPT node use this function to determine which node is better for root/parent
 void setId(int id)
          Set the id
 byte[] toByteArray()
          Converts the object into a byte array for transfer in a message.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hypercast.I_Address
equals, hashCode
 

Field Detail

ADDRESS_ARRAY_SIZE

public static final int ADDRESS_ARRAY_SIZE
See Also:
Constant Field Values
Constructor Detail

SPT_LogicalAddress

public SPT_LogicalAddress(int id)
constructor with the integer value

Parameters:
id - the ID in the integer form

SPT_LogicalAddress

public SPT_LogicalAddress(hypercast.SPT.SPT_LogicalAddress sptla)
Constructor

Parameters:
sptla - a spt logical address

SPT_LogicalAddress

public SPT_LogicalAddress(byte[] array,
                          int offset)
Constructor Reads id from a byte array. It reads 4 bytes

Parameters:
array - the byte array
offset - the offset to read the array

SPT_LogicalAddress

public SPT_LogicalAddress(java.lang.String s)
Constructor

Parameters:
s - the logical address in string form

SPT_LogicalAddress

public SPT_LogicalAddress(hypercast.INETv4OnePort a)
Constructor Construct the address with ip address

Parameters:
a - the ip address
Method Detail

changeLogicalAddress

public void changeLogicalAddress(hypercast.SPT.SPT_LogicalAddress newAddr)

greaterThan

public boolean greaterThan(hypercast.I_Address a)
Description copied from interface: I_Address
Checks if an I_address object is greater than this one. (Total ordering.)

Specified by:
greaterThan in interface I_Address
See Also:
I_Address.greaterThan(hypercast.I_Address)

isBetterThan

public boolean isBetterThan(hypercast.I_Address b)
SPT node use this function to determine which node is better for root/parent

Parameters:
b - an address object
Returns:
if this address is better than the param address

getSize

public int getSize()
Returns the size of byte[] used to store address.

Specified by:
getSize in interface I_Address
Returns:
4

toByteArray

public byte[] toByteArray()
Converts the object into a byte array for transfer in a message. This is the exact inverse of the constructor that takes a byte array.

Specified by:
toByteArray in interface I_Address
Returns:
the byte array

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the string form of the ID

equals

public boolean equals(java.lang.Object o)
Compares to another SPT_ID

Overrides:
equals in class java.lang.Object
Parameters:
o - an SPT_ID object
Returns:
whether they are equal, or false if the param is null
Throws:
IllegalArgumentException, - if the object is not an instance of SPT_ID

hashCode

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

getId

public int getId()
Returns:
the ID in integer form

setId

public void setId(int id)
Set the id

Parameters:
id -

greaterThan

public static final boolean greaterThan(hypercast.SPT.SPT_ID a,
                                        hypercast.SPT.SPT_ID b)
Returns:
true if SPT_ID a comes before b in the total ordering of points.