Skip to main content
Close announcements banner

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.

You can produce these XML-serialized Java objects in the following ways:
  • 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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!