MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / toString

Method toString

src/main/java/core/org/xbill/DNS/Name.java:617–640  ·  view source on GitHub ↗

Convert a Name to a String @param omitFinalDot If true, and the name is absolute, omit the final dot. @return The representation of this name as a (printable) String.

(boolean omitFinalDot)

Source from the content-addressed store, hash-verified

615 * @return The representation of this name as a (printable) String.
616 */
617public String
618toString(boolean omitFinalDot) {
619 int labels = labels();
620 if (labels == 0)
621 return "@";
622 else if (labels == 1 && name[offset(0)] == 0)
623 return ".";
624 StringBuffer sb = new StringBuffer();
625 for (int i = 0, pos = offset(0); i < labels; i++) {
626 int len = name[pos];
627 if (len > MAXLABEL)
628 throw new IllegalStateException("invalid label");
629 if (len == 0) {
630 if (!omitFinalDot)
631 sb.append('.');
632 break;
633 }
634 if (i > 0)
635 sb.append('.');
636 sb.append(byteString(name, pos));
637 pos += (1 + len);
638 }
639 return sb.toString();
640}
641
642/**
643 * Convert a Name to a String

Callers 1

byteStringMethod · 0.45

Calls 4

labelsMethod · 0.95
offsetMethod · 0.95
byteStringMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected