com.eurotech.framework.protocol.pcn
Class IpAddress

java.lang.Object
  extended by com.eurotech.framework.protocol.pcn.IpAddress

public class IpAddress
extends Object

Container for an IP address value.


Field Summary
 int b0
          First octet of IP address
 int b1
          Second octet of IP address
 int b2
          Third octet of IP address
 int b3
          Fourth octet of IP address
 
Constructor Summary
IpAddress()
          Default constructor, sets IP to 0.0.0.0
IpAddress(int ip)
          Convert IP as integer to an IpAddress object
IpAddress(String ipAddressAsString)
          Convert IP as String in dotted notation, to an IpAddress object
 
Method Summary
 int asInteger()
          Returns value of IP address as integer.
 void maskByInvertedSubnet(IpAddress subnet)
          Masks the IpAddress by the inversion of subnet, to obtain a numeric IP broadcast address.
 void maskBySubnet(IpAddress subnet)
          Masks the IpAddress by the specified subnet, to obtain a numeric IP network identifier.
 String toString()
          Returns IP address in dotted notation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

b0

public int b0
First octet of IP address


b1

public int b1
Second octet of IP address


b2

public int b2
Third octet of IP address


b3

public int b3
Fourth octet of IP address

Constructor Detail

IpAddress

public IpAddress()
Default constructor, sets IP to 0.0.0.0


IpAddress

public IpAddress(int ip)
Convert IP as integer to an IpAddress object

Parameters:
ip - - IP address as int

IpAddress

public IpAddress(String ipAddressAsString)
Convert IP as String in dotted notation, to an IpAddress object

Parameters:
ipAddressAsString - IP in dotted notation
Method Detail

asInteger

public int asInteger()
Returns value of IP address as integer. Most significant byte is the first octet, etc.

Returns:
IP address converted to 32-bit integer

maskBySubnet

public void maskBySubnet(IpAddress subnet)
Masks the IpAddress by the specified subnet, to obtain a numeric IP network identifier.

Parameters:
subnet - as IpAddress type

maskByInvertedSubnet

public void maskByInvertedSubnet(IpAddress subnet)
Masks the IpAddress by the inversion of subnet, to obtain a numeric IP broadcast address.

Parameters:
subnet - as IpAddress type

toString

public String toString()
Returns IP address in dotted notation

Overrides:
toString in class Object
Returns:
IP as String


Copyright © 2013. All Rights Reserved.