DefaultDnsRecordEncoder implements DnsRecordEncoder { protected void encodeName(String name, ByteBuf buf) throws Exception { if (ROOT.equals(name)) { buf.writeByte(0); return; } final String[] labels = name.split("\\."); for (String label : labels) { final int labelLen = label.length(); if (labelLen == 0) { break; } buf.writeByte(labelLen); ByteBufUtil.writeAscii(buf, label); } buf.writeByte(0); } protected  DefaultDnsRecordEncoder(); @Override final void encodeQuestion(DnsQuestion question, ByteBuf out); @Override void encodeRecord(DnsRecord record, ByteBuf out);  }
@Test public void testEncodeName() throws Exception { testEncodeName(new byte[] { 5, 'n', 'e', 't', 't', 'y', 2, 'i', 'o', 0 }, "netty.io."); }