Package uk.ipfreely
Class V6
- All Implemented Interfaces:
Comparable<V6>
Immutable IPv6
Address
and 128-bit unsigned integer value.
Use Family.v6()
to create values.-
Method Summary
Modifier and TypeMethodDescriptionAddition with overflow.Bitwise AND.int
Useful for sorting.Division.double
LikeNumber.doubleValue()
.boolean
Object equality.family()
Internet protocol family - V4 or V6.int
hashCode()
Hash code.long
highBits()
Useful for efficient conversion.int
Similar toInteger.numberOfLeadingZeros(int)
.long
lowBits()
Useful for efficient conversion.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()
int
Similar toInteger.numberOfTrailingZeros(int)
.Bitwise exclusive OR.
-
Method Details
-
family
Description copied from class:Address
Internet protocol family - V4 or V6. -
equals
Description copied from class:Address
Object equality. -
hashCode
public int hashCode()Description copied from class:Address
Hash code. -
toString
-
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:Address
The address as aBigInteger
.- Specified by:
toBigInteger
in classAddress<V6>
- Returns:
- the address as a positive integer
-
toBytes
public byte[] toBytes()Description copied from class:Address
The address as bytes of lengthFamily.width()
/Byte.SIZE
. -
highBits
public long highBits()Description copied from class:Address
Useful for efficient conversion. -
lowBits
public long lowBits()Description copied from class:Address
Useful for efficient conversion. -
leadingZeros
public int leadingZeros()Description copied from class:Address
Similar toInteger.numberOfLeadingZeros(int)
.- Specified by:
leadingZeros
in classAddress<V6>
- Returns:
- number of zero bits preceding the highest-order ("leftmost") one-bit
-
trailingZeros
public int trailingZeros()Description copied from class:Address
Similar toInteger.numberOfTrailingZeros(int)
.- Specified by:
trailingZeros
in classAddress<V6>
- Returns:
- number of zero bits following the lowest-order ("rightmost") one-bit
-
doubleValue
public double doubleValue()Description copied from class:Address
LikeNumber.doubleValue()
.- Specified by:
doubleValue
in classAddress<V6>
- Returns:
- approximate floating point value
-
add
Description copied from class:Address
Addition with overflow. -
subtract
Description copied from class:Address
Subtraction with underflow. -
multiply
Description copied from class:Address
Multiplication with overflow. -
divide
Description copied from class:Address
Division. -
mod
Description copied from class:Address
Modulus. -
and
Description copied from class:Address
Bitwise 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:Address
Bitwise OR. -
xor
Description copied from class:Address
Bitwise exclusive OR. -
not
Description copied from class:Address
Bitwise 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:Address
Bitwise 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);
-