@Test public void testint16bit2hex() { assertEquals(IPUtils.int16bit2hex(0), "0000"); assertEquals(IPUtils.int16bit2hex(32768), "8000"); assertEquals(IPUtils.int16bit2hex(65536), null); assertEquals(IPUtils.int16bit2hex(-1), null); assertEquals(IPUtils.int16bit2hex(65535), "FFFF"); assertEquals(IPUtils.int16bit2hex(256), "0100"); }
public static String int16bit2hex(int i16) { String out; byte[] nibbles = new byte[4]; int i; if (i16 < 0x0000 || i16 > 0xffff) { return null; } nibbles[0] = int2nibble((i16 & 0xf000) >> 12); nibbles[1] = int2nibble((i16 & 0x0f00) >> 8); nibbles[2] = int2nibble((i16 & 0x00f0) >> 4); nibbles[3] = int2nibble((i16 & 0x000f) >> 0); out = new String(nibbles); return out; }
IPUtils { public static String int16bit2hex(int i16) { String out; byte[] nibbles = new byte[4]; int i; if (i16 < 0x0000 || i16 > 0xffff) { return null; } nibbles[0] = int2nibble((i16 & 0xf000) >> 12); nibbles[1] = int2nibble((i16 & 0x0f00) >> 8); nibbles[2] = int2nibble((i16 & 0x00f0) >> 4); nibbles[3] = int2nibble((i16 & 0x000f) >> 0); out = new String(nibbles); return out; } }
IPUtils { public static String int16bit2hex(int i16) { String out; byte[] nibbles = new byte[4]; int i; if (i16 < 0x0000 || i16 > 0xffff) { return null; } nibbles[0] = int2nibble((i16 & 0xf000) >> 12); nibbles[1] = int2nibble((i16 & 0x0f00) >> 8); nibbles[2] = int2nibble((i16 & 0x00f0) >> 4); nibbles[3] = int2nibble((i16 & 0x000f) >> 0); out = new String(nibbles); return out; }  }
IPUtils { public static String int16bit2hex(int i16) { String out; byte[] nibbles = new byte[4]; int i; if (i16 < 0x0000 || i16 > 0xffff) { return null; } nibbles[0] = int2nibble((i16 & 0xf000) >> 12); nibbles[1] = int2nibble((i16 & 0x0f00) >> 8); nibbles[2] = int2nibble((i16 & 0x00f0) >> 4); nibbles[3] = int2nibble((i16 & 0x000f) >> 0); out = new String(nibbles); return out; }  static Integer rndInt(int lo, int hi); static Double rndDouble(double lo, double hi); static Integer rndPosInt(int lo, int hi); static String rndIp(); static Object rndChoice(List oList); static Object rndChoice(Object[] oArray); static String rndperc(); static final int ubyte2int(byte in); static final byte int2ubyte(int in); static boolean isValidIpv6String(String in); static final boolean isValidIpv4Subnet(String in); static boolean isValidIpv6Subnet(String in); static boolean isValidIpv4String(String in); static int nibble2int(byte nibble); static final byte int2nibble(int in); static String int16bit2hex(int i16); static int hex16bit2int(String in); static boolean IP4RegEx(String ip); static boolean IP6RegEx(String ip); static boolean IPRegEx(String ip); }
IPUtils { public static String int16bit2hex(int i16) { String out; byte[] nibbles = new byte[4]; int i; if (i16 < 0x0000 || i16 > 0xffff) { return null; } nibbles[0] = int2nibble((i16 & 0xf000) >> 12); nibbles[1] = int2nibble((i16 & 0x0f00) >> 8); nibbles[2] = int2nibble((i16 & 0x00f0) >> 4); nibbles[3] = int2nibble((i16 & 0x000f) >> 0); out = new String(nibbles); return out; }  static Integer rndInt(int lo, int hi); static Double rndDouble(double lo, double hi); static Integer rndPosInt(int lo, int hi); static String rndIp(); static Object rndChoice(List oList); static Object rndChoice(Object[] oArray); static String rndperc(); static final int ubyte2int(byte in); static final byte int2ubyte(int in); static boolean isValidIpv6String(String in); static final boolean isValidIpv4Subnet(String in); static boolean isValidIpv6Subnet(String in); static boolean isValidIpv4String(String in); static int nibble2int(byte nibble); static final byte int2nibble(int in); static String int16bit2hex(int i16); static int hex16bit2int(String in); static boolean IP4RegEx(String ip); static boolean IP6RegEx(String ip); static boolean IPRegEx(String ip);  }