DRCL J-Sim API

drcl.data
Class MapKey

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.data.MapKey
All Implemented Interfaces:
java.lang.Cloneable, ObjectCloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
RTKey

public class MapKey
extends DrclObj

MapKey is a pair of value and mask BitSets. A MapKey matches a BitSet if the value masked from the bitset by the mask of the key is equal to the masked value of the key. Also two keys are matched exactly if both the values and masks are matched. A key is said to be matched with the other key in the wildcard manner if the value masked from the masked value of the first key by the mask of the second key is equal to the value masked from the masked value of the second key by the mask of the first key.

See Also:
BitSet, Map, Serialized Form

Field Summary
 BitSet mask
           
 BitSet value
           
 
Constructor Summary
MapKey()
           
MapKey(BitSet mask_, BitSet value_)
          Creates an MapKey given mask and value.
MapKey(long[] mask_, long[] value_)
          Creates an MapKey given mask and value as arrays of long integers.
MapKey(long mask_, long value_)
          Creates an MapKey given mask and value as long integers.
 
Method Summary
 java.lang.String binaryRepresentation()
          Returns the binary representation of this map key.
 java.lang.String binaryRepresentation(boolean skipLeadingZeros_)
          Returns the binary representation of this map key.
 java.lang.String binaryRepresentation(int length_)
          Returns the binary representation of the value and the mask of the map key in the specified number of binary characters.
 void duplicate(java.lang.Object source_)
          opies the content of the source_ object to this object.
 boolean equals(java.lang.Object obj_)
           
 boolean exactMatch(MapKey that_)
          Returns true only if the masks and the masked values of that_ and this key are equal.
 BitSet getMask()
           
 BitSet getValue()
           
 int hashCode()
           
 java.lang.String hexRepresentation()
          Returns the hex representation of this map key.
 java.lang.String hexRepresentation(boolean skipLeadingZeros_)
          Returns the hex representation of this map key.
 java.lang.String hexRepresentation(int length_)
          Returns the hex representation of the value and the mask of the map key in the specified number of hex characters.
 boolean match(BitSet bs_)
          Masks the value of bs_ with the mask of this MapKey and returns true if the masked value is equal to the masked value of this key.
 java.lang.String numberRepresentation()
          Returns the long integer representation of this map key.
 void set(BitSet mask_, BitSet value_)
          Set this MapKey with the given mask and value.
 void setMask(BitSet bs_)
           
 void setValue(BitSet bs_)
           
 java.lang.String toString()
          Prints out the value and the mask of this map key by the set of indices of the bits of 1's in the value and the mask.
 boolean wildcardMatch(MapKey that_)
          Returns true if the masks and the masked values of that_ and this key are equal.
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mask

public BitSet mask

value

public BitSet value
Constructor Detail

MapKey

public MapKey()

MapKey

public MapKey(BitSet mask_,
              BitSet value_)
Creates an MapKey given mask and value.

Parameters:
mask_ - mask.
value_ - value.

MapKey

public MapKey(long mask_,
              long value_)
Creates an MapKey given mask and value as long integers.

Parameters:
mask_ - mask.
value_ - value.

MapKey

public MapKey(long[] mask_,
              long[] value_)
Creates an MapKey given mask and value as arrays of long integers. The arrays are first converted to bitsets. The least significant bit of a bit set is at bit 0 of element 0 in the array.

Parameters:
mask_ - mask.
value_ - value.
Method Detail

set

public void set(BitSet mask_,
                BitSet value_)
Set this MapKey with the given mask and value.

Parameters:
mask_ - mask.
value_ - value.

setValue

public void setValue(BitSet bs_)

getValue

public BitSet getValue()

setMask

public void setMask(BitSet bs_)

getMask

public BitSet getMask()

match

public boolean match(BitSet bs_)
Masks the value of bs_ with the mask of this MapKey and returns true if the masked value is equal to the masked value of this key.

Returns:
true if the masked value of that_ using the mask of this key is equal to the masked value of this key.

exactMatch

public boolean exactMatch(MapKey that_)
Returns true only if the masks and the masked values of that_ and this key are equal.

Parameters:
that_ - the key to be matched.
Returns:
true if the masks and the masked values of that_ and this key are equal.

wildcardMatch

public boolean wildcardMatch(MapKey that_)
Returns true if the masks and the masked values of that_ and this key are equal.

Parameters:
that_ - the key to be matched.
Returns:
true if the masks and the masked values of that_ and this key are equal.

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: DrclObj
opies the content of the source_ object to this object. he subclass must implement this method to realize DrclObj.clone().

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class DrclObj

equals

public boolean equals(java.lang.Object obj_)

hashCode

public int hashCode()

toString

public java.lang.String toString()
Prints out the value and the mask of this map key by the set of indices of the bits of 1's in the value and the mask.

Overrides:
toString in class DrclObj
See Also:
BitSet.toString().

numberRepresentation

public java.lang.String numberRepresentation()
Returns the long integer representation of this map key.


binaryRepresentation

public java.lang.String binaryRepresentation()
Returns the binary representation of this map key.


binaryRepresentation

public java.lang.String binaryRepresentation(boolean skipLeadingZeros_)
Returns the binary representation of this map key.

Parameters:
skipLeadingZeros_ - if true, the leading zeros in the resulting binary represenation is not printed.
See Also:
BitSet.binaryRepresentation(boolean).

binaryRepresentation

public java.lang.String binaryRepresentation(int length_)
Returns the binary representation of the value and the mask of the map key in the specified number of binary characters. It stuffs zeros if the value or the mask is not large enough. The length of the result may exceed the specified length if the value or mask is too large.

Parameters:
length_ - expected number of binary characters.
See Also:
BitSet.binaryRepresentation(int).

hexRepresentation

public java.lang.String hexRepresentation()
Returns the hex representation of this map key.


hexRepresentation

public java.lang.String hexRepresentation(boolean skipLeadingZeros_)
Returns the hex representation of this map key.

Parameters:
skipLeadingZeros_ - if true, the leading zeros in the resulting binary represenation is not printed.
See Also:
BitSet.hexRepresentation(boolean).

hexRepresentation

public java.lang.String hexRepresentation(int length_)
Returns the hex representation of the value and the mask of the map key in the specified number of hex characters. It stuffs zeros if the value or the mask is not large enough. The length of the result may exceed the specified length if the value or mask is too large.

Parameters:
length_ - expected number of hex characters.
See Also:
BitSet.hexRepresentation(int).

DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~