@Override
	public DocumentParseResultResource toResource(DocumentParseResult entity) {
		DocumentParseResultResource resource = new DocumentParseResultResource();
		for (DocumentParseResult.Line line : entity) {
			DocumentParseResultResource.Line resourceLine = new DocumentParseResultResource.Line();

			// Add any exceptions to the response for this line
			if (line.getExceptions() != null) {

				for (Exception e : line.getExceptions()) {

					if (e instanceof StreamDefinitionException) {
						StreamDefinitionException sde = (StreamDefinitionException) e;
						resourceLine.addError(new DocumentParseResultResource.Error(sde.getMessage(), sde.getPosition()));
					}
					else {
						resourceLine.addError(new DocumentParseResultResource.Error(e.getMessage()));
					}
				}
			}
			// If any modules were parsed, include that in the response
			if (line.getDescriptors() != null) {
				for (ModuleDescriptor md : Lists.reverse(line.getDescriptors())) {
					resourceLine.addDescriptor(new DocumentParseResultResource.ModuleDescriptor(
							md.getGroup(),
							md.getModuleLabel(),
							RESTModuleType.valueOf(md.getType().name()),
							md.getModuleName(),
							md.getSourceChannelName(),
							md.getSinkChannelName(),
							md.getParameters()));
				}
			}
			resource.addLine(resourceLine);
		}
		return resource;
	}
This class is responsible for creating a REST representation of a DocumentParseResult.

@author Eric Bottard
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/rest/DocumentParseResultResourceAssembler.java