Package org.apache.commons.net.util
Class SubnetUtils.SubnetInfo
java.lang.Object
org.apache.commons.net.util.SubnetUtils.SubnetInfo
- Enclosing class:
- SubnetUtils
Convenience container for subnet summary information.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Mask to convert unsigned int to a long (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
private long
private String
format
(int[] octets) Converts a 4-element array into dotted decimal format.int
Deprecated.long
Gets the count of available addresses.String[]
Gets the high address as a dotted IP address.Gets the low address as a dotted IP address.private int
high()
boolean
isInRange
(int address) Tests if the parameteraddress
is in the range of usable endpoint addresses for this subnet.boolean
Tests if the parameteraddress
is in the range of usable endpoint addresses for this subnet.private int
low()
private long
long versions of the values (as unsigned int) which are more suitable for range checking.private int[]
toArray
(int val) Converts a packed integer address into a 4-element arraytoString()
-
Field Details
-
UNSIGNED_INT_MASK
private static final long UNSIGNED_INT_MASKMask to convert unsigned int to a long (i.e. keep 32 bits).- See Also:
-
-
Constructor Details
-
SubnetInfo
private SubnetInfo()
-
-
Method Details
-
asInteger
-
broadcastLong
private long broadcastLong() -
format
Converts a 4-element array into dotted decimal format. -
getAddress
-
getAddressCount
Deprecated.(3.4) usegetAddressCountLong()
insteadGets the count of available addresses. Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.- Returns:
- the count of addresses, may be zero.
- Throws:
RuntimeException
- if the correct count is greater thanInteger.MAX_VALUE
-
getAddressCountLong
public long getAddressCountLong()Gets the count of available addresses. Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.- Returns:
- the count of addresses, may be zero.
- Since:
- 3.4
-
getAllAddresses
-
getBroadcastAddress
-
getCidrSignature
-
getHighAddress
Gets the high address as a dotted IP address. Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.- Returns:
- the IP address in dotted format, may be "0.0.0.0" if there is no valid address
-
getLowAddress
Gets the low address as a dotted IP address. Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.- Returns:
- the IP address in dotted format, may be "0.0.0.0" if there is no valid address
-
getNetmask
-
getNetworkAddress
-
getNextAddress
-
getPreviousAddress
-
high
private int high() -
isInRange
public boolean isInRange(int address) Tests if the parameteraddress
is in the range of usable endpoint addresses for this subnet. This excludes the network and broadcast addresses by default. UseSubnetUtils.setInclusiveHostCount(boolean)
to change this.- Parameters:
address
- the address to check- Returns:
- true if it is in range
- Since:
- 3.4 (made public)
-
isInRange
Tests if the parameteraddress
is in the range of usable endpoint addresses for this subnet. This excludes the network and broadcast addresses. UseSubnetUtils.setInclusiveHostCount(boolean)
to change this.- Parameters:
address
- A dot-delimited IPv4 address, e.g. "192.168.0.1"- Returns:
- True if in range, false otherwise
-
low
private int low() -
networkLong
private long networkLong()long versions of the values (as unsigned int) which are more suitable for range checking. -
toArray
private int[] toArray(int val) Converts a packed integer address into a 4-element array -
toString
-
getAddressCountLong()
instead