ParticipantIDParser { protected static String ipToNormalizedLongString(String ip) { StringBuilder builder = new StringBuilder(); int i = 0,j = 0; while ((j=ip.indexOf('.', i)) != -1) { builder.append(String.format("%03d",Integer.parseInt(ip.substring(i,j)))); i = j+1; } builder.append(String.format("%03d",Integer.parseInt(ip.substring(i, ip.length())))); return builder.toString(); }  static String encode(String raw); static String decode(String encoded); static String[] parseId(String raw); static String getIpAddress(String encoded); static String[] parseEncodedId(String encodedId); static boolean isCall(RemoteParticipant participant); static boolean isMixer(RemoteParticipant participant); static void main(String[] args); static Pattern pattern; }
@Test public void testEncodeIPs() { assertEquals(ParticipantIDParser.ipToNormalizedLongString("127.0.0.1"), "127000000001"); assertEquals(ParticipantIDParser.ipToNormalizedLongString("12.0.20.1"), "012000020001"); assertEquals(ParticipantIDParser.ipToNormalizedLongString("1.0.0.1"), "001000000001"); assertEquals(ParticipantIDParser.ipToNormalizedLongString("127.120.202.221"), "127120202221"); assertEquals(ParticipantIDParser.ipToNormalizedLongString("12.120.22.221"), "012120022221"); }