com.atlassian.ip
Class Subnet

java.lang.Object
  extended by com.atlassian.ip.Subnet

public class Subnet
extends java.lang.Object

IP subnet consisting of a network address and a network mask. Individual ip addresses are represented as all ones subnets. Zero subnets are also allowed.


Method Summary
 boolean equals(java.lang.Object o)
           
static Subnet forAddress(java.net.InetAddress ipAddress)
          Creates an all ones subnet of the given ip address.
static Subnet forPattern(java.lang.String pattern)
          Creates a subnet of the given pattern.
 byte[] getAddress()
          Returns the network address of this subnet.
 int getMask()
          Returns the network mask of this subnet.
 int hashCode()
           
static boolean isValidPattern(java.lang.String pattern)
          Returns true if the given pattern is a valid subnet pattern.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forPattern

public static Subnet forPattern(java.lang.String pattern)
Creates a subnet of the given pattern. Patterns can be IPv4/IPv6 addresses or subnets in both asterisk and CIDR notation. Examples of valid patterns:
 192.168.1.10
 ::10
 192.168.1.*
 192.168.5.128/26
 0:0:0:7b::/64
 

Parameters:
pattern - pattern to create a Subnet of
Returns:
Subnet based on the given pattern

forAddress

public static Subnet forAddress(java.net.InetAddress ipAddress)
Creates an all ones subnet of the given ip address.

Parameters:
ipAddress - ipAddress to create a subnet of
Returns:
all ones subnet based on the given ip address

isValidPattern

public static boolean isValidPattern(java.lang.String pattern)
Returns true if the given pattern is a valid subnet pattern.

Parameters:
pattern - pattern to validate
Returns:
true if the given pattern is a valid subnet pattern

getAddress

public byte[] getAddress()
Returns the network address of this subnet.

Returns:
network address of this subnet

getMask

public int getMask()
Returns the network mask of this subnet.

Returns:
network mask of this subnet

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2012 Atlassian. All Rights Reserved.