public class IPv4Address extends IPAddress implements java.lang.Iterable<IPv4Address>
| Modifier and Type | Class and Description |
|---|---|
static class |
IPv4Address.inet_aton_radix |
static interface |
IPv4Address.IPv4AddressConverter |
IPAddress.IPVersionAddress.SegmentValueProvider| Modifier and Type | Field and Description |
|---|---|
static int |
BIT_COUNT |
static int |
BITS_PER_SEGMENT |
static int |
BYTE_COUNT |
static int |
BYTES_PER_SEGMENT |
static int |
DEFAULT_TEXTUAL_RADIX |
static int |
MAX_VALUE_PER_SEGMENT |
static java.lang.String |
REVERSE_DNS_SUFFIX |
static int |
SEGMENT_COUNT |
static char |
SEGMENT_SEPARATOR |
addressConverter, PREFIX_LEN_SEPARATORaddressComparator, ALTERNATIVE_RANGE_SEPARATOR, ALTERNATIVE_RANGE_SEPARATOR_STR, ALTERNATIVE_SEGMENT_WILDCARD_STR, HEX_PREFIX, OCTAL_PREFIX, RANGE_SEPARATOR, RANGE_SEPARATOR_STR, SEGMENT_SQL_SINGLE_WILDCARD, SEGMENT_SQL_SINGLE_WILDCARD_STR, SEGMENT_SQL_WILDCARD, SEGMENT_SQL_WILDCARD_STR, SEGMENT_WILDCARD, SEGMENT_WILDCARD_STR| Constructor and Description |
|---|
IPv4Address(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider)
Constructs an IPv4 address or subnet.
|
IPv4Address(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
java.lang.Integer networkPrefixLength)
Constructs an IPv4 address or subnet.
|
IPv4Address(byte[] bytes)
Constructs an IPv4 address.
|
IPv4Address(byte[] bytes,
java.lang.Integer networkPrefixLength)
Constructs an IPv4 address or subnet.
|
IPv4Address(int address)
Constructs an IPv4 address.
|
IPv4Address(int address,
java.lang.Integer networkPrefixLength)
Constructs an IPv4 address or subnet.
|
IPv4Address(IPv4AddressSection section)
Constructs an IPv4 address or subnet.
|
IPv4Address(IPv4AddressSegment[] segments)
Constructs an IPv4 address or subnet.
|
IPv4Address(IPv4AddressSegment[] segments,
java.lang.Integer networkPrefixLength)
Constructs an IPv4 address or subnet.
|
| Modifier and Type | Method and Description |
|---|---|
IPv4Address |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
IPv4Address |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
IPv4Address |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new address.
|
IPv4Address |
bitwiseOr(IPAddress mask)
Does the bitwise disjunction with this address.
|
IPv4Address |
bitwiseOrNetwork(IPAddress mask,
int networkPrefixLength)
Does the bitwise disjunction with this address.
|
int |
getBitCount() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
IPv4AddressSection |
getHostSection()
Generates the host section of the address.
|
IPv4AddressSection |
getHostSection(int networkPrefixLength)
Generates the host section of the address.
|
IPv6Address |
getIPv4MappedAddress() |
java.lang.Iterable<IPv4Address> |
getIterable()
Useful for using an instance in a "for-each loop".
|
static IPv4Address |
getLoopback() |
IPv4Address |
getLower()
If this represents an address with ranging values, returns an address representing the lower values of the range.
|
IPv4AddressNetwork |
getNetwork() |
IPv4AddressSection |
getNetworkSection()
Generates the network section of the address if the address is a CIDR prefix, otherwise it generates the entire address as a prefixed address with prefix matching the address bit length.
|
IPv4AddressSection |
getNetworkSection(int networkPrefixLength)
Generates the network section of the address.
|
IPv4AddressSection |
getNetworkSection(int networkPrefixLength,
boolean withPrefixLength)
Generates the network section of the address.
|
IPAddressStringDivisionSeries[] |
getParts(IPAddressSection.IPStringBuilderOptions options)
Returns all the ways of breaking this address down into segments, as selected.
|
IPAddressStringDivisionSeries[] |
getParts(IPv4AddressSection.IPv4StringBuilderOptions options) |
IPv4AddressSection |
getSection()
Returns the address as an address section comprising all segments in the address.
|
IPv4AddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
IPv4AddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
IPv4AddressSegment |
getSegment(int index) |
int |
getSegmentCount() |
IPv4AddressSegment[] |
getSegments() |
static java.lang.String[] |
getStandardLoopbackStrings() |
IPv4Address |
getUpper()
If this represents an address with ranging values, returns an address representing the upper values of the range
If this represents an address with a single value in each segment, returns this.
|
boolean |
isIPv4Convertible()
Determines whether this address can be converted to IPv4, if not IPv4 already.
|
boolean |
isIPv6Convertible()
Determines whether an address can be converted to IPv6, if not IPv6 already.
|
boolean |
isLinkLocal() |
boolean |
isLoopback() |
boolean |
isMulticast() |
boolean |
isSiteLocal() |
java.util.Iterator<IPv4Address> |
iterator()
An address component can represent a single segment, address, or section, or it can represent multiple,
typically a subnet or range of segment, address, or section values.
|
IPv4Address |
mask(IPAddress mask)
Applies the given mask to all addresses represented by this IPAddress.
|
IPv4Address |
maskNetwork(IPAddress mask,
int networkPrefixLength)
Applies the given mask up until the given prefix length to all addresses represented by this IPAddress.
|
static IPv4AddressNetwork |
network() |
IPv4Address |
removePrefixLength()
Removes the prefix.
|
IPv4Address |
removePrefixLength(boolean zeroed) |
IPv4Address |
reverseBits(boolean perByte)
Returns a new IPAddress which has the bits reversed.
|
IPv4Address |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
IPv4Address |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
IPv4Address |
reverseSegments()
Returns a new segment series with the segments reversed.
|
java.util.Iterator<IPv4AddressSegment[]> |
segmentsIterator() |
IPv4Address |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
IPv4Address |
setPrefixLength(int prefixLength,
boolean zeroed) |
IPv4Address[] |
subtract(IPAddress other)
Subtract the give subnet from this subnet, returning an array of subnets for the result (the subnets will not be contiguous so an array is required).
|
IPAddressPartStringCollection |
toAllStringCollection() |
java.net.Inet4Address |
toInetAddress() |
java.lang.String |
toInetAtonString(IPv4Address.inet_aton_radix radix)
Returns a string like the inet_aton style string
|
java.lang.String |
toInetAtonString(IPv4Address.inet_aton_radix radix,
int joinedCount) |
IPv4Address |
toIPv4()
If this address is IPv4, or can be converted to IPv4, returns that
IPv4Address. |
IPv6Address |
toIPv6()
Returns this address converted to IPv6.
|
IPAddressPartStringCollection |
toStandardStringCollection() |
IPAddressPartStringCollection |
toStringCollection(IPAddressSection.IPStringBuilderOptions opts) |
IPAddressPartStringCollection |
toStringCollection(IPv4AddressSection.IPv4StringBuilderOptions opts) |
java.lang.String |
toUNCHostName()
Generates the Microsoft UNC path component for this address
|
bitCount, bitsPerSegment, byteCount, contains, contains, from, from, from, from, getBitsPerSegment, getBytesPerSegment, getIPVersion, getLocalHost, getLoopback, getMaskPrefixLength, getMatchesSQLClause, getMatchesSQLClause, getMaxSegmentValue, getNetworkPrefixLength, getSegmentStrings, getStandardLoopbackStrings, isAnyLocal, isIPv4, isIPv6, isLocal, isMultipleByNetworkPrefix, isSameAddress, matches, maxSegmentValue, network, segmentCount, toAddressString, toAllStrings, toBinaryString, toCanonicalHostName, toCanonicalWildcardString, toCompressedWildcardString, toConvertedString, toDelimitedSQLStrs, toFullString, toHostName, toMinPrefixedEquivalent, toNormalizedString, toNormalizedWildcardString, toOctalString, toPrefixedEquivalent, toPrefixLengthString, toReverseDNSLookupString, toSQLWildcardString, toStandardStrings, toStrings, toSubnetStringcompareTo, equals, getBytes, getBytes, getCount, getDivision, getDivisionCount, getEquivalentPrefix, getMinPrefix, getPrefixLength, getSegments, getSegments, getUpperBytes, getUpperBytes, hashCode, isFullRange, isMore, isMultiple, isMultipleByPrefix, isPrefixed, isRangeEquivalentToPrefix, isSameAddress, isZero, toCanonicalString, toCompressedString, toHexString, toNormalizedString, toStringpublic static final char SEGMENT_SEPARATOR
public static final int BITS_PER_SEGMENT
public static final int BYTES_PER_SEGMENT
public static final int SEGMENT_COUNT
public static final int BYTE_COUNT
public static final int BIT_COUNT
public static final int DEFAULT_TEXTUAL_RADIX
public static final int MAX_VALUE_PER_SEGMENT
public static final java.lang.String REVERSE_DNS_SUFFIX
public IPv4Address(IPv4AddressSegment[] segments, java.lang.Integer networkPrefixLength)
segments - the address segmentsnetworkPrefixLength - java.lang.IllegalArgumentException - if segments is not length 4public IPv4Address(IPv4AddressSegment[] segments)
segments - the address segmentsjava.lang.IllegalArgumentException - if segments is not length 4public IPv4Address(IPv4AddressSection section)
section - the address segmentsjava.lang.IllegalArgumentException - if section does not have 4 segmentspublic IPv4Address(int address)
address - the 4 byte IPv4 addresspublic IPv4Address(int address,
java.lang.Integer networkPrefixLength)
address - the 4 byte IPv4 addressnetworkPrefixLength - the CIDR network prefix length, which can be null for no prefixpublic IPv4Address(byte[] bytes)
bytes - must be a 4 byte IPv4 addressjava.lang.IllegalArgumentException - if bytes is not length 4public IPv4Address(byte[] bytes,
java.lang.Integer networkPrefixLength)
bytes - must be a 4 byte IPv4 addressnetworkPrefixLength - the CIDR network prefix length, which can be null for no prefixpublic IPv4Address(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, java.lang.Integer networkPrefixLength)
lowerValueProvider - supplies the 1 byte lower values for each segmentupperValueProvider - supplies the 1 byte upper values for each segmentnetworkPrefixLength - the CIDR network prefix length, which can be null for no prefixpublic IPv4Address(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider)
lowerValueProvider - supplies the 1 byte lower values for each segmentupperValueProvider - supplies the 1 byte upper values for each segmentpublic IPv4AddressSection getSection()
IPAddressgetSection in class IPAddresspublic IPv4AddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in class IPAddresspublic IPv4AddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in class IPAddresspublic IPv4AddressSegment getSegment(int index)
getSegment in interface AddressSegmentSeriesgetSegment in class IPAddresspublic IPv4AddressSegment[] getSegments()
getSegments in interface AddressSegmentSeriesgetSegments in class IPAddresspublic IPAddressStringDivisionSeries[] getParts(IPAddressSection.IPStringBuilderOptions options)
IPAddresspublic IPAddressStringDivisionSeries[] getParts(IPv4AddressSection.IPv4StringBuilderOptions options)
public int getSegmentCount()
getSegmentCount in interface AddressSegmentSeriesgetSegmentCount in class Addresspublic int getByteCount()
AddressComponentgetByteCount in interface AddressComponentgetByteCount in class IPAddresspublic int getBitCount()
getBitCount in interface AddressItemgetBitCount in class Addresspublic IPv4Address toIPv4()
IPAddressIPv4Address. Otherwise, returns null.toIPv4 in class IPAddressIPAddress.isIPv4Convertible()public boolean isIPv4Convertible()
IPAddressIPAddress.toIPv4() to match the conversion.
This method returns true for all IPv4 addresses.isIPv4Convertible in class IPAddresspublic IPv6Address getIPv4MappedAddress()
public boolean isIPv6Convertible()
IPAddressIPAddress.toIPv6() to match the conversion.
This method returns true for all IPv6 addresses.isIPv6Convertible in class IPAddresstoIPv6()public IPv6Address toIPv6()
This uses isIPv6Convertible() to determine convertibility, and that uses an instance of IPAddressConverter.DefaultAddressConverter which uses IPv4-mapped address mappings from rfc 4038.
Override this method and IPv6Address.isIPv4Convertible() if you wish to map IPv4 to IPv6 according to the mappings defined by
in IPv6Address.isIPv4Compatible(), IPv6Address.isIPv4Mapped(), IPv6Address.is6To4() or some other mapping.
If you override this method, you should also override the isIPv6Convertible() method to match this behaviour,
and potentially also override the reverse conversion IPv6Address.toIPv4() in your IPv6Address subclass.
toIPv6 in class IPAddressIPv6Address. Otherwise, returns null.public IPv4Address getLower()
IPAddressgetLower in interface AddressComponentgetLower in interface AddressSegmentSeriesgetLower in class IPAddresspublic IPv4Address getUpper()
IPAddressgetUpper in interface AddressComponentgetUpper in interface AddressSegmentSeriesgetUpper in class IPAddresspublic IPv4Address reverseBits(boolean perByte)
IPAddressreverseBits in interface AddressComponentreverseBits in interface AddressSegmentSeriesreverseBits in class IPAddressperByte - if true, only the bits in each byte are reversed, if false, then all bits in the address are reversedpublic IPv4Address reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSegmentSeriesreverseBytes in class IPAddresspublic IPv4Address reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSegmentSeriesreverseBytesPerSegment in class IPAddresspublic IPv4Address reverseSegments()
AddressSegmentSeriesreverseSegments in interface AddressSegmentSeriesreverseSegments in class IPAddresspublic IPv4Address adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeriesadjustPrefixBySegment in interface AddressSegmentSeriesadjustPrefixBySegment in class IPAddresspublic IPv4Address adjustPrefixLength(int adjustment)
AddressSegmentSeriesadjustPrefixLength in interface AddressSegmentSeriesadjustPrefixLength in class IPAddresspublic IPv4Address setPrefixLength(int prefixLength)
AddressSegmentSeriessetPrefixLength in interface AddressSegmentSeriessetPrefixLength in class IPAddresspublic IPv4Address setPrefixLength(int prefixLength, boolean zeroed)
setPrefixLength in class IPAddresspublic java.util.Iterator<IPv4Address> iterator()
AddressComponentAddressItem.isMultiple() to determine if this instance represents multiple.
This method iterates through the individual elements.iterator in interface AddressComponentiterator in interface AddressSegmentSeriesiterator in interface java.lang.Iterable<IPv4Address>iterator in class IPAddresspublic java.lang.Iterable<IPv4Address> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentSeriesgetIterable in class IPAddresspublic static IPv4AddressNetwork network()
public IPv4AddressNetwork getNetwork()
getNetwork in class IPAddresspublic static IPv4Address getLoopback()
public static java.lang.String[] getStandardLoopbackStrings()
public IPv4Address[] subtract(IPAddress other)
IPAddresspublic IPv4Address applyPrefixLength(int networkPrefixLength) throws AddressTypeException
IPAddressapplyPrefixLength in interface AddressSegmentSeriesapplyPrefixLength in class IPAddressAddressTypeExceptionpublic IPv4Address removePrefixLength(boolean zeroed)
removePrefixLength in class IPAddresspublic IPv4Address removePrefixLength()
AddressSegmentSeriesremovePrefixLength in interface AddressSegmentSeriesremovePrefixLength in class IPAddresspublic IPv4Address mask(IPAddress mask) throws AddressTypeException
IPAddressAddressTypeException is thrown.mask in class IPAddressAddressTypeExceptionpublic IPv4Address maskNetwork(IPAddress mask, int networkPrefixLength) throws AddressTypeException
IPAddressAddressTypeException is thrown.maskNetwork in class IPAddressAddressTypeExceptionpublic IPv4Address bitwiseOr(IPAddress mask) throws AddressTypeException
IPAddressbitwiseOr in class IPAddressAddressTypeExceptionpublic IPv4Address bitwiseOrNetwork(IPAddress mask, int networkPrefixLength) throws AddressTypeException
IPAddressbitwiseOrNetwork in class IPAddressnetworkPrefixLength - the new prefix length for the addressAddressTypeExceptionpublic IPv4AddressSection getNetworkSection(int networkPrefixLength)
IPAddressgetNetworkSection in class IPAddresspublic IPv4AddressSection getNetworkSection(int networkPrefixLength, boolean withPrefixLength)
IPAddressgetNetworkSection in class IPAddresswithPrefixLength - whether the resulting section will have networkPrefixLength as the associated prefix length or notpublic IPv4AddressSection getNetworkSection()
IPAddressgetNetworkSection in class IPAddresspublic IPv4AddressSection getHostSection(int networkPrefixLength)
IPAddressgetHostSection in class IPAddresspublic IPv4AddressSection getHostSection()
IPAddressgetHostSection in class IPAddresspublic java.net.Inet4Address toInetAddress()
toInetAddress in class IPAddresspublic boolean isLinkLocal()
isLinkLocal in class IPAddressInetAddress.isLinkLocalAddress()public boolean isSiteLocal()
isSiteLocal in class IPAddressInetAddress.isSiteLocalAddress()public boolean isMulticast()
isMulticast in class AddressInetAddress.isMulticastAddress()public boolean isLoopback()
isLoopback in class IPAddressInetAddress.isLoopbackAddress()public java.lang.String toInetAtonString(IPv4Address.inet_aton_radix radix)
public java.lang.String toInetAtonString(IPv4Address.inet_aton_radix radix, int joinedCount)
public java.lang.String toUNCHostName()
IPAddresstoUNCHostName in class IPAddresspublic IPAddressPartStringCollection toStandardStringCollection()
toStandardStringCollection in class IPAddresspublic IPAddressPartStringCollection toAllStringCollection()
toAllStringCollection in class IPAddresspublic IPAddressPartStringCollection toStringCollection(IPAddressSection.IPStringBuilderOptions opts)
toStringCollection in class IPAddresspublic IPAddressPartStringCollection toStringCollection(IPv4AddressSection.IPv4StringBuilderOptions opts)
public java.util.Iterator<IPv4AddressSegment[]> segmentsIterator()
segmentsIterator in interface AddressSegmentSeriessegmentsIterator in class IPAddress