Working with Java sample data objects
You can create sample documents from Java object instances so that you can test maps that use Java objects as input. These documents are stored as XML as defined in the XStream project's default serialization. Well, almost the default serialization, the only difference is that it specifies the ID_REFERENCES option so that the object graph is preserved in the case of inter-object references.
-
As an Output - If you have a map that writes to the desired Java object, this is the easiest way to go. Simply test run the map in the designer to a sample output document. Do this by selecting the Test Run to Sample Document in either the Test Run button's menu or the Test menu on the main menu bar. This will produce the XML document and associate it with the output structure of the map.
-
Using your own Standalone Code - The following snippet of code can be used to produce the sample document; this depends on the some XStream classes, but has no other dependency.
HierarchicalStreamWriter javaWriter; StringWriter sw = new StringWriter(); javaWriter = new PrettyPrintWriter(sw); XStream xsShow = new XStream(null); xsShow.setMode(XStream.ID_REFERENCES); xsShow.marshal(yourObject, javaWriter); javaWriter.flush();
You put the string into a file and then copy the file into the Sample Data folder corresponding to your Java structure in the workspace.