org.apache.commons.net.util

## Class SubnetUtils

- java.lang.Object
- - org.apache.commons.net.util.SubnetUtils

-     public class SubnetUtils
      extends Object

  Performs subnet calculations given a network address and a subnet mask.
  See Also:
    "http://www.faqs.org/rfcs/rfc1519.html"

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `SubnetUtils.SubnetInfo` Contains subnet summary information.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubnetUtils(String cidrNotation)` Constructs an instance from a CIDR-notation string, e.g.
    `SubnetUtils(String address, String mask)` Constructs an instance from a dotted decimal address and a dotted decimal mask.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SubnetUtils.SubnetInfo` | `getInfo()` Gets a `SubnetUtils.SubnetInfo` instance that contains subnet-specific statistics
    `SubnetUtils` | `getNext()` Gets the next subnet for this instance.
    `SubnetUtils` | `getPrevious()` Gets the previous subnet for this instance.
    `boolean` | `isInclusiveHostCount()` Tests if the return value of `SubnetUtils.SubnetInfo.getAddressCount()` includes the network and broadcast addresses.
    `void` | `setInclusiveHostCount(boolean inclusiveHostCount)` Sets to `true` if you want the return value of `SubnetUtils.SubnetInfo.getAddressCount()` to include the network and broadcast addresses.
    `String` | `toString()` Converts this instance to a debug String.

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

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

- - ### Constructor Detail

    - #### SubnetUtils

          public SubnetUtils(String cidrNotation)

      Constructs an instance from a CIDR-notation string, e.g. "192.168.0.1/16"
      Parameters:
        `cidrNotation` - A CIDR-notation string, e.g. "192.168.0.1/16"
      Throws:
        `IllegalArgumentException` - if the parameter is invalid, i.e. does not match n.n.n.n/m where n=1-3 decimal digits, m = 1-2 decimal digits in range 0-32

    - #### SubnetUtils

          public SubnetUtils(String address,
                             String mask)

      Constructs an instance from a dotted decimal address and a dotted decimal mask.
      Parameters:
        `address` - An IP address, e.g. "192.168.0.1"
        `mask` - A dotted decimal netmask e.g. "255.255.0.0"
      Throws:
        `IllegalArgumentException` - if the address or mask is invalid, i.e. does not match n.n.n.n where n=1-3 decimal digits and the mask is not all zeros

  - ### Method Detail

    - #### getInfo

          public final SubnetUtils.SubnetInfo getInfo()

      Gets a `SubnetUtils.SubnetInfo` instance that contains subnet-specific statistics
      Returns:
        new instance

    - #### getNext

          public SubnetUtils getNext()

      Gets the next subnet for this instance.
      Returns:
        the next subnet for this instance.

    - #### getPrevious

          public SubnetUtils getPrevious()

      Gets the previous subnet for this instance.
      Returns:
        the next previous for this instance.

    - #### isInclusiveHostCount

          public boolean isInclusiveHostCount()

      Tests if the return value of `SubnetUtils.SubnetInfo.getAddressCount()` includes the network and broadcast addresses.
      Returns:
        true if the host count includes the network and broadcast addresses

    - #### setInclusiveHostCount

          public void setInclusiveHostCount(boolean inclusiveHostCount)

      Sets to `true` if you want the return value of `SubnetUtils.SubnetInfo.getAddressCount()` to include the network and broadcast addresses. This also applies to `SubnetUtils.SubnetInfo.isInRange(int)`
      Parameters:
        `inclusiveHostCount` - true if network and broadcast addresses are to be included

    - #### toString

          public String toString()

      Converts this instance to a debug String.
      Overrides:
        `toString` in class `Object`
      Returns:
        this instance to a debug String.