verinec.netsim.addresses
Class IPAddressNetmask

java.lang.Object
  extended by verinec.netsim.addresses.IPAddress
      extended by verinec.netsim.addresses.IPAddressNetmask
All Implemented Interfaces:
Comparable, IAddress

public class IPAddressNetmask
extends IPAddress

This Class represents an IPAddress with Netmask. Convert applies the Netmask to the IPAddress. e.g. IPAddress 192.168.0.1 with Netmask 255.255.255.0. If the Netmask is applied to the Address 192.168.0.0 is returned.

Version:
$Revision: 47 $
Author:
Dominik Jungo

Field Summary
private  IPAddress netmask
           
 
Constructor Summary
IPAddressNetmask()
          Constructs a new IPAddress 0.0.0.0 with Netmask 0.0.0.0
IPAddressNetmask(byte i0, byte i1, byte i2, byte i3)
          Constructs a new IP Address with the Value i0.i1.i2.i3 and Netmask 0.0.0.0
IPAddressNetmask(byte i0, byte i1, byte i2, byte i3, byte n0, byte n1, byte n2, byte n3)
          Constructs a new IP Address with the Value i0.i1.i2.i3 and Netmask n0.n1.n2.n3
IPAddressNetmask(String ipaddress, String netmask)
          Constructs a new IPAddress with Netmask form a String.
 
Method Summary
 IPAddress convert()
          Applies the Netmask to the IPAddress It calculates bitwise or between Address and Netmask.
 IPAddress convert(IPAddress address)
          Applies the Netmask to an IPAddress.
 boolean equals(IPAddress address)
          Applies the Netmask to this IPAddress and the IPAddress given as parameter and then it compares the two resulting Addresses.
 IPAddress getNetmask()
          this method returns the Nemask.
 
Methods inherited from class verinec.netsim.addresses.IPAddress
compareTo, compareTo, compareToDigitByDigit, equals, getPart, getsubnetMask, setPart, toByteArray, toInetAddress, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

netmask

private IPAddress netmask
Constructor Detail

IPAddressNetmask

public IPAddressNetmask()
Constructs a new IPAddress 0.0.0.0 with Netmask 0.0.0.0


IPAddressNetmask

public IPAddressNetmask(byte i0,
                        byte i1,
                        byte i2,
                        byte i3)
Constructs a new IP Address with the Value i0.i1.i2.i3 and Netmask 0.0.0.0

Parameters:
i0 - first byte of the Address
i1 - second byte of the Address
i2 - third byte of the Address
i3 - fourth byte of the Address

IPAddressNetmask

public IPAddressNetmask(byte i0,
                        byte i1,
                        byte i2,
                        byte i3,
                        byte n0,
                        byte n1,
                        byte n2,
                        byte n3)
Constructs a new IP Address with the Value i0.i1.i2.i3 and Netmask n0.n1.n2.n3

Parameters:
i0 - first byte of the Address
i1 - second byte of the Address
i2 - third byte of the Address
i3 - fourth byte of the Address
n0 - first byte of the Netmask
n1 - second byte of the Netmask
n2 - third byte of the Netmask
n3 - fourth byte of the Netmask

IPAddressNetmask

public IPAddressNetmask(String ipaddress,
                        String netmask)
Constructs a new IPAddress with Netmask form a String.

Parameters:
ipaddress - address in String representation with "."s between the four bytes.
netmask - netmask in String representation with "."s between the four bytes.
Method Detail

convert

public IPAddress convert()
Applies the Netmask to the IPAddress It calculates bitwise or between Address and Netmask.

Returns:
this address with applied netmask

convert

public IPAddress convert(IPAddress address)
Applies the Netmask to an IPAddress. It calculates bitwise-or between Address and Netmask. e.g. if the ipaddress is 192.168.20.10 and the subnetmask is 255.255.0.0 you will get 192.168.0.0.

Parameters:
address - an address to convert
Returns:
the ipaddress with applied subnetmask (this subnetmask)

equals

public boolean equals(IPAddress address)
Applies the Netmask to this IPAddress and the IPAddress given as parameter and then it compares the two resulting Addresses.

Parameters:
address - an IPAddress to be comapred with this Address.
Returns:
true if this Address applied with this netmask and the Parameter Address with applied netmask are equal.

getNetmask

public IPAddress getNetmask()
this method returns the Nemask.

Returns:
the Netmask

Copyright © 2005 Verinec, DIUF