@Test public void shouldPrintFirstIpv6Address() { assertEquals("::", Ipv6.FIRST_IPV6_ADDRESS.toString()); }
@Override public String toString() { long[] parts = new long[8]; int currentZeroPartsLength = 0; int currentZeroPartsStart = 0; int maxZeroPartsLength = 0; int maxZeroPartsStart = 0; for (int i = 0; i < parts.length; ++i) { parts[i] = value().shiftRight((7 - i) * BITS_PER_PART).and(FOUR_OCTECT_MASK).longValue(); if (parts[i] == 0) { if (currentZeroPartsLength == 0) { currentZeroPartsStart = i; } ++currentZeroPartsLength; if (currentZeroPartsLength > maxZeroPartsLength) { maxZeroPartsLength = currentZeroPartsLength; maxZeroPartsStart = currentZeroPartsStart; } } else { currentZeroPartsLength = 0; } } StringBuilder sb = new StringBuilder(39); if (maxZeroPartsStart == 0 && maxZeroPartsLength > 1) { sb.append(COLON); } String delimiter = ""; for (int i = 0; i < parts.length; ++i) { if (i == maxZeroPartsStart && maxZeroPartsLength > 1) { i += maxZeroPartsLength; sb.append(COLON); } sb.append(delimiter); if (i <= 7) { sb.append(Long.toHexString(parts[i])); } else { break; } delimiter = COLON; } return sb.toString(); }
Ipv6 extends AbstractIp<Ipv6, Ipv6Range> { @Override public String toString() { long[] parts = new long[8]; int currentZeroPartsLength = 0; int currentZeroPartsStart = 0; int maxZeroPartsLength = 0; int maxZeroPartsStart = 0; for (int i = 0; i < parts.length; ++i) { parts[i] = value().shiftRight((7 - i) * BITS_PER_PART).and(FOUR_OCTECT_MASK).longValue(); if (parts[i] == 0) { if (currentZeroPartsLength == 0) { currentZeroPartsStart = i; } ++currentZeroPartsLength; if (currentZeroPartsLength > maxZeroPartsLength) { maxZeroPartsLength = currentZeroPartsLength; maxZeroPartsStart = currentZeroPartsStart; } } else { currentZeroPartsLength = 0; } } StringBuilder sb = new StringBuilder(39); if (maxZeroPartsStart == 0 && maxZeroPartsLength > 1) { sb.append(COLON); } String delimiter = ""; for (int i = 0; i < parts.length; ++i) { if (i == maxZeroPartsStart && maxZeroPartsLength > 1) { i += maxZeroPartsLength; sb.append(COLON); } sb.append(delimiter); if (i <= 7) { sb.append(Long.toHexString(parts[i])); } else { break; } delimiter = COLON; } return sb.toString(); } }
Ipv6 extends AbstractIp<Ipv6, Ipv6Range> { @Override public String toString() { long[] parts = new long[8]; int currentZeroPartsLength = 0; int currentZeroPartsStart = 0; int maxZeroPartsLength = 0; int maxZeroPartsStart = 0; for (int i = 0; i < parts.length; ++i) { parts[i] = value().shiftRight((7 - i) * BITS_PER_PART).and(FOUR_OCTECT_MASK).longValue(); if (parts[i] == 0) { if (currentZeroPartsLength == 0) { currentZeroPartsStart = i; } ++currentZeroPartsLength; if (currentZeroPartsLength > maxZeroPartsLength) { maxZeroPartsLength = currentZeroPartsLength; maxZeroPartsStart = currentZeroPartsStart; } } else { currentZeroPartsLength = 0; } } StringBuilder sb = new StringBuilder(39); if (maxZeroPartsStart == 0 && maxZeroPartsLength > 1) { sb.append(COLON); } String delimiter = ""; for (int i = 0; i < parts.length; ++i) { if (i == maxZeroPartsStart && maxZeroPartsLength > 1) { i += maxZeroPartsLength; sb.append(COLON); } sb.append(delimiter); if (i <= 7) { sb.append(Long.toHexString(parts[i])); } else { break; } delimiter = COLON; } return sb.toString(); } protected  Ipv6(BigInteger value); }
Ipv6 extends AbstractIp<Ipv6, Ipv6Range> { @Override public String toString() { long[] parts = new long[8]; int currentZeroPartsLength = 0; int currentZeroPartsStart = 0; int maxZeroPartsLength = 0; int maxZeroPartsStart = 0; for (int i = 0; i < parts.length; ++i) { parts[i] = value().shiftRight((7 - i) * BITS_PER_PART).and(FOUR_OCTECT_MASK).longValue(); if (parts[i] == 0) { if (currentZeroPartsLength == 0) { currentZeroPartsStart = i; } ++currentZeroPartsLength; if (currentZeroPartsLength > maxZeroPartsLength) { maxZeroPartsLength = currentZeroPartsLength; maxZeroPartsStart = currentZeroPartsStart; } } else { currentZeroPartsLength = 0; } } StringBuilder sb = new StringBuilder(39); if (maxZeroPartsStart == 0 && maxZeroPartsLength > 1) { sb.append(COLON); } String delimiter = ""; for (int i = 0; i < parts.length; ++i) { if (i == maxZeroPartsStart && maxZeroPartsLength > 1) { i += maxZeroPartsLength; sb.append(COLON); } sb.append(delimiter); if (i <= 7) { sb.append(Long.toHexString(parts[i])); } else { break; } delimiter = COLON; } return sb.toString(); } protected  Ipv6(BigInteger value); static Ipv6 of(BigInteger value); static Ipv6 of(String value); @Override int compareTo(Ipv6 other); @Override Ipv6 next(); @Override Ipv6 previous(); @Override boolean hasNext(); @Override boolean hasPrevious(); @Override Ipv6Range asRange(); @Override String toString(); static Ipv6 parse(final String ipv6Address); @Override int bitSize(); @Override BigInteger asBigInteger(); @Override Ipv6 lowerBoundForPrefix(int prefixLength); @Override Ipv6 upperBoundForPrefix(int prefixLength); @Override int getCommonPrefixLength(Ipv6 other); @Override boolean equals(Object o); @Override int hashCode(); }
Ipv6 extends AbstractIp<Ipv6, Ipv6Range> { @Override public String toString() { long[] parts = new long[8]; int currentZeroPartsLength = 0; int currentZeroPartsStart = 0; int maxZeroPartsLength = 0; int maxZeroPartsStart = 0; for (int i = 0; i < parts.length; ++i) { parts[i] = value().shiftRight((7 - i) * BITS_PER_PART).and(FOUR_OCTECT_MASK).longValue(); if (parts[i] == 0) { if (currentZeroPartsLength == 0) { currentZeroPartsStart = i; } ++currentZeroPartsLength; if (currentZeroPartsLength > maxZeroPartsLength) { maxZeroPartsLength = currentZeroPartsLength; maxZeroPartsStart = currentZeroPartsStart; } } else { currentZeroPartsLength = 0; } } StringBuilder sb = new StringBuilder(39); if (maxZeroPartsStart == 0 && maxZeroPartsLength > 1) { sb.append(COLON); } String delimiter = ""; for (int i = 0; i < parts.length; ++i) { if (i == maxZeroPartsStart && maxZeroPartsLength > 1) { i += maxZeroPartsLength; sb.append(COLON); } sb.append(delimiter); if (i <= 7) { sb.append(Long.toHexString(parts[i])); } else { break; } delimiter = COLON; } return sb.toString(); } protected  Ipv6(BigInteger value); static Ipv6 of(BigInteger value); static Ipv6 of(String value); @Override int compareTo(Ipv6 other); @Override Ipv6 next(); @Override Ipv6 previous(); @Override boolean hasNext(); @Override boolean hasPrevious(); @Override Ipv6Range asRange(); @Override String toString(); static Ipv6 parse(final String ipv6Address); @Override int bitSize(); @Override BigInteger asBigInteger(); @Override Ipv6 lowerBoundForPrefix(int prefixLength); @Override Ipv6 upperBoundForPrefix(int prefixLength); @Override int getCommonPrefixLength(Ipv6 other); @Override boolean equals(Object o); @Override int hashCode(); static final BigInteger FOUR_OCTECT_MASK; static final int NUMBER_OF_BITS; static final BigInteger MINIMUM_VALUE; static final BigInteger MAXIMUM_VALUE; static final Ipv6 FIRST_IPV6_ADDRESS; static final Ipv6 LAST_IPV6_ADDRESS; }