(Object instance)
| 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. |
no test coverage detected