Class SubnetUtils

java.lang.Object
org.apache.camel.component.netty.util.SubnetUtils

public class SubnetUtils extends Object
A class that performs some subnet calculations given a network address and a subnet mask.
  • Constructor Details

    • SubnetUtils

      public SubnetUtils(String cidrNotation)
      Constructor that takes 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-3 decimal digits in range 1-32
    • SubnetUtils

      public SubnetUtils(String address, String mask)
      Constructor that takes 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 Details

    • isInclusiveHostCount

      public boolean isInclusiveHostCount()
      Returns true if the return value of SubnetUtils.SubnetInfo.getAddressCount() includes the network and broadcast addresses.
      Returns:
      true if the hostcount includes the network and broadcast addresses
      Since:
      2.2
    • setInclusiveHostCount

      public void setInclusiveHostCount(boolean inclusiveHostCount)
      Set to true if you want the return value of SubnetUtils.SubnetInfo.getAddressCount() to include the network and broadcast addresses.
      Parameters:
      inclusiveHostCount - true if network and broadcast addresses are to be included
      Since:
      2.2
    • getInfo

      public final SubnetUtils.SubnetInfo getInfo()
      Return a SubnetUtils.SubnetInfo instance that contains subnet-specific statistics
      Returns:
      new instance