@Test public void testScore() { Component component = TextParsers.XML .parse("<score name=\"SupaHam\" objective=\"bar\" value=\"baz\">foo</score>"); TextComponent expected = TextComponent.of("").append(ScoreComponent.of("SupaHam", "bar", "baz").append(TextComponent.of("foo"))); Assert.assertEquals(expected, component); }
@Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComponent.Builder builder = TextComponent.builder().content(""); tag.apply(builder); tag.loop(builder); return builder.build(); } catch (Exception e) { throw new RuntimeException("Failed to parse: " + source, e); } }
XmlParser implements TextParser { @Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComponent.Builder builder = TextComponent.builder().content(""); tag.apply(builder); tag.loop(builder); return builder.build(); } catch (Exception e) { throw new RuntimeException("Failed to parse: " + source, e); } } }
XmlParser implements TextParser { @Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComponent.Builder builder = TextComponent.builder().content(""); tag.apply(builder); tag.loop(builder); return builder.build(); } catch (Exception e) { throw new RuntimeException("Failed to parse: " + source, e); } }  }
XmlParser implements TextParser { @Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComponent.Builder builder = TextComponent.builder().content(""); tag.apply(builder); tag.loop(builder); return builder.build(); } catch (Exception e) { throw new RuntimeException("Failed to parse: " + source, e); } }  @Override Component parse(String source); }
XmlParser implements TextParser { @Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComponent.Builder builder = TextComponent.builder().content(""); tag.apply(builder); tag.loop(builder); return builder.build(); } catch (Exception e) { throw new RuntimeException("Failed to parse: " + source, e); } }  @Override Component parse(String source);  }