org.n52.security.common.ip
Class IP4AddressMask

java.lang.Object
  extended by org.n52.security.common.ip.IP4AddressMask
All Implemented Interfaces:
IPAddressMask, IPRange

public class IP4AddressMask
extends Object
implements IPAddressMask

Represents an IP address mask that consists of an IPv4 address and a subnet mask. The subnet mask is a number of bits that defines the network prefix length, i.e. a number between 0 and 32 vor IP4 addresses.

Author:
jdr

Nested Class Summary
static class IP4AddressMask.IP4Mask
           
 
Constructor Summary
IP4AddressMask(Inet4Address address, int mask)
          Creates a new IP4 address mask.
 
Method Summary
 boolean contains(InetAddress address)
          Checks whether a given IP address is part of this IP address range.
 boolean equals(Object obj)
           
 InetAddress first()
           
 InetAddress getAddress()
           
 byte[] getMask()
           
 int hashCode()
           
 InetAddress last()
           
 String toString()
          Mask as a String in the form of "190.10.1.0/24".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IP4AddressMask

public IP4AddressMask(Inet4Address address,
                      int mask)
Creates a new IP4 address mask.

Parameters:
address - Base IP4 address of the IP address mask.
mask - subnet mask length to be applied. Must be a value between 0 and 32.
Method Detail

getMask

public byte[] getMask()
Specified by:
getMask in interface IPAddressMask

getAddress

public InetAddress getAddress()
Specified by:
getAddress in interface IPAddressMask

toString

public String toString()
Mask as a String in the form of "190.10.1.0/24".

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

contains

public boolean contains(InetAddress address)
Description copied from interface: IPRange
Checks whether a given IP address is part of this IP address range.

Specified by:
contains in interface IPRange
Parameters:
address - the address to test.
Returns:
true if the specified address is in the range, false otherwise.

first

public InetAddress first()
Specified by:
first in interface IPRange
Returns:
IP address that is the upper border of the range.

last

public InetAddress last()
Specified by:
last in interface IPRange
Returns:
IP address that is the lower border of the range.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2004–2013 52north.org. All rights reserved.