test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/properties/input.properties")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/properties/input.properties");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File(
              "src/test/resource/resfilter/properties/write-output.properties")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File(
              "src/test/resource/resfilter/properties/write-output.properties");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: EXPECTED_WRITE_FILE_ALL = new File(
              "src/test/resource/resfilter/properties/write-output-all.properties")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE_ALL = new File(
              "src/test/resource/resfilter/properties/write-output-all.properties");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE_ALL
test_class.declarator: EXPECTED_MERGE_FILE = new File(
              "src/test/resource/resfilter/properties/merge-output.properties")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_MERGE_FILE = new File(
              "src/test/resource/resfilter/properties/merge-output.properties");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_FILE
test_class.declarator: PARSE_TEST_INPUT_FILE = new File(
              "src/test/resource/resfilter/properties/parseline-test-input.properties")
test_class.modifier: private static final
test_class.original_string: private static final File PARSE_TEST_INPUT_FILE = new File(
              "src/test/resource/resfilter/properties/parseline-test-input.properties");
test_class.type: File
test_class.var_name: PARSE_TEST_INPUT_FILE
test_class.declarator: EXPECTED_INPUT_RES_LIST
test_class.modifier: private static final
test_class.original_string: private static final Collection<ResourceString> EXPECTED_INPUT_RES_LIST;
test_class.type: Collection<ResourceString>
test_class.var_name: EXPECTED_INPUT_RES_LIST
test_class.declarator: WRITE_BUNDLE
test_class.modifier: private static
test_class.original_string: private static LanguageBundle WRITE_BUNDLE;
test_class.type: LanguageBundle
test_class.var_name: WRITE_BUNDLE
test_class.declarator: WRITE_BUNDLE_ALL
test_class.modifier: private static
test_class.original_string: private static LanguageBundle WRITE_BUNDLE_ALL;
test_class.type: LanguageBundle
test_class.var_name: WRITE_BUNDLE_ALL
test_class.declarator: EXPECTED_PROP_DEF_LIST
test_class.modifier: private static
test_class.original_string: private static LinkedList<PropDef> EXPECTED_PROP_DEF_LIST;
test_class.type: LinkedList<PropDef>
test_class.var_name: EXPECTED_PROP_DEF_LIST
test_class.declarator: res = new JavaPropertiesResource()
test_class.modifier: private static final
test_class.original_string: private static final JavaPropertiesResource res = new JavaPropertiesResource();
test_class.type: JavaPropertiesResource
test_class.var_name: res
test_class.declarator: UNESC_TEST_CASES =
      {
          {"", ""},
          {"abc", "abc"},
          {"\\ abc\\u0020", " abc "},
          {"a\\tb\\u0009c", "a\tb\tc"},
          {"a\\=\\b", "a=b"},
          {"a\\\\b", "a\\b"},
          {"\\t\\f\\z", "\t\fz"},
          {"\\a\\b\\c", "abc"},
          {"\\u304A\\u304b", "\u304A\u304B"},
      }
test_class.modifier: private static final
test_class.original_string: private static final String[][] UNESC_TEST_CASES =
      {
          {"", ""},
          {"abc", "abc"},
          {"\\ abc\\u0020", " abc "},
          {"a\\tb\\u0009c", "a\tb\tc"},
          {"a\\=\\b", "a=b"},
          {"a\\\\b", "a\\b"},
          {"\\t\\f\\z", "\t\fz"},
          {"\\a\\b\\c", "abc"},
          {"\\u304A\\u304b", "\u304A\u304B"},
      };
test_class.type: String[][]
test_class.var_name: UNESC_TEST_CASES
test_class.declarator: MESSAGE_PATTERN_TEST_CASES = {
          // {<GP expression>,
          //     <props expression - auto>[,
          //     <props expression - all>,                    // if absent, use <prop expression - auto>
          //     <GP expression after round trip - auto>,     // if absent, use <GP expression>
          //     <GP expression after round trip - all>]}     // if absent, use <GP expression>
          { "You're about to delete {0} rows.",
              "You''re about to delete {0} rows." },
          { "You're about to delete '{0}' rows in Mike's file {0}.",
              "You''re about to delete '{0}' rows in Mike''s file {0}." },
          { "Log shows '{''}' in file {0}",
              "Log shows '{''}' in file {0}" },
          { "Log shows '{''} in file {0}",
              "Log shows '{''} in file {0}",
              "Log shows '{''} in file {0}'", // escape with MessagePatternEscape.ALL
              null,
              "Log shows '{''} in file {0}'"}, // round trip with MessagePatternEscape.ALL
          { "Log shows '{'}' in file {0}",
              "Log shows '{'}'' in file {0}" },
          { "Log shows '{'error'}' in file {0}",
              "Log shows '{'error'}' in file {0}" },
          { "Log shows '{''error''}' in file {0}",
              "Log shows '{''error''}' in file {0}" },
          { "File {0} shows '{''error''}'",
              "File {0} shows '{''error''}'" },
          { "The file isn't in use.",
              "The file isn't in use.",
              "The file isn''t in use." }, // escape with MessagePatternEscape.ALL
          { "File {0} isn't in use.",
              "File {0} isn''t in use."},
      }
test_class.modifier: private static final
test_class.original_string: private static final String[][] MESSAGE_PATTERN_TEST_CASES = {
          // {<GP expression>,
          //     <props expression - auto>[,
          //     <props expression - all>,                    // if absent, use <prop expression - auto>
          //     <GP expression after round trip - auto>,     // if absent, use <GP expression>
          //     <GP expression after round trip - all>]}     // if absent, use <GP expression>
          { "You're about to delete {0} rows.",
              "You''re about to delete {0} rows." },
          { "You're about to delete '{0}' rows in Mike's file {0}.",
              "You''re about to delete '{0}' rows in Mike''s file {0}." },
          { "Log shows '{''}' in file {0}",
              "Log shows '{''}' in file {0}" },
          { "Log shows '{''} in file {0}",
              "Log shows '{''} in file {0}",
              "Log shows '{''} in file {0}'", // escape with MessagePatternEscape.ALL
              null,
              "Log shows '{''} in file {0}'"}, // round trip with MessagePatternEscape.ALL
          { "Log shows '{'}' in file {0}",
              "Log shows '{'}'' in file {0}" },
          { "Log shows '{'error'}' in file {0}",
              "Log shows '{'error'}' in file {0}" },
          { "Log shows '{''error''}' in file {0}",
              "Log shows '{''error''}' in file {0}" },
          { "File {0} shows '{''error''}'",
              "File {0} shows '{''error''}'" },
          { "The file isn't in use.",
              "The file isn't in use.",
              "The file isn''t in use." }, // escape with MessagePatternEscape.ALL
          { "File {0} isn't in use.",
              "File {0} isn''t in use."},
      };
test_class.type: String[][]
test_class.var_name: MESSAGE_PATTERN_TEST_CASES
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/JavaPropertiesResourceTest.java
test_class.identifier: JavaPropertiesResourceTest
test_case.body: @Test
      public void testMerge() throws IOException, ResourceFilterException {
          File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".properties");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile); InputStream is = new FileInputStream(INPUT_FILE)) {
              res.merge(is, os, WRITE_BUNDLE, new FilterOptions(Locale.ENGLISH));
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_FILE, tempFile));
          }
      }
test_case.class_method_signature: JavaPropertiesResourceTest.testMerge()
test_case.full_signature: @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit merge flush assertTrue compareFiles
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: enc
focal_class.modifier: private final
focal_class.original_string: private final Encoding enc;
focal_class.type: Encoding
focal_class.var_name: enc
focal_class.declarator: msgPatEsc
focal_class.modifier: private final
focal_class.original_string: private final MessagePatternEscape msgPatEsc;
focal_class.type: MessagePatternEscape
focal_class.var_name: msgPatEsc
focal_class.declarator: BACKSLASH = '\\'
focal_class.modifier: private static final
focal_class.original_string: private static final char BACKSLASH = '\\';
focal_class.type: char
focal_class.var_name: BACKSLASH
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/JavaPropertiesResource.java
focal_class.identifier: JavaPropertiesResource
focal_class.class_method_signature: JavaPropertiesResource.JavaPropertiesResource(Encoding enc, MessagePatternEscape msgPatEsc)
focal_class.full_signature: public  JavaPropertiesResource(Encoding enc, MessagePatternEscape msgPatEsc)
focal_class.identifier: JavaPropertiesResource
focal_class.modifiers: public
focal_class.parameters: (Encoding enc, MessagePatternEscape msgPatEsc)
focal_class.signature:  JavaPropertiesResource(Encoding enc, MessagePatternEscape msgPatEsc)
focal_class.class_method_signature: JavaPropertiesResource.JavaPropertiesResource()
focal_class.full_signature: public  JavaPropertiesResource()
focal_class.identifier: JavaPropertiesResource
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  JavaPropertiesResource()
focal_class.class_method_signature: JavaPropertiesResource.parse(InputStream inStream, FilterOptions options)
focal_class.full_signature: @Override public LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.identifier: parse
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream inStream, FilterOptions options)
focal_class.return: LanguageBundle
focal_class.signature: LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.class_method_signature: JavaPropertiesResource.isContinuationLine(String s)
focal_class.full_signature: private boolean isContinuationLine(String s)
focal_class.identifier: isContinuationLine
focal_class.modifiers: private
focal_class.parameters: (String s)
focal_class.return: boolean
focal_class.signature: boolean isContinuationLine(String s)
focal_class.class_method_signature: JavaPropertiesResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.return: void
focal_class.signature: void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.class_method_signature: JavaPropertiesResource.getCharset()
focal_class.full_signature: private Charset getCharset()
focal_class.identifier: getCharset
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Charset
focal_class.signature: Charset getCharset()
focal_class.class_method_signature: JavaPropertiesResource.escape(String str, EscapeSpace escSpace, boolean isUTF8)
focal_class.full_signature: private static String escape(String str, EscapeSpace escSpace, boolean isUTF8)
focal_class.identifier: escape
focal_class.modifiers: private static
focal_class.parameters: (String str, EscapeSpace escSpace, boolean isUTF8)
focal_class.return: String
focal_class.signature: String escape(String str, EscapeSpace escSpace, boolean isUTF8)
focal_class.class_method_signature: JavaPropertiesResource.escapePropKey(String str)
focal_class.full_signature: static String escapePropKey(String str)
focal_class.identifier: escapePropKey
focal_class.modifiers: static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String escapePropKey(String str)
focal_class.class_method_signature: JavaPropertiesResource.escapePropKey(String str, boolean isUTF8)
focal_class.full_signature: static String escapePropKey(String str, boolean isUTF8)
focal_class.identifier: escapePropKey
focal_class.modifiers: static
focal_class.parameters: (String str, boolean isUTF8)
focal_class.return: String
focal_class.signature: String escapePropKey(String str, boolean isUTF8)
focal_class.class_method_signature: JavaPropertiesResource.escapePropValue(String str)
focal_class.full_signature: static String escapePropValue(String str)
focal_class.identifier: escapePropValue
focal_class.modifiers: static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String escapePropValue(String str)
focal_class.class_method_signature: JavaPropertiesResource.escapePropValue(String str, boolean isUTF8)
focal_class.full_signature: static String escapePropValue(String str, boolean isUTF8)
focal_class.identifier: escapePropValue
focal_class.modifiers: static
focal_class.parameters: (String str, boolean isUTF8)
focal_class.return: String
focal_class.signature: String escapePropValue(String str, boolean isUTF8)
focal_class.class_method_signature: JavaPropertiesResource.appendUnicodeEscape(StringBuilder buf, char codeUnit)
focal_class.full_signature: static void appendUnicodeEscape(StringBuilder buf, char codeUnit)
focal_class.identifier: appendUnicodeEscape
focal_class.modifiers: static
focal_class.parameters: (StringBuilder buf, char codeUnit)
focal_class.return: void
focal_class.signature: void appendUnicodeEscape(StringBuilder buf, char codeUnit)
focal_class.class_method_signature: JavaPropertiesResource.unescapePropKey(String str)
focal_class.full_signature: static String unescapePropKey(String str)
focal_class.identifier: unescapePropKey
focal_class.modifiers: static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String unescapePropKey(String str)
focal_class.class_method_signature: JavaPropertiesResource.unescapePropValue(String str)
focal_class.full_signature: static String unescapePropValue(String str)
focal_class.identifier: unescapePropValue
focal_class.modifiers: static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String unescapePropValue(String str)
focal_class.class_method_signature: JavaPropertiesResource.unescape(String str)
focal_class.full_signature: private static String unescape(String str)
focal_class.identifier: unescape
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String unescape(String str)
focal_class.class_method_signature: JavaPropertiesResource.escapeOnlyUnicode(String str)
focal_class.full_signature: private static String escapeOnlyUnicode(String str)
focal_class.identifier: escapeOnlyUnicode
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String escapeOnlyUnicode(String str)
focal_class.class_method_signature: JavaPropertiesResource.unescapeOnlyUnicode(String str)
focal_class.full_signature: private static String unescapeOnlyUnicode(String str)
focal_class.identifier: unescapeOnlyUnicode
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String unescapeOnlyUnicode(String str)
focal_class.class_method_signature: JavaPropertiesResource.unescapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.full_signature: static String unescapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.identifier: unescapeMessagePattern
focal_class.modifiers: static
focal_class.parameters: (String inputStr, MessagePatternEscape msgPatEsc)
focal_class.return: String
focal_class.signature: String unescapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.class_method_signature: JavaPropertiesResource.escapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.full_signature: static String escapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.identifier: escapeMessagePattern
focal_class.modifiers: static
focal_class.parameters: (String inputStr, MessagePatternEscape msgPatEsc)
focal_class.return: String
focal_class.signature: String escapeMessagePattern(String inputStr, MessagePatternEscape msgPatEsc)
focal_class.class_method_signature: JavaPropertiesResource.hasArgs(MessagePattern msgPat)
focal_class.full_signature: static boolean hasArgs(MessagePattern msgPat)
focal_class.identifier: hasArgs
focal_class.modifiers: static
focal_class.parameters: (MessagePattern msgPat)
focal_class.return: boolean
focal_class.signature: boolean hasArgs(MessagePattern msgPat)
focal_class.class_method_signature: JavaPropertiesResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: merge
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.return: void
focal_class.signature: void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.class_method_signature: JavaPropertiesResource.getLeadingSpacesLength(String s)
focal_class.full_signature: private static int getLeadingSpacesLength(String s)
focal_class.identifier: getLeadingSpacesLength
focal_class.modifiers: private static
focal_class.parameters: (String s)
focal_class.return: int
focal_class.signature: int getLeadingSpacesLength(String s)
focal_class.class_method_signature: JavaPropertiesResource.stripLeadingSpaces(String s)
focal_class.full_signature: private static String stripLeadingSpaces(String s)
focal_class.identifier: stripLeadingSpaces
focal_class.modifiers: private static
focal_class.parameters: (String s)
focal_class.return: String
focal_class.signature: String stripLeadingSpaces(String s)
focal_class.class_method_signature: JavaPropertiesResource.isPropsWhiteSpaceChar(char c)
focal_class.full_signature: private static boolean isPropsWhiteSpaceChar(char c)
focal_class.identifier: isPropsWhiteSpaceChar
focal_class.modifiers: private static
focal_class.parameters: (char c)
focal_class.return: boolean
focal_class.signature: boolean isPropsWhiteSpaceChar(char c)
focal_class.superclass: extends ResourceFilter
focal_method.body: @Override
      public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
  
          Map<String, String> kvMap = Utils.createKeyValueMap(languageBundle.getResourceStrings());
  
          BufferedReader baseReader = new BufferedReader(new InputStreamReader(baseStream, getCharset()));
          PrintWriter outWriter = new PrintWriter(new OutputStreamWriter(outStream, getCharset()));
  
          BreakIterator brkItr = Utils.getWordBreakIterator(options);
  
          String line = null;
          StringBuilder logicalLineBuf = new StringBuilder();
          List<String> orgLines = new ArrayList<String>(8); // default size - up
                                                            // to 8 continuous
                                                            // lines
          do {
              // logical line that may define a single property, or empty line
              String logicalLine = null;
  
              line = baseReader.readLine();
  
              if (line == null) {
                  // End of the file - emit lines not yet processed.
                  if (!orgLines.isEmpty()) {
                      logicalLine = logicalLineBuf.toString();
                  }
              } else {
                  String normLine = stripLeadingSpaces(line);
  
                  if (orgLines.isEmpty()) {
                      // No continuation marker in the previous line
                      if (normLine.startsWith("#") || normLine.startsWith("!")) {
                          // Comment line - print the original line
                          outWriter.println(line);
                      } else if (isContinuationLine(normLine)) {
                          // Continue to the next line
                          logicalLineBuf.append(normLine, 0, normLine.length() - 1);
                          orgLines.add(line);
                      } else {
                          logicalLine = line;
                      }
                  } else {
                      // Continued from the previous line
                      if (normLine.endsWith("\\")) {
                          // continues to the next line
                          logicalLineBuf.append(normLine.substring(0, normLine.length() - 1));
                          orgLines.add(line); // preserve the original line
                      } else {
                          // terminating the current logical property line
                          logicalLineBuf.append(normLine);
                          orgLines.add(line);
                          logicalLine = logicalLineBuf.toString();
                      }
                  }
              }
  
              if (logicalLine != null) {
                  PropDef pd = PropDef.parseLine(logicalLine);
                  if (pd != null && kvMap.containsKey(pd.getKey())) {
                      // Preserve original leading spaces
                      String firstLine = orgLines.isEmpty() ? line : orgLines.get(0);
                      int len = getLeadingSpacesLength(firstLine);
                      if (len > 0) {
                          outWriter.print(firstLine.substring(0, len));
                      }
                      // Write the property key and value
                      String key = pd.getKey();
                      String value = escapeMessagePattern(kvMap.get(key), msgPatEsc);
                      PropDef modPd = new PropDef(key, value , pd.getSeparator(), null);
                      modPd.print(outWriter, brkItr, (enc == Encoding.UTF_8));
                  } else {
                      if (orgLines.isEmpty()) {
                          // Single line
                          outWriter.println(line);
                      } else {
                          // Multiple lines
                          for (String orgLine : orgLines) {
                              outWriter.println(orgLine);
                          }
                      }
                  }
  
                  // Clear continuation data
                  orgLines.clear();
                  logicalLineBuf.setLength(0);
              }
          } while (line != null);
  
          outWriter.flush();
      }
focal_method.class_method_signature: JavaPropertiesResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.full_signature: @Override public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.identifier: merge
focal_method.invocations: createKeyValueMap getResourceStrings getCharset getCharset getWordBreakIterator readLine isEmpty toString stripLeadingSpaces isEmpty startsWith startsWith println isContinuationLine append length add endsWith append substring length add append add toString parseLine containsKey getKey isEmpty get getLeadingSpacesLength print substring getKey escapeMessagePattern get getSeparator print isEmpty println println clear setLength flush
focal_method.modifiers: @Override public
focal_method.parameters: (InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.return: void
focal_method.signature: void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)