- All Implemented Interfaces:
Comparable<V4>
Immutable IPv4
Address and 32-bit unsigned integer value.
Use Family.v4() to create values.-
Method Summary
Modifier and TypeMethodDescriptionAddition with overflow.Bitwise AND.intUseful for sorting.Division.doubleLikeNumber.doubleValue().booleanObject equality.family()Internet protocol family - V4 or V6.inthashCode()Hash code.longhighBits()The high bits are out of range for IPv4.intSimilar toInteger.numberOfLeadingZeros(int).longlowBits()The IP address as n long between0Land0xFFFFFFFFL.Modulus.Multiplication with overflow.not()Bitwise NOT.Bitwise OR.shift(int bits) Bitwise shift.Subtraction with underflow.The address as aBigInteger.byte[]toBytes()The address as bytes of lengthFamily.width()/Byte.SIZE.toString()IPv4 address in dotted quad notation.intSimilar toInteger.numberOfTrailingZeros(int).Bitwise exclusive OR.
-
Method Details
-
family
Description copied from class:AddrInternet protocol family - V4 or V6. -
equals
Description copied from class:AddrObject equality. -
hashCode
public int hashCode()Description copied from class:AddrHash code. -
toString
IPv4 address in dotted quad notation. -
compareTo
Useful for sorting.- Parameters:
o- another address- Returns:
- negative, zero, or positive integer as this is less than, equal to, or greater than other address
-
toBigInteger
Description copied from class:AddrThe address as aBigInteger.- Specified by:
toBigIntegerin classAddr<V4>- Returns:
- the address as a positive integer
-
toBytes
public byte[] toBytes()Description copied from class:AddrThe address as bytes of lengthFamily.width()/Byte.SIZE. -
highBits
public long highBits()The high bits are out of range for IPv4. -
lowBits
public long lowBits()The IP address as n long between0Land0xFFFFFFFFL. -
leadingZeros
public int leadingZeros()Description copied from class:AddrSimilar toInteger.numberOfLeadingZeros(int).- Specified by:
leadingZerosin classAddr<V4>- Returns:
- number of zero bits preceding the highest-order ("leftmost") one-bit
-
trailingZeros
public int trailingZeros()Description copied from class:AddrSimilar toInteger.numberOfTrailingZeros(int).- Specified by:
trailingZerosin classAddr<V4>- Returns:
- number of zero bits following the lowest-order ("rightmost") one-bit
-
doubleValue
public double doubleValue()Description copied from class:AddrLikeNumber.doubleValue().- Specified by:
doubleValuein classAddr<V4>- Returns:
- approximate floating point value
-
add
Description copied from class:AddrAddition with overflow. -
subtract
Description copied from class:AddrSubtraction with underflow. -
multiply
Description copied from class:AddrMultiplication with overflow. -
divide
Description copied from class:AddrDivision. -
mod
Description copied from class:AddrModulus. -
and
Description copied from class:AddrBitwise AND.// EXAMPLE // LinkLocal is fe80::/10 private static V6 LL = Family.v6().parse("fe80::"); private static V6 MASK = Family.v6().subnets().masks().get(10); public static boolean isLinkLocal(V6 candidate) { return MASK.and(candidate).equals(LL); } -
or
Description copied from class:AddrBitwise OR. -
xor
Description copied from class:AddrBitwise exclusive OR. -
not
Description copied from class:AddrBitwise NOT.// EXAMPLE // Define 192.168.0.0/24 int maskBits = 24; V4 networkAddress = Family.v4().parse("192.168.0.0"); // 255.255.255.0 V4 mask = Family.v4().subnets().masks().get(maskBits); // 0.0.0.255 V4 inverseMask = mask.not() // 192.168.0.255 V4 lastAddress = inverseMask.or(networkAddress); -
shift
Description copied from class:AddrBitwise shift. Negative operands shift left. Positive operands shift right. Values exceedingFamily.width()overflow as described in The Java Language Specification Java SE 21 Edition 15.19. Shift Operators.// EXAMPLE // 0.0.0.1 V4 one = Family.v4().parse(1); // 0.0.0.2 V4 two = one.shift(-1);
-