@Test public void testReadPreservesOrdering() throws Exception { text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><resources>\n" + "<!--test comment1-->\n" + "<string name=\"string1\" tmTextUnitId=\"10\">string1 @ content</string>\n" + "<!--plural1 @ comment-->\n" + "<plurals name=\"plural1\">\n" + "<item quantity=\"one\">One item</item>\n" + "<item quantity=\"other\">{more} items</item>\n" + "</plurals>\n" + "<!--test comment2-->\n" + "<string name=\"string2\" tmTextUnitId=\"11\">string2 @ content</string>\n" + "<!--plural2 @ comment-->\n" + "<plurals name=\"plural2\">\n" + "<item quantity=\"one\">One test</item>\n" + "<item quantity=\"two\">Two tests</item>\n" + "<item quantity=\"other\">{more} tests</item>\n" + "</plurals>\n" + "</resources>\n"; document = AndroidStringDocumentReader.fromText(text); AbstractAndroidString string; AndroidSingular singular; AndroidPlural plural; Iterator<AbstractAndroidString> stringsIterator = document.getStrings().iterator(); string = stringsIterator.next(); assertThat(string.isSingular()).isTrue(); singular = (AndroidSingular) string; assertThat(singular.getId()).isEqualTo(10); assertThat(singular.getName()).isEqualTo("string1"); assertThat(singular.getComment()).isEqualTo("test comment1"); assertThat(singular.getContent()).isEqualTo("string1 @ content"); string = stringsIterator.next(); assertThat(string.isPlural()).isTrue(); plural = (AndroidPlural) string; assertThat(plural.getName()).isEqualTo("plural1"); assertThat(plural.getComment()).isEqualTo("plural1 @ comment"); assertThat(plural.getItems()).hasSize(2); string = stringsIterator.next(); assertThat(string.isSingular()).isTrue(); singular = (AndroidSingular) string; assertThat(singular.getId()).isEqualTo(11); assertThat(singular.getName()).isEqualTo("string2"); assertThat(singular.getComment()).isEqualTo("test comment2"); assertThat(singular.getContent()).isEqualTo("string2 @ content"); string = stringsIterator.next(); assertThat(string.isPlural()).isTrue(); plural = (AndroidPlural) string; assertThat(plural.getName()).isEqualTo("plural2"); assertThat(plural.getComment()).isEqualTo("plural2 @ comment"); assertThat(plural.getItems()).hasSize(3); }
public static AndroidStringDocument fromText(String text) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new InputSource(new StringReader(Strings.nullToEmpty(text))))); }
AndroidStringDocumentReader { public static AndroidStringDocument fromText(String text) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new InputSource(new StringReader(Strings.nullToEmpty(text))))); } }
AndroidStringDocumentReader { public static AndroidStringDocument fromText(String text) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new InputSource(new StringReader(Strings.nullToEmpty(text))))); }  }
AndroidStringDocumentReader { public static AndroidStringDocument fromText(String text) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new InputSource(new StringReader(Strings.nullToEmpty(text))))); }  static AndroidStringDocument fromFile(String fileName); static AndroidStringDocument fromText(String text); }
AndroidStringDocumentReader { public static AndroidStringDocument fromText(String text) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new InputSource(new StringReader(Strings.nullToEmpty(text))))); }  static AndroidStringDocument fromFile(String fileName); static AndroidStringDocument fromText(String text);  }