Package org.apache.commons.net.util
Class SubnetUtils
java.lang.Object
org.apache.commons.net.util.SubnetUtils
Performs subnet calculations given a network address and a subnet mask.
- Since:
- 2.0
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionfinal classConvenience container for subnet summary information.
- 
Constructor SummaryConstructorsConstructorDescriptionSubnetUtils(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 SummaryModifier and TypeMethodDescriptionfinal SubnetUtils.SubnetInfogetInfo()Gets aSubnetUtils.SubnetInfoinstance that contains subnet-specific statisticsgetNext()booleanTests if the return value ofSubnetUtils.SubnetInfo.getAddressCount()includes the network and broadcast addresses.voidsetInclusiveHostCount(boolean inclusiveHostCount) Sets totrueif you want the return value ofSubnetUtils.SubnetInfo.getAddressCount()to include the network and broadcast addresses.toString()Converts this instance to a debug String.
- 
Constructor Details- 
SubnetUtilsConstructs 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
 
- 
SubnetUtilsConstructs 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 Details- 
getInfoGets aSubnetUtils.SubnetInfoinstance that contains subnet-specific statistics- Returns:
- new instance
 
- 
getNext
- 
getPrevious
- 
isInclusiveHostCountTests if the return value ofSubnetUtils.SubnetInfo.getAddressCount()includes the network and broadcast addresses.- Returns:
- true if the host count includes the network and broadcast addresses
- Since:
- 2.2
 
- 
setInclusiveHostCountSets totrueif you want the return value ofSubnetUtils.SubnetInfo.getAddressCount()to include the network and broadcast addresses. This also applies toSubnetUtils.SubnetInfo.isInRange(int)- Parameters:
- inclusiveHostCount- true if network and broadcast addresses are to be included
- Since:
- 2.2
 
- 
toStringConverts this instance to a debug String.
 
-