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 testWrite() throws IOException, ResourceFilterException{
          File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xml");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile)) {
              res.write(os, WRITE_BUNDLE, null);
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_WRITE_FILE, tempFile, 1));
          }
      }
test_case.class_method_signature: AndroidStringsResourceTest.testWrite()
test_case.full_signature: @Test public void testWrite()
test_case.identifier: testWrite
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit write flush assertTrue compareFiles
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWrite()
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 write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options)
              throws IOException, ResourceFilterException {
  
          List<ResourceString> resStrings = languageBundle.getSortedResourceStrings();
  
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder docBuilder = null;
          try {
              docBuilder = docFactory.newDocumentBuilder();
          } catch (ParserConfigurationException e) {
              // runtime problem
              throw new RuntimeException(e);
          }
  
          // root elements
          Document doc = docBuilder.newDocument();
  
          // creating <resources></resources>
          Element rootElement = doc.createElement(RESOURCES_STRING);
  
          for (ResourceString resString : resStrings) {
              String value = resString.getValue();
              Map<String, String> plural_categories = null;
  
              if (value.startsWith("[") && value.endsWith("]")) {
                  // creating <string-array name="$NAME">
                  Element child = doc.createElement(STR_ARRAY);
                  Attr attr = doc.createAttribute(NAME_STRING);
                  attr.setValue(resString.getKey());
                  child.setAttributeNode(attr);
  
                  int startIndex = 0;
                  int endIndex = -1;
  
                  while (endIndex < value.length() - 1) {
                      endIndex = value.indexOf(',', startIndex);
  
                      if (endIndex == -1) {
                          endIndex = value.length() - 1;
                      }
  
                      String itemValue = value.substring(startIndex + 1, endIndex);
  
                      Element arrayChild = doc.createElement("item");
                      arrayChild.setTextContent(itemValue);
                      child.appendChild(arrayChild);
  
                      startIndex = endIndex + 1;
                  }
                  rootElement.appendChild(child);
              } else if (!(plural_categories = getPluralCategories(value)).isEmpty()) {
                  Element child = doc.createElement(PLURALS_STRING);
                  Attr attr = doc.createAttribute(NAME_STRING);
                  attr.setValue(resString.getKey());
                  child.setAttributeNode(attr);
  
                  if (!resString.getNotes().isEmpty()) {
                      List<String> comments = resString.getNotes();
                      for (String comment : comments) {
                          Comment d_comment = doc.createComment(comment);
                          child.appendChild(d_comment);
                      }
                  }
  
                  /**
                   * Append plural category items Show the items in predefined
                   * order
                   */
                  for (String pKey : Constants.PLURAL_CATEGORIES) {
                      if (plural_categories.containsKey(pKey)) {
                          String pValue = plural_categories.get(pKey);
                          Element item = doc.createElement(ITEM_STRING);
                          Attr pAttr = doc.createAttribute(QUANTITY_STRING);
                          pAttr.setValue(pKey);
                          item.setAttributeNode(pAttr);
                          item.setTextContent(pValue);
                          child.appendChild(item);
                      }
                  }
  
                  rootElement.appendChild(child);
              } else {
                  // creating <string name=$NAME>VALUE</string>
                  Element child = doc.createElement(STR_STRING);
                  Attr attr = doc.createAttribute(NAME_STRING);
                  attr.setValue(resString.getKey());
                  child.setAttributeNode(attr);
                  child.setTextContent(value);
                  rootElement.appendChild(child);
              }
          }
          doc.appendChild(rootElement);
  
          TransformerFactory transformerFactory = TransformerFactory.newInstance();
          Transformer transformer = null;
          try {
              transformer = transformerFactory.newTransformer();
          } catch (TransformerConfigurationException e) {
              // runtime problem
              throw new ResourceFilterException(e);
          }
  
          // to add the tab spacing to files
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
  
          transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
  
          DOMSource source = new DOMSource(doc);
          StreamResult result = new StreamResult(outStream);
  
          // write the file
          try {
              transformer.transform(source, result);
          } catch (TransformerException e) {
              // runtime problem?
              throw new ResourceFilterException(e);
          }
      }
focal_method.class_method_signature: AndroidStringsResource.write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options)
focal_method.full_signature: @Override public void write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options)
focal_method.identifier: write
focal_method.invocations: getSortedResourceStrings newInstance newDocumentBuilder newDocument createElement getValue startsWith endsWith createElement createAttribute setValue getKey setAttributeNode length indexOf length substring createElement setTextContent appendChild appendChild isEmpty getPluralCategories createElement createAttribute setValue getKey setAttributeNode isEmpty getNotes getNotes createComment appendChild containsKey get createElement createAttribute setValue setAttributeNode setTextContent appendChild appendChild createElement createAttribute setValue getKey setAttributeNode setTextContent appendChild appendChild newInstance newTransformer setOutputProperty setOutputProperty setOutputProperty transform
focal_method.modifiers: @Override public
focal_method.parameters: (OutputStream outStream, LanguageBundle languageBundle, FilterOptions options)
focal_method.return: void
focal_method.signature: void write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options)