com.xmlcalabash.util.Reporter Maven / Gradle / Ivy
The newest version!
package com.xmlcalabash.util;
import com.xmlcalabash.model.Step;
import com.xmlcalabash.model.Input;
import com.xmlcalabash.model.Output;
import com.xmlcalabash.model.Parameter;
import com.xmlcalabash.model.Option;
import com.xmlcalabash.model.Variable;
import com.xmlcalabash.model.Binding;
import com.xmlcalabash.model.Serialization;
import com.xmlcalabash.model.DocumentBinding;
import com.xmlcalabash.model.PipeBinding;
import com.xmlcalabash.model.PipeNameBinding;
import com.xmlcalabash.model.DataBinding;
import com.xmlcalabash.core.XProcConstants;
import com.xmlcalabash.core.XProcRuntime;
import java.io.PrintStream;
import net.sf.saxon.s9api.QName;
/**
* Created by IntelliJ IDEA.
* User: ndw
* Date: Dec 5, 2008
* Time: 8:20:50 AM
* To change this template use File | Settings | File Templates.
*/
public class Reporter {
private XProcRuntime runtime;
private PrintStream pr;
private boolean xmlReport;
public Reporter(XProcRuntime runtime, PrintStream pr) {
this.runtime = runtime;
this.pr = pr;
xmlReport = true;
}
public void report(Step step) {
if (xmlReport) {
pr.println("");
pr.println("" + runtime.getXProcVersion() + " ");
pr.println("" + runtime.getProductName() + " ");
pr.println("" + runtime.getProductVersion() + " ");
pr.println("" + runtime.getEpisode() + " ");
xmlReport(step);
pr.println(" ");
}
}
private void xmlReport(Step step) {
pr.print("");
for (Input input : step.inputs()) {
xmlReport(input);
}
for (Output output : step.outputs()) {
xmlReport(output);
}
for (Parameter param : step.parameters()) {
xmlReport(param);
}
for (Option option : step.options()) {
xmlReport(option);
}
for (Variable var : step.getVariables()) {
xmlReport(var);
}
for (Step substep : step.subpipeline()) {
xmlReport(substep);
}
pr.println(" ");
}
private void xmlReport(Input input) {
if (!input.getPort().startsWith("|")) {
pr.print(" ");
for (Binding binding : input.getBinding()) {
xmlReport(binding);
}
pr.println(" ");
}
}
private void xmlReport(Output output) {
if (!output.getPort().endsWith("|")) {
pr.println(" ");
}
}
private void xmlReport(Binding binding) {
switch (binding.getBindingType()) {
case Binding.NO_BINDING:
pr.println(" ");
break;
case Binding.PIPE_NAME_BINDING:
xmlReport((PipeNameBinding) binding);
break;
case Binding.INLINE_BINDING:
pr.println(" ");
break;
case Binding.DOCUMENT_BINDING:
case Binding.STDIO_BINDING:
xmlReport((DocumentBinding) binding);
break;
case Binding.DATA_BINDING:
xmlReport((DataBinding) binding);
break;
case Binding.PIPE_BINDING:
pr.println(" ");
break;
case Binding.EMPTY_BINDING:
pr.println(" ");
break;
case Binding.ERROR_BINDING:
pr.println(" ");
break;
default:
pr.println(" ");
}
}
private void xmlReport(PipeNameBinding binding) {
pr.println(" ");
}
private void xmlReport(DocumentBinding binding) {
String href = binding.getHref();
if (href == null) {
pr.println(" ");
} else {
pr.println(" ");
}
}
private void xmlReport(DataBinding binding) {
String href = binding.getHref();
QName wrapper = binding.getWrapper();
pr.println(" ");
}
private void xmlReport(Parameter param) {
String select = param.getSelect();
pr.print(" ");
}
private void xmlReport(Option option) {
String type = option.getType();
boolean req = option.getRequired();
String select = option.getSelect();
pr.print(" ");
}
private void xmlReport(Variable var) {
String select = var.getSelect();
pr.print(" ");
}
}