Posts

Showing posts from October, 2013

Convert complex objects into xml

 There are many utilities like Xstream which can provide this functionality, but i did not find them easy to use, so i am putting this small utility to help unmarshelling complex objects into readable format for easier debugging. Most of the tools rely on toString method overrides to unmarshall the objects and fail to unwrap the multilevel nesting.   This code also converts strings containing xml or html into character data so that output remains readable in XML editors. There are two helper flags, sample output is as follows. 1. SIMPLE_TYPED = false and CANONICAL_TYPED = false  <ArrayList><String><String>mystery</String><Boolean><Boolean>true</Boolean><ArrayList><String><String>one</String><String><String>two</String></ArrayList></ArrayList> 2. SIMPLE_TYPED = true and CANONICAL_TYPED = false  <ArrayList:java.util.ArrayList><String:java.lang.String><String:String