Package org.apache.mina.filter.util
Class SubnetUtils.SubnetInfo
java.lang.Object
org.apache.mina.filter.util.SubnetUtils.SubnetInfo
- Enclosing class:
- SubnetUtils
Contains subnet summary information.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longMask to convert unsigned int to a long (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintConverts a dotted decimal format address to a packed integer format.private longGets this instance's address into a dotted decimal String.intDeprecated.longGets the count of available addresses.String[]Gets all addresses in this subnet, the return array could be huge.Gets the broadcast address for this subnet.Gets the CIDR signature for this subnet.Gets the high address as a dotted IP address.Gets the low address as a dotted IP address.Gets the network mask for this subnet.Gets the network address for this subnet.Gets the next address for this subnet.Gets the previous address for this subnet.private inthigh()booleanisInRange(int address) Tests if the parameteraddressis in the range of usable endpoint addresses for this subnet.booleanTests if the parameteraddressis in the range of usable endpoint addresses for this subnet.Creates a new Iterable of address Strings.private intlow()private longLong versions of the values (as unsigned int) which are more suitable for range checking.Creates a new Stream of address Strings.toString()
-
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
Converts a dotted decimal format address to a packed integer format.- Parameters:
address- a dotted decimal format address.- Returns:
- packed integer formatted int.
-
broadcastLong
private long broadcastLong() -
getAddress
Gets this instance's address into a dotted decimal String.- Returns:
- a dotted decimal String.
-
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
Gets all addresses in this subnet, the return array could be huge.For large ranges, you can iterate or stream over the addresses instead using
iterableAddressStrings()orstreamAddressStrings().- Returns:
- all addresses in this subnet.
- See Also:
-
getBroadcastAddress
Gets the broadcast address for this subnet.- Returns:
- the broadcast address for this subnet.
-
getCidrSignature
Gets the CIDR signature for this subnet.- Returns:
- the CIDR signature for this subnet.
-
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
Gets the network mask for this subnet.- Returns:
- the network mask for this subnet.
-
getNetworkAddress
Gets the network address for this subnet.- Returns:
- the network address for this subnet.
-
getNextAddress
Gets the next address for this subnet.- Returns:
- the next address for this subnet.
-
getPreviousAddress
Gets the previous address for this subnet.- Returns:
- the previous address for this subnet.
-
high
private int high() -
isInRange
public boolean isInRange(int address) Tests if the parameteraddressis 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 parameteraddressis 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
-
iterableAddressStrings
Creates a new Iterable of address Strings.- Returns:
- a new Iterable of address Strings
- Since:
- 3.12.0
- See Also:
-
low
private int low() -
networkLong
private long networkLong()Long versions of the values (as unsigned int) which are more suitable for range checking. -
streamAddressStrings
Creates a new Stream of address Strings.- Returns:
- a new Stream of address Strings.
- Since:
- 3.12.0
- See Also:
-
toString
-
getAddressCountLong()instead