@Test public void testInsertBigInteger() throws IPStringConversionException{ IPv6 mangle; IPv6 expected; mangle = new IPv6("::"); expected = new IPv6("5678:e3fc::feef:1234:cccc:aaaa"); mangle.insertBigInteger(new BigInteger("feef1234",16),64,32); mangle.insertBigInteger(new BigInteger("e",16),16,4); mangle.insertBigInteger(new BigInteger("3fc",16),20,12); mangle.insertBigInteger(new BigInteger("ccccaaaa",16),96, 32); mangle.insertBigInteger(new BigInteger("5678",16),0,16); assertEquals(expected,mangle); mangle.insertBigInteger(new BigInteger("fefe",16), 80,16); expected = new IPv6("5678:e3fc::feef:fefe:cccc:aaaa"); assertEquals(expected,mangle); mangle.insertBigInteger(new BigInteger("0",16), 16, 96); expected = new IPv6("5678::aaaa"); assertEquals(expected,mangle); }
public void insertBigInteger(BigInteger in, int startBit, int size) throws IPStringConversionException { BigInteger bigInt; BigInteger thisIpInt; BigInteger mask; BigInteger invMask; bigInt = in.or(BigInteger.ZERO); thisIpInt = this.toBigInteger(); mask = maxIp.shiftRight(128 - size); mask = mask.shiftLeft(128 - startBit - size); invMask = mask.xor(maxIp); bigInt = bigInt.shiftLeft(128 - startBit - size); thisIpInt = thisIpInt.and(invMask); bigInt = bigInt.and(mask); thisIpInt = thisIpInt.or(bigInt); try { this.ip = new IPv6(thisIpInt).expand(); } catch (IPBigIntegerConversionException ex) { throw new IPStringConversionException("Impossible exception conditions where already checked"); } }
IPv6 implements Comparable<IPv6> { public void insertBigInteger(BigInteger in, int startBit, int size) throws IPStringConversionException { BigInteger bigInt; BigInteger thisIpInt; BigInteger mask; BigInteger invMask; bigInt = in.or(BigInteger.ZERO); thisIpInt = this.toBigInteger(); mask = maxIp.shiftRight(128 - size); mask = mask.shiftLeft(128 - startBit - size); invMask = mask.xor(maxIp); bigInt = bigInt.shiftLeft(128 - startBit - size); thisIpInt = thisIpInt.and(invMask); bigInt = bigInt.and(mask); thisIpInt = thisIpInt.or(bigInt); try { this.ip = new IPv6(thisIpInt).expand(); } catch (IPBigIntegerConversionException ex) { throw new IPStringConversionException("Impossible exception conditions where already checked"); } } }
IPv6 implements Comparable<IPv6> { public void insertBigInteger(BigInteger in, int startBit, int size) throws IPStringConversionException { BigInteger bigInt; BigInteger thisIpInt; BigInteger mask; BigInteger invMask; bigInt = in.or(BigInteger.ZERO); thisIpInt = this.toBigInteger(); mask = maxIp.shiftRight(128 - size); mask = mask.shiftLeft(128 - startBit - size); invMask = mask.xor(maxIp); bigInt = bigInt.shiftLeft(128 - startBit - size); thisIpInt = thisIpInt.and(invMask); bigInt = bigInt.and(mask); thisIpInt = thisIpInt.or(bigInt); try { this.ip = new IPv6(thisIpInt).expand(); } catch (IPBigIntegerConversionException ex) { throw new IPStringConversionException("Impossible exception conditions where already checked"); } } IPv6(BigInteger in);  IPv6();  IPv6(String ip);  IPv6(byte[] in); }
IPv6 implements Comparable<IPv6> { public void insertBigInteger(BigInteger in, int startBit, int size) throws IPStringConversionException { BigInteger bigInt; BigInteger thisIpInt; BigInteger mask; BigInteger invMask; bigInt = in.or(BigInteger.ZERO); thisIpInt = this.toBigInteger(); mask = maxIp.shiftRight(128 - size); mask = mask.shiftLeft(128 - startBit - size); invMask = mask.xor(maxIp); bigInt = bigInt.shiftLeft(128 - startBit - size); thisIpInt = thisIpInt.and(invMask); bigInt = bigInt.and(mask); thisIpInt = thisIpInt.or(bigInt); try { this.ip = new IPv6(thisIpInt).expand(); } catch (IPBigIntegerConversionException ex) { throw new IPStringConversionException("Impossible exception conditions where already checked"); } } IPv6(BigInteger in);  IPv6();  IPv6(String ip);  IPv6(byte[] in); static String expand(String ipStr, int nwords); String expand(); BigInteger toBigInteger(); static IPv6 bigInteger2IPv6(BigInteger in); static byte[] IpString2bytes(String ipStr); static String bytes2IpString(byte[] in); void setIp(byte[] in); String getString(); byte[] getBytes(); void setIp(String ip); void insertInteger(int in, int startBit); void insertBigInteger(BigInteger in, int startBit, int size); void setAccountPartition(int accountId); void setVipOctets(int lo); int getVipOctets(); void setClusterPartition(IPv6Cidr clusterCidr); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(IPv6 that); }
IPv6 implements Comparable<IPv6> { public void insertBigInteger(BigInteger in, int startBit, int size) throws IPStringConversionException { BigInteger bigInt; BigInteger thisIpInt; BigInteger mask; BigInteger invMask; bigInt = in.or(BigInteger.ZERO); thisIpInt = this.toBigInteger(); mask = maxIp.shiftRight(128 - size); mask = mask.shiftLeft(128 - startBit - size); invMask = mask.xor(maxIp); bigInt = bigInt.shiftLeft(128 - startBit - size); thisIpInt = thisIpInt.and(invMask); bigInt = bigInt.and(mask); thisIpInt = thisIpInt.or(bigInt); try { this.ip = new IPv6(thisIpInt).expand(); } catch (IPBigIntegerConversionException ex) { throw new IPStringConversionException("Impossible exception conditions where already checked"); } } IPv6(BigInteger in);  IPv6();  IPv6(String ip);  IPv6(byte[] in); static String expand(String ipStr, int nwords); String expand(); BigInteger toBigInteger(); static IPv6 bigInteger2IPv6(BigInteger in); static byte[] IpString2bytes(String ipStr); static String bytes2IpString(byte[] in); void setIp(byte[] in); String getString(); byte[] getBytes(); void setIp(String ip); void insertInteger(int in, int startBit); void insertBigInteger(BigInteger in, int startBit, int size); void setAccountPartition(int accountId); void setVipOctets(int lo); int getVipOctets(); void setClusterPartition(IPv6Cidr clusterCidr); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(IPv6 that);  }