MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / toXml

Method toXml

CodenameOne/src/com/codename1/mapping/Mappers.java:157–169  ·  view source on GitHub ↗
(Object instance)

Source from the content-addressed store, hash-verified

155
156 /// Serializes `instance` to XML.
157 public static String toXml(Object instance) {
158 if (instance == null) {
159 return "";
160 }
161 @SuppressWarnings("unchecked")
162 Mapper<Object> m = (Mapper<Object>) BY_NAME.get(instance.getClass().getName());
163 if (m == null) {
164 throw missing(instance.getClass());
165 }
166 Element root = new Element(m.xmlRootName());
167 m.writeXml(instance, root);
168 return new XMLWriter(true).toXML(root);
169 }
170
171 /// Inverse of `#toXml`. Parses the XML text and hands the resulting
172 /// Element to the registered mapper.

Callers 1

invokeStatic0Method · 0.80

Calls 7

missingMethod · 0.95
getMethod · 0.65
getNameMethod · 0.65
xmlRootNameMethod · 0.65
writeXmlMethod · 0.65
getClassMethod · 0.45
toXMLMethod · 0.45

Tested by

no test coverage detected