HOME

com.ireasoning.protocol.snmp
Class SnmpIpAddress

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.SnmpOctetString
      extended bycom.ireasoning.protocol.snmp.SnmpIpAddress
All Implemented Interfaces:
Msg, Serializable, SnmpDataType

public class SnmpIpAddress
extends SnmpOctetString

This class represents Snmp IpAddress data type. The IpAddress type represents a 32-bit internet address. It is represented as an OCTET STRING of length 4, in network byte-order.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.ireasoning.protocol.snmp.SnmpDataType
BITS, BITSTRING, COUNTER32, COUNTER64, END_OF_MIB_VIEW, END_OF_MIB_VIEW_OBJECT, GAUGE32, INTEGER, IPADDRESS, NO_SUCH_INSTANCE, NO_SUCH_INSTANCE_OBJECT, NO_SUCH_OBJECT, NO_SUCH_OBJECT_OBJECT, NULL, OCTETSTRING, OID, OPAQUE, PDU, SEQUENCE, SEQUENCEOF, serialVersionUID, TIMETICKS, UNSIGNED32, VARBIND
 
Fields inherited from interface com.ireasoning.protocol.Msg
ERROR_TYPE
 
Constructor Summary
SnmpIpAddress()
          Constructs an SnmpIpAddress whose ip address is 0.0.0.0
SnmpIpAddress(byte[] data)
          Constructs an SnmpIpAddress object with the passed in data
SnmpIpAddress(InetAddress ipAddr)
          Constructs an SnmpIpAddress with the passed in ipAddr object.
SnmpIpAddress(SnmpIpAddress ipAddr)
          Makes a copy of passed in ipAddr object
SnmpIpAddress(String ipAddr)
          Constructs an SnmpIpAddress with the passed in ipAddr object.
 
Method Summary
 SnmpDataType copy()
          Makes a copy of itself
 int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
          For internal use
 int getType()
          Returns SnmpDataType.IPADDRESS
 String getTypeString()
          Returns "IpAddress"
static boolean isValidIpAddress(String ipAddr)
          Checks if the passed argument is a valid IPv4 address.
 InetAddress toInetAddress()
          Converts to InetAddress object
 String toString()
          Returns a String representation of this object.
 
Methods inherited from class com.ireasoning.protocol.snmp.SnmpOctetString
convertPhysAddress, equals, getBytes, getLength, getValue, hashCode, setValue, toHexString, toPrintableString, toString, toString2
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnmpIpAddress

public SnmpIpAddress()
Constructs an SnmpIpAddress whose ip address is 0.0.0.0


SnmpIpAddress

public SnmpIpAddress(byte[] data)
Constructs an SnmpIpAddress object with the passed in data


SnmpIpAddress

public SnmpIpAddress(SnmpIpAddress ipAddr)
Makes a copy of passed in ipAddr object


SnmpIpAddress

public SnmpIpAddress(String ipAddr)
Constructs an SnmpIpAddress with the passed in ipAddr object. If passed ipAddr is null or an empty string, this class will represent it as 0.0.0.0

Throws:
IllegalArgumentException - raised if passed ipAddr is invalid

SnmpIpAddress

public SnmpIpAddress(InetAddress ipAddr)
Constructs an SnmpIpAddress with the passed in ipAddr object. If passed ipAddr is null or an empty string, this class will represent it as 0.0.0.0

Throws:
IllegalArgumentException - raised if passed ipAddr is invalid
Method Detail

getType

public int getType()
Returns SnmpDataType.IPADDRESS

Specified by:
getType in interface SnmpDataType
Overrides:
getType in class SnmpOctetString

getTypeString

public String getTypeString()
Returns "IpAddress"

Specified by:
getTypeString in interface SnmpDataType
Overrides:
getTypeString in class SnmpOctetString

toString

public String toString()
Description copied from class: SnmpOctetString
Returns a String representation of this object. If this object contains a non-displayable character, it will be automatically switch to hex format, that is, result is the same as toHexString() method.

Overrides:
toString in class SnmpOctetString

toInetAddress

public InetAddress toInetAddress()
Converts to InetAddress object


copy

public SnmpDataType copy()
Description copied from interface: SnmpDataType
Makes a copy of itself

Specified by:
copy in interface SnmpDataType
Overrides:
copy in class SnmpOctetString

encode

public int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
           throws SnmpEncodingException
Description copied from interface: SnmpDataType
For internal use

Specified by:
encode in interface SnmpDataType
Overrides:
encode in class SnmpOctetString
Throws:
SnmpEncodingException

isValidIpAddress

public static boolean isValidIpAddress(String ipAddr)
Checks if the passed argument is a valid IPv4 address.

Returns:
true if the passed ipAddr is valid

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.