@Test public void testBraceFormatNextTermFails() { try { int unused = BraceStyleMessageParser.nextBraceFormatTerm("Hello '", 0); fail("expected ParseException"); } catch (ParseException expected) { assertThat(expected.getMessage()).contains("[']"); } try { int unused = BraceStyleMessageParser.nextBraceFormatTerm("Hello 'World", 0); fail("expected ParseException"); } catch (ParseException expected) { assertThat(expected.getMessage()).contains("['World]"); } }
static int nextBraceFormatTerm(String message, int pos) throws ParseException { while (pos < message.length()) { char c = message.charAt(pos++); if (c == '{') { return pos - 1; } if (c != '\'') { continue; } if (pos == message.length()) { throw ParseException.withStartPosition("trailing single quote", message, pos - 1); } if (message.charAt(pos++) == '\'') { continue; } int quote = pos - 2; do { if (pos == message.length()) { throw ParseException.withStartPosition("unmatched single quote", message, quote); } } while (message.charAt(pos++) != '\''); } return -1; }
BraceStyleMessageParser extends MessageParser { static int nextBraceFormatTerm(String message, int pos) throws ParseException { while (pos < message.length()) { char c = message.charAt(pos++); if (c == '{') { return pos - 1; } if (c != '\'') { continue; } if (pos == message.length()) { throw ParseException.withStartPosition("trailing single quote", message, pos - 1); } if (message.charAt(pos++) == '\'') { continue; } int quote = pos - 2; do { if (pos == message.length()) { throw ParseException.withStartPosition("unmatched single quote", message, quote); } } while (message.charAt(pos++) != '\''); } return -1; } }
BraceStyleMessageParser extends MessageParser { static int nextBraceFormatTerm(String message, int pos) throws ParseException { while (pos < message.length()) { char c = message.charAt(pos++); if (c == '{') { return pos - 1; } if (c != '\'') { continue; } if (pos == message.length()) { throw ParseException.withStartPosition("trailing single quote", message, pos - 1); } if (message.charAt(pos++) == '\'') { continue; } int quote = pos - 2; do { if (pos == message.length()) { throw ParseException.withStartPosition("unmatched single quote", message, quote); } } while (message.charAt(pos++) != '\''); } return -1; }  }
BraceStyleMessageParser extends MessageParser { static int nextBraceFormatTerm(String message, int pos) throws ParseException { while (pos < message.length()) { char c = message.charAt(pos++); if (c == '{') { return pos - 1; } if (c != '\'') { continue; } if (pos == message.length()) { throw ParseException.withStartPosition("trailing single quote", message, pos - 1); } if (message.charAt(pos++) == '\'') { continue; } int quote = pos - 2; do { if (pos == message.length()) { throw ParseException.withStartPosition("unmatched single quote", message, quote); } } while (message.charAt(pos++) != '\''); } return -1; }  @Override final void unescape(StringBuilder out, String message, int start, int end); }
BraceStyleMessageParser extends MessageParser { static int nextBraceFormatTerm(String message, int pos) throws ParseException { while (pos < message.length()) { char c = message.charAt(pos++); if (c == '{') { return pos - 1; } if (c != '\'') { continue; } if (pos == message.length()) { throw ParseException.withStartPosition("trailing single quote", message, pos - 1); } if (message.charAt(pos++) == '\'') { continue; } int quote = pos - 2; do { if (pos == message.length()) { throw ParseException.withStartPosition("unmatched single quote", message, quote); } } while (message.charAt(pos++) != '\''); } return -1; }  @Override final void unescape(StringBuilder out, String message, int start, int end);  }