org.jboss.netty.handler.ipfilter

## Class CIDR

- java.lang.Object
- - org.jboss.netty.handler.ipfilter.CIDR

- All Implemented Interfaces:
    Comparable<CIDR>
  Direct Known Subclasses:
    CIDR4, CIDR6

      public abstract class CIDR
      extends Object
      implements Comparable<CIDR>

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected InetAddress` | `baseAddress` The base address of the CIDR notation
    `protected int` | `cidrMask` The mask used in the CIDR notation

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CIDR()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract boolean` | `contains(InetAddress inetAddress)` Compares the given InetAddress against the CIDR and returns true if the ip is in the subnet-ip-range and false if not.
    `boolean` | `equals(Object arg0)`
    `InetAddress` | `getBaseAddress()`
    `abstract InetAddress` | `getEndAddress()`
    `static byte[]` | `getIpV4FromIpV6(Inet6Address address)` Compute a byte representation of IpV4 from a IpV6
    `static byte[]` | `getIpV6FromIpV4(Inet4Address address)` Compute a byte representation of IpV6 from a IpV4
    `int` | `getMask()`
    `int` | `hashCode()`
    `static CIDR` | `newCIDR(InetAddress baseAddress, int cidrMask)` Create CIDR using the CIDR Notation
    `static CIDR` | `newCIDR(InetAddress baseAddress, String scidrMask)` Create CIDR using the normal Notation
    `static CIDR` | `newCIDR(String cidr)` Create CIDR using the CIDR or normal Notation i.e.: CIDR subnet = newCIDR ("10.10.10.0/24"); or CIDR subnet = newCIDR ("1fff:0:0a88:85a3:0:0:ac1f:8001/24"); or CIDR subnet = newCIDR ("10.10.10.0/255.255.255.0");
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### baseAddress

          protected InetAddress baseAddress

      The base address of the CIDR notation

    - #### cidrMask

          protected int cidrMask

      The mask used in the CIDR notation

  - ### Constructor Detail

    - #### CIDR

          public CIDR()

  - ### Method Detail

    - #### newCIDR

          public static CIDR newCIDR(InetAddress baseAddress,
                     int cidrMask)
                              throws UnknownHostException

      Create CIDR using the CIDR Notation
      Returns:
        the generated CIDR
      Throws:
        `UnknownHostException`

    - #### newCIDR

          public static CIDR newCIDR(InetAddress baseAddress,
                     String scidrMask)
                              throws UnknownHostException

      Create CIDR using the normal Notation
      Returns:
        the generated CIDR
      Throws:
        `UnknownHostException`

    - #### newCIDR

          public static CIDR newCIDR(String cidr)
                              throws UnknownHostException

      Create CIDR using the CIDR or normal Notation
      i.e.: CIDR subnet = newCIDR ("10.10.10.0/24"); or CIDR subnet = newCIDR ("1fff:0:0a88:85a3:0:0:ac1f:8001/24"); or CIDR subnet = newCIDR ("10.10.10.0/255.255.255.0");
      Returns:
        the generated CIDR
      Throws:
        `UnknownHostException`

    - #### getBaseAddress

          public InetAddress getBaseAddress()

      Returns:
        the baseAddress of the CIDR block.

    - #### getMask

          public int getMask()

      Returns:
        the Mask length.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`
      Returns:
        the textual CIDR notation.

    - #### getEndAddress

          public abstract InetAddress getEndAddress()

      Returns:
        the end address of this block.

    - #### contains

          public abstract boolean contains(InetAddress inetAddress)

      Compares the given InetAddress against the CIDR and returns true if the ip is in the subnet-ip-range and false if not.
      Returns:
        returns true if the given IP address is inside the currently set network.

    - #### equals

          public boolean equals(Object arg0)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getIpV4FromIpV6

          public static byte[] getIpV4FromIpV6(Inet6Address address)

      Compute a byte representation of IpV4 from a IpV6
      Returns:
        the byte representation
      Throws:
        `IllegalArgumentException` - if the IpV6 cannot be mapped to IpV4

    - #### getIpV6FromIpV4

          public static byte[] getIpV6FromIpV4(Inet4Address address)

      Compute a byte representation of IpV6 from a IpV4
      Returns:
        the byte representation
      Throws:
        `IllegalArgumentException` - if the IpV6 cannot be mapped to IpV4

Copyright © 2008-2012 The Netty Project. All Rights Reserved.