JavaPropertiesResource extends ResourceFilter { static String escapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc) throws ResourceFilterException { if (inputStr.indexOf("'") < 0) { return inputStr; } MessagePattern msgPat = new MessagePattern(ApostropheMode.DOUBLE_OPTIONAL); try { msgPat.parse(inputStr); if (msgPatEsc == MessagePatternEscape.AUTO && !hasArgs(msgPat)) { return inputStr; } } catch (Exception e) { if (msgPatEsc == MessagePatternEscape.ALL) { throw new ResourceFilterException("Illegal message pattern string: " + inputStr); } return inputStr; } return msgPat.autoQuoteApostropheDeep(); } JavaPropertiesResource(Encoding enc, MessagePatternEscape msgPatEsc);  JavaPropertiesResource(); @Override LanguageBundle parse(InputStream inStream, FilterOptions options); @Override void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options); @Override void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options);  }
@Test public void testEscapeMessagePattern() throws ResourceFilterException { for (String[] testCase : MESSAGE_PATTERN_TEST_CASES) { String result = JavaPropertiesResource.escapeMessagePattern(testCase[0], MessagePatternEscape.AUTO); assertEquals("escapeMessagePattern(" + testCase[0] + ", AUTO)", testCase[1], result); } for (String[] testCase : MESSAGE_PATTERN_TEST_CASES) { String result = JavaPropertiesResource.escapeMessagePattern(testCase[0], MessagePatternEscape.ALL); String expected = testCase.length >= 3 && testCase[2] != null ? testCase[2] : testCase[1]; assertEquals("escapeMessagePattern(" + testCase[0] + ", ALL)", expected, result); } }