org.friendlysnmp
Class FID

java.lang.Object
  extended by org.friendlysnmp.persist.PersistExternalizable
      extended by org.friendlysnmp.FID
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Comparable<FID>

public class FID
extends PersistExternalizable
implements java.lang.Comparable<FID>

Immutable wrapper which hides org.snmp4j.smi.OID mutable implementation.

Version:
$Revision: 1.15 $
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_NAME
          Default name is <nodef>.
 
Constructor Summary
FID()
          Default ctor for deserialization
FID(int... id)
          Constructor.
FID(org.snmp4j.smi.OID oid)
          Constructor.
FID(org.snmp4j.smi.OID oid, java.lang.String name)
          Constructor.
 
Method Summary
 FID cloneFID()
          Clones this object.
 int compareTo(FID that)
          Implementing Comparable interface.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 byte[] getBytes()
          Returns array of bytes presenting internal OID
 java.lang.String getFIDtoString()
          Returns internal OID + name string.
 int[] getInt()
          Returns array of integers presenting internal OID
 java.lang.String getName()
          Returns name
 org.snmp4j.smi.OID getOID()
          Returns copy of internal OID
 java.lang.String getOIDtoString()
          Returns internal OID toString()
 int hashCode()
          Returns a hash code value for the object.
static FID max(FID a, FID b)
          Compares two objects and returns max object.
 FID next()
          Generates next ID by increasing the max first integer and setting others (if exist) to 1.
 void readExternal(java.io.ObjectInput in)
           
 int size()
          Returns size of internal OID
 java.lang.String toString()
          Returns a string representation of the object.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final java.lang.String DEFAULT_NAME
Default name is <nodef>.

See Also:
Constant Field Values
Constructor Detail

FID

public FID()
Default ctor for deserialization


FID

public FID(int... id)
Constructor. The name will be DEFAULT_NAME

Parameters:
id - comma separated list of integers

FID

public FID(org.snmp4j.smi.OID oid)
Constructor. The name will be DEFAULT_NAME

Parameters:
oid - OID

FID

public FID(org.snmp4j.smi.OID oid,
           java.lang.String name)
Constructor.

Parameters:
oid - OID
name - name
Method Detail

cloneFID

public FID cloneFID()
Clones this object.

Returns:
cloned FID object

getOID

public org.snmp4j.smi.OID getOID()
Returns copy of internal OID

Returns:
copy of internal OID

getInt

public int[] getInt()
Returns array of integers presenting internal OID

Returns:
array of integers presenting internal OID

getBytes

public byte[] getBytes()
Returns array of bytes presenting internal OID

Returns:
array of bytes presenting internal OID

getName

public java.lang.String getName()
Returns name

Returns:
name

next

public FID next()
Generates next ID by increasing the max first integer and setting others (if exist) to 1.

Returns:
next ID

max

public static final FID max(FID a,
                            FID b)
Compares two objects and returns max object.

Parameters:
a - first object
b - second object
Returns:
max object

size

public int size()
Returns size of internal OID

Returns:
size of internal OID

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

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

getOIDtoString

public java.lang.String getOIDtoString()
Returns internal OID toString()

Returns:
internal OID toString()

getFIDtoString

public java.lang.String getFIDtoString()
Returns internal OID + name string.

Returns:
string in format "OID + name" convenient for logging.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

compareTo

public int compareTo(FID that)
Implementing Comparable interface.

Specified by:
compareTo in interface java.lang.Comparable<FID>
See Also:
Comparable.compareTo(java.lang.Object)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class PersistExternalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class PersistExternalizable
Throws:
java.io.IOException