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)
| 615 | * @return The representation of this name as a (printable) String. |
| 616 | */ |
| 617 | public String |
| 618 | toString(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 |
no test coverage detected