test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/xml/input.xml")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/xml/input.xml");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/xml/write-output.xml")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/xml/write-output.xml");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/xml/merge-input-1.xml")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/xml/merge-input-1.xml");
test_class.type: File
test_class.var_name: MERGE_INPUT_1_FILE
test_class.declarator: MERGE_INPUT_2_FILE = new File("src/test/resource/resfilter/xml/merge-input-2.xml")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_2_FILE = new File("src/test/resource/resfilter/xml/merge-input-2.xml");
test_class.type: File
test_class.var_name: MERGE_INPUT_2_FILE
test_class.declarator: EXPECTED_MERGE_1_FILE = new File("src/test/resource/resfilter/xml/merge-output-1.xml")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_MERGE_1_FILE = new File("src/test/resource/resfilter/xml/merge-output-1.xml");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_1_FILE
test_class.declarator: EXPECTED_MERGE_2_FILE = new File("src/test/resource/resfilter/xml/merge-output-2.xml")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_MERGE_2_FILE = new File("src/test/resource/resfilter/xml/merge-output-2.xml");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_2_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: MERGE_BUNDLE
test_class.modifier: private static
test_class.original_string: private static LanguageBundle MERGE_BUNDLE;
test_class.type: LanguageBundle
test_class.var_name: MERGE_BUNDLE
test_class.declarator: res = new AndroidStringsResource()
test_class.modifier: private static final
test_class.original_string: private static final AndroidStringsResource res = new AndroidStringsResource();
test_class.type: AndroidStringsResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/AndroidStringsResourceTest.java
test_class.identifier: AndroidStringsResourceTest
test_case.body: @Test
      public void testMerge() throws IOException, ResourceFilterException {
          File tempFile;
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xml");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile);
                  InputStream is = new FileInputStream(MERGE_INPUT_1_FILE)) {
              res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.ENGLISH));
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_1_FILE, tempFile));
          }
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xml");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile);
                  InputStream is = new FileInputStream(MERGE_INPUT_2_FILE)) {
              res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.JAPANESE));
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_2_FILE, tempFile));
          }
      }
test_case.class_method_signature: AndroidStringsResourceTest.testMerge()
test_case.full_signature: @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit merge flush assertTrue compareFiles 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: CHAR_SET = "UTF-8"
focal_class.modifier: private static final
focal_class.original_string: private static final String CHAR_SET = "UTF-8";
focal_class.type: String
focal_class.var_name: CHAR_SET
focal_class.declarator: RESOURCES_STRING = "resources"
focal_class.modifier: private static final
focal_class.original_string: private static final String RESOURCES_STRING = "resources";
focal_class.type: String
focal_class.var_name: RESOURCES_STRING
focal_class.declarator: NAME_STRING = "name"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAME_STRING = "name";
focal_class.type: String
focal_class.var_name: NAME_STRING
focal_class.declarator: STR_STRING = "string"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_STRING = "string";
focal_class.type: String
focal_class.var_name: STR_STRING
focal_class.declarator: STR_ARRAY = "string-array"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_ARRAY = "string-array";
focal_class.type: String
focal_class.var_name: STR_ARRAY
focal_class.declarator: PLURAL_STRING = "plural"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLURAL_STRING = "plural";
focal_class.type: String
focal_class.var_name: PLURAL_STRING
focal_class.declarator: PLURALS_STRING = "plurals"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLURALS_STRING = "plurals";
focal_class.type: String
focal_class.var_name: PLURALS_STRING
focal_class.declarator: QUANTITY_STRING = "quantity"
focal_class.modifier: private static final
focal_class.original_string: private static final String QUANTITY_STRING = "quantity";
focal_class.type: String
focal_class.var_name: QUANTITY_STRING
focal_class.declarator: ITEM_STRING = "item"
focal_class.modifier: private static final
focal_class.original_string: private static final String ITEM_STRING = "item";
focal_class.type: String
focal_class.var_name: ITEM_STRING
focal_class.declarator: STR_ARRAY_OPEN_TAG_PTRN = "^(\\s*<string-array\\s*name=\".*\">).*"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_ARRAY_OPEN_TAG_PTRN = "^(\\s*<string-array\\s*name=\".*\">).*";
focal_class.type: String
focal_class.var_name: STR_ARRAY_OPEN_TAG_PTRN
focal_class.declarator: STR_ARRAY_CLOSE_TAG_PTRN = ".*(\\s*</string-array\\s*>)$"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_ARRAY_CLOSE_TAG_PTRN = ".*(\\s*</string-array\\s*>)$";
focal_class.type: String
focal_class.var_name: STR_ARRAY_CLOSE_TAG_PTRN
focal_class.declarator: STR_OPEN_TAG_PTRN = "^(\\s*<string\\s*name=\".*\">).*"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_OPEN_TAG_PTRN = "^(\\s*<string\\s*name=\".*\">).*";
focal_class.type: String
focal_class.var_name: STR_OPEN_TAG_PTRN
focal_class.declarator: STR_CLOSE_TAG_PTRN = ".*(\\s*</string\\s*>)$"
focal_class.modifier: private static final
focal_class.original_string: private static final String STR_CLOSE_TAG_PTRN = ".*(\\s*</string\\s*>)$";
focal_class.type: String
focal_class.var_name: STR_CLOSE_TAG_PTRN
focal_class.declarator: PLURALS_OPEN_TAG_PTRN = "^(\\s*<plurals\\s*name=\".*\">).*"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLURALS_OPEN_TAG_PTRN = "^(\\s*<plurals\\s*name=\".*\">).*";
focal_class.type: String
focal_class.var_name: PLURALS_OPEN_TAG_PTRN
focal_class.declarator: PLURALS_CLOSE_TAG_PTRN = ".*(\\s*</plurals\\s*>)$"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLURALS_CLOSE_TAG_PTRN = ".*(\\s*</plurals\\s*>)$";
focal_class.type: String
focal_class.var_name: PLURALS_CLOSE_TAG_PTRN
focal_class.declarator: PLURAL_ENTIRY_PTRN = "{0}, plural, {1}"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLURAL_ENTIRY_PTRN = "{0}, plural, {1}";
focal_class.type: String
focal_class.var_name: PLURAL_ENTIRY_PTRN
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/AndroidStringsResource.java
focal_class.identifier: AndroidStringsResource
focal_class.class_method_signature: AndroidStringsResource.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: AndroidStringsResource.collectResourceStrings(NodeList nodeList, int startSeqNum, Collection<ResourceString> resStrings)
focal_class.full_signature: private int collectResourceStrings(NodeList nodeList, int startSeqNum, Collection<ResourceString> resStrings)
focal_class.identifier: collectResourceStrings
focal_class.modifiers: private
focal_class.parameters: (NodeList nodeList, int startSeqNum, Collection<ResourceString> resStrings)
focal_class.return: int
focal_class.signature: int collectResourceStrings(NodeList nodeList, int startSeqNum, Collection<ResourceString> resStrings)
focal_class.class_method_signature: AndroidStringsResource.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: AndroidStringsResource.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: AndroidStringsResource.getTabStr(String str)
focal_class.full_signature: static String getTabStr(String str)
focal_class.identifier: getTabStr
focal_class.modifiers: static
focal_class.parameters: (String str)
focal_class.return: String
focal_class.signature: String getTabStr(String str)
focal_class.class_method_signature: AndroidStringsResource.getSpacesSize(String whitespace)
focal_class.full_signature: static int getSpacesSize(String whitespace)
focal_class.identifier: getSpacesSize
focal_class.modifiers: static
focal_class.parameters: (String whitespace)
focal_class.return: int
focal_class.signature: int getSpacesSize(String whitespace)
focal_class.class_method_signature: AndroidStringsResource.formatMessage(String openingTag, String message, String closingTag, String whitespace,
              BreakIterator brkItr)
focal_class.full_signature: static String formatMessage(String openingTag, String message, String closingTag, String whitespace,
              BreakIterator brkItr)
focal_class.identifier: formatMessage
focal_class.modifiers: static
focal_class.parameters: (String openingTag, String message, String closingTag, String whitespace,
              BreakIterator brkItr)
focal_class.return: String
focal_class.signature: String formatMessage(String openingTag, String message, String closingTag, String whitespace,
              BreakIterator brkItr)
focal_class.class_method_signature: AndroidStringsResource.containPluralString(String inputString)
focal_class.full_signature: static boolean containPluralString(String inputString)
focal_class.identifier: containPluralString
focal_class.modifiers: static
focal_class.parameters: (String inputString)
focal_class.return: boolean
focal_class.signature: boolean containPluralString(String inputString)
focal_class.class_method_signature: AndroidStringsResource.getPluralString(String inputString)
focal_class.full_signature: static String getPluralString(String inputString)
focal_class.identifier: getPluralString
focal_class.modifiers: static
focal_class.parameters: (String inputString)
focal_class.return: String
focal_class.signature: String getPluralString(String inputString)
focal_class.class_method_signature: AndroidStringsResource.getPluralCategories(String inputString)
focal_class.full_signature: static Map<String, String> getPluralCategories(String inputString)
focal_class.identifier: getPluralCategories
focal_class.modifiers: static
focal_class.parameters: (String inputString)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getPluralCategories(String inputString)
focal_class.superclass: extends ResourceFilter
focal_method.body: @Override
      public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
  
          // put res data into a map for easier searching
          Map<String, String> kvMap = Utils.createKeyValueMap(languageBundle.getResourceStrings());
          BreakIterator brkItr = Utils.getWordBreakIterator(options);
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(baseStream, CHAR_SET));
          BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, CHAR_SET));
  
          String line;
          while ((line = reader.readLine()) != null) {
              if (line.matches(STR_ARRAY_OPEN_TAG_PTRN)) {
                  // handle <string-array name="name"> tag
                  String openingTag = line.substring(0, line.indexOf('>') + 1);
                  String key = openingTag.substring(openingTag.indexOf('"') + 1, openingTag.lastIndexOf('"'));
  
                  if (!kvMap.containsKey(key)) {
                      writer.write(line);
                      writer.newLine();
                      continue;
                  }
  
                  String value = kvMap.get(key);
  
                  if (!(value.startsWith("[") && value.endsWith("]"))) {
                      writer.write(line);
                      writer.newLine();
                      continue;
                  }
  
                  String tabSubString = openingTag.substring(0, openingTag.indexOf('<'));
                  String spaces = tabSubString + getTabStr(tabSubString);
                  writer.write(openingTag);
                  writer.newLine();
  
                  String[] items = value.substring(1, value.length() - 1).split(",");
  
                  for (int i = 0; i < items.length; i++) {
                      writer.write(formatMessage("<item>", items[i].trim(), "</item>", spaces, brkItr));
                  }
  
                  writer.write(openingTag.substring(0, openingTag.indexOf('<')));
  
                  writer.write("</string-array>");
                  writer.newLine();
  
                  while ((line = reader.readLine()) != null && !line.matches(STR_ARRAY_CLOSE_TAG_PTRN))
                      ;
              } else if (line.matches(STR_OPEN_TAG_PTRN)) {
                  // handle <string name="name"> tag
                  String openingTag = line.substring(0, line.indexOf('>') + 1);
                  String key = openingTag.substring(openingTag.indexOf('"') + 1, openingTag.lastIndexOf('"'));
  
                  if (!kvMap.containsKey(key)) {
                      writer.write(line);
                      writer.newLine();
                      continue;
                  }
  
                  String value = kvMap.get(key);
  
                  String spaces = openingTag.substring(0, openingTag.indexOf('<'));
  
                  writer.write(formatMessage(openingTag.trim(), value, "</string>", spaces, brkItr));
  
                  while (line != null && !line.matches(STR_CLOSE_TAG_PTRN)) {
                      line = reader.readLine();
                  }
              } else if (line.matches(PLURALS_OPEN_TAG_PTRN)) {
                  // handle <plurals name="name"> tag
                  String openingTag = line.substring(0, line.indexOf('>') + 1);
                  String key = openingTag.substring(openingTag.indexOf('"') + 1, openingTag.lastIndexOf('"'));
  
                  if (!kvMap.containsKey(key)) {
                      writer.write(line);
                      writer.newLine();
                      continue;
                  }
  
                  String value = kvMap.get(key);
  
                  Map<String, String> plural_categories = null;
  
                  if ((plural_categories = getPluralCategories(value)).isEmpty()) {
                      writer.write(line);
                      writer.newLine();
                      continue;
                  }
  
                  String tabSubString = openingTag.substring(0, openingTag.indexOf('<'));
                  String spaces = tabSubString + getTabStr(tabSubString);
                  writer.write(openingTag);
                  writer.newLine();
  
                  for (String pKey : Constants.PLURAL_CATEGORIES) {
                      if (plural_categories.containsKey(pKey)) {
                          String pValue = plural_categories.get(pKey);
                          // <item quantity="one">
                          String itemStr = "<item quantity=\"" + pKey + "\">";
                          writer.write(formatMessage(itemStr, pValue.trim(), "</item>", spaces, brkItr));
                      }
                  }
                  writer.write(openingTag.substring(0, openingTag.indexOf('<')));
  
                  writer.write("</plurals>");
                  writer.newLine();
  
                  while (line != null && !line.matches(PLURALS_CLOSE_TAG_PTRN)) {
                      line = reader.readLine();
                  }
              } else {
                  writer.write(line);
                  writer.newLine();
              }
          }
          writer.flush();
      }
focal_method.class_method_signature: AndroidStringsResource.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 getWordBreakIterator readLine matches substring indexOf substring indexOf lastIndexOf containsKey write newLine get startsWith endsWith write newLine substring indexOf getTabStr write newLine split substring length write formatMessage trim write substring indexOf write newLine readLine matches matches substring indexOf substring indexOf lastIndexOf containsKey write newLine get substring indexOf write formatMessage trim matches readLine matches substring indexOf substring indexOf lastIndexOf containsKey write newLine get isEmpty getPluralCategories write newLine substring indexOf getTabStr write newLine containsKey get write formatMessage trim write substring indexOf write newLine matches readLine write newLine 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)