Constructors Summary |
---|
public SnmpIpAddress(byte[] bytes)Constructs a new SnmpIpAddress from the specified bytes array.
buildFromByteArray(bytes);
|
public SnmpIpAddress(long addr)Constructs a new SnmpIpAddress from the specified long value.
int address = (int)addr ;
byte[] ipaddr = new byte[4];
ipaddr[0] = (byte) ((address >>> 24) & 0xFF);
ipaddr[1] = (byte) ((address >>> 16) & 0xFF);
ipaddr[2] = (byte) ((address >>> 8) & 0xFF);
ipaddr[3] = (byte) (address & 0xFF);
buildFromByteArray(ipaddr);
|
public SnmpIpAddress(String dotAddress)Constructs a new SnmpIpAddress from a dot-formatted String .
The dot-formatted String is formulated x.x.x.x .
super(dotAddress) ;
if ((componentCount > 4) ||
(components[0] > 255) ||
(components[1] > 255) ||
(components[2] > 255) ||
(components[3] > 255)) {
throw new IllegalArgumentException(dotAddress) ;
}
|
public SnmpIpAddress(long b1, long b2, long b3, long b4)Constructs a new SnmpIpAddress from four long values.
super(b1, b2, b3, b4) ;
if ((components[0] > 255) ||
(components[1] > 255) ||
(components[2] > 255) ||
(components[3] > 255)) {
throw new IllegalArgumentException() ;
}
|
Methods Summary |
---|
public static void | appendToOid(SnmpOid source, SnmpOid dest)Appends an SnmpOid representing an SnmpIpAddress to another OID.
if (source.getLength() != 4) {
throw new IllegalArgumentException() ;
}
dest.append(source) ;
|
private void | buildFromByteArray(byte[] bytes)Build Ip address from byte array.
if (bytes.length != 4) {
throw new IllegalArgumentException() ;
}
components = new long[4] ;
componentCount= 4;
components[0] = (bytes[0] >= 0) ? bytes[0] : bytes[0] + 256 ;
components[1] = (bytes[1] >= 0) ? bytes[1] : bytes[1] + 256 ;
components[2] = (bytes[2] >= 0) ? bytes[2] : bytes[2] + 256 ;
components[3] = (bytes[3] >= 0) ? bytes[3] : bytes[3] + 256 ;
|
public byte[] | byteValue()Converts the address value to its byte array form.
byte[] result = new byte[4] ;
result[0] = (byte)components[0] ;
result[1] = (byte)components[1] ;
result[2] = (byte)components[2] ;
result[3] = (byte)components[3] ;
return result ;
|
public final java.lang.String | getTypeName()Returns a textual description of the type object.
return name ;
|
public static int | nextOid(long[] index, int start)Scans an index OID, skips the address value and returns the position
of the next value.
if (start + 4 <= index.length) {
return start + 4 ;
}
else {
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
}
|
public java.lang.String | stringValue()Converts the address to its String form.
Same as toString() . Exists only to follow a naming scheme.
return toString() ;
|
public static SnmpOid | toOid(long[] index, int start)Extracts the ip address from an index OID and returns its
value converted as an SnmpOid .
if (start + 4 <= index.length) {
try {
return new SnmpOid(
index[start],
index[start+1],
index[start+2],
index[start+3]) ;
}
catch(IllegalArgumentException e) {
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
}
}
else {
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
}
|