Appends the given UID to the given regular expression buffer @param buf The String buffer to modify @param id The UID to add @param close Whether or not to append "\\E" to the end
(final StringBuilder buf, final byte[] id,
final boolean close)
| 590 | * @param close Whether or not to append "\\E" to the end |
| 591 | */ |
| 592 | public static void addId(final StringBuilder buf, final byte[] id, |
| 593 | final boolean close) { |
| 594 | boolean backslash = false; |
| 595 | for (final byte b : id) { |
| 596 | buf.append((char) (b & 0xFF)); |
| 597 | if (b == 'E' && backslash) { // If we saw a `\' and now we have a `E'. |
| 598 | // So we just terminated the quoted section because we just added \E |
| 599 | // to `buf'. So let's put a litteral \E now and start quoting again. |
| 600 | buf.append("\\\\E\\Q"); |
| 601 | } else { |
| 602 | backslash = b == '\\'; |
| 603 | } |
| 604 | } |
| 605 | if (close) { |
| 606 | buf.append("\\E"); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Little helper to print out the regular expression by converting the UID |
no test coverage detected