SDX Network Information Collector SDK

net.juniper.smgt.gateway.gal
Class NicKey

java.lang.Object
  extended by net.juniper.smgt.gateway.gal.NicKey
All Implemented Interfaces:
java.lang.Comparable

public class NicKey
extends java.lang.Object
implements java.lang.Comparable

The NicKey represents the key object passed to all the lookup methods defined in the NIC or the SaeLocator interface.


Field Summary
static long FOREVER
          max time to live, means key does not expire
static long IGNORE_TIME
          default max time to live, will be ignored in comparison
 
Constructor Summary
NicKey(java.lang.String aKey)
          Constructs a NicKey object given the string representation of the key value.
 
Method Summary
 void addConstraint(java.lang.String name, java.lang.String value)
          Associates the passed-in constraint information to the current key object.
 int compareTo(java.lang.Object anotherKey)
          Compares to NicKeys by their time to live attribute.
 boolean equals(java.lang.Object o)
          NicKeys are equal if they have equal keys and equal constraints
 java.util.SortedMap getConstraints()
          Returns all the constraints associated with the current key object.
static long getCurrentTimeGMT()
          Returns the current time in milliseconds (UTC) in the GMT timezone.
 java.lang.String getKey()
          Returns the string representation of the key value.
 long getTimeToLive()
          Returns time to live
 int hashCode()
          Returns hash code for this NicKey
 boolean isOutdated()
          Returns true if value is outdated
 long setTimeToLive(long keyTimeToLive, long proxyTimeToLive)
          Sets time to live to a min value out of key time and the proxy time to live.
 java.lang.String toString()
          Returns the string representation for the key and constraints
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IGNORE_TIME

public static final long IGNORE_TIME
default max time to live, will be ignored in comparison

See Also:
Constant Field Values

FOREVER

public static final long FOREVER
max time to live, means key does not expire

See Also:
Constant Field Values
Constructor Detail

NicKey

public NicKey(java.lang.String aKey)
Constructs a NicKey object given the string representation of the key value.

Parameters:
aKey - java.lang.String
Method Detail

addConstraint

public void addConstraint(java.lang.String name,
                          java.lang.String value)
Associates the passed-in constraint information to the current key object.

Parameters:
name - java.lang.String the constraint name (should correspond to a NIC data type)
value - String the constraint string value

equals

public boolean equals(java.lang.Object o)
NicKeys are equal if they have equal keys and equal constraints

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to which to test equality
Returns:
boolean true if equal, false otherwise

getConstraints

public java.util.SortedMap getConstraints()
Returns all the constraints associated with the current key object. The returned constraints are in the form of 'name=value' pairs.

Returns:
the Map of constraints if any, null otherwise

getKey

public java.lang.String getKey()
Returns the string representation of the key value.

Returns:
java.langString

hashCode

public int hashCode()
Returns hash code for this NicKey

Overrides:
hashCode in class java.lang.Object
Returns:
int

toString

public java.lang.String toString()
Returns the string representation for the key and constraints

Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

getTimeToLive

public long getTimeToLive()
Returns time to live

Returns:
long

setTimeToLive

public long setTimeToLive(long keyTimeToLive,
                          long proxyTimeToLive)
Sets time to live to a min value out of key time and the proxy time to live. If the proxy time to live is equal to IGNORE_TIME, we set time to live to the key time to live.

Parameters:
keyTimeToLive - long
proxyTimeToLive - long
Returns:
long relative time to live in seconds

getCurrentTimeGMT

public static long getCurrentTimeGMT()
Returns the current time in milliseconds (UTC) in the GMT timezone.

Returns:
long - the current time in GMT
See Also:
#System.currentTimeMillis

isOutdated

public boolean isOutdated()
Returns true if value is outdated

Parameters:
proxyTime - long time to live set on the NicProxy
Returns:
boolean

compareTo

public int compareTo(java.lang.Object anotherKey)
Compares to NicKeys by their time to live attribute. If time to live is the same or for one of the keys it is never been set (default), we compare by key attribute. If key attribute is found to be the same, the comparison is performed on constraints.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
int

SDX Network Information Collector SDK