@SuppressWarnings("unchecked") @Test public void testParseAnyGenericType() throws Exception { AnyGenericType xml = new AnyGenericType(); XmlPullParser parser = Xml.createParser(); parser.setInput(new StringReader(ANY_GENERIC_TYPE_XML)); XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); Xml.parseElement(parser, xml, namespaceDictionary, null); assertTrue(xml.attr instanceof String); Collection<GenericXml> repList = (Collection<GenericXml>) xml.elem.get("rep"); assertEquals(2, repList.size()); Collection<GenericXml> repValue = (Collection<GenericXml>) xml.elem.get("value"); assertEquals(1, repValue.size()); assertEquals( "@attr", ((Map.Entry) repList.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[0]) .getKey()); assertEquals( "param1", ((Map.Entry) repList.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[0]) .getValue()); assertEquals( "text()", ((Map.Entry) repList.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[1]) .getKey()); assertEquals( "rep1", ((Map.Entry) repList.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[1]) .getValue()); assertEquals( "@attr", ((Map.Entry) repList.toArray(new ArrayMap[] {})[1].entrySet().toArray(new Map.Entry[] {})[0]) .getKey()); assertEquals( "param2", ((Map.Entry) repList.toArray(new ArrayMap[] {})[1].entrySet().toArray(new Map.Entry[] {})[0]) .getValue()); assertEquals( "text()", ((Map.Entry) repList.toArray(new ArrayMap[] {})[1].entrySet().toArray(new Map.Entry[] {})[1]) .getKey()); assertEquals( "rep2", ((Map.Entry) repList.toArray(new ArrayMap[] {})[1].entrySet().toArray(new Map.Entry[] {})[1]) .getValue()); assertEquals( "text()", ((Map.Entry) repValue.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[0]) .getKey()); assertEquals( "content", ((Map.Entry) repValue.toArray(new ArrayMap[] {})[0].entrySet().toArray(new Map.Entry[] {})[0]) .getValue()); XmlSerializer serializer = Xml.createSerializer(); ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.setOutput(out, "UTF-8"); namespaceDictionary.serialize(serializer, "any", xml); assertEquals(ANY_GENERIC_TYPE_XML, out.toString()); }
@Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); }
GenericXml extends GenericData implements Cloneable { @Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); } }
GenericXml extends GenericData implements Cloneable { @Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); }  }
GenericXml extends GenericData implements Cloneable { @Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); }  @Override GenericXml clone(); @Override String toString(); @Override GenericXml set(String fieldName, Object value); }
GenericXml extends GenericData implements Cloneable { @Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); }  @Override GenericXml clone(); @Override String toString(); @Override GenericXml set(String fieldName, Object value); public String name; public XmlNamespaceDictionary namespaceDictionary; }