protected void patchEnvironment(Environment env) { // See if there's exactly one "ordinary" input int count = 0; Input defin = null; boolean foundPrimary = false; for (Input input : inputs) { if (!input.getPort().startsWith("|") && !input.getParameterInput()) { count++; foundPrimary |= input.getPrimary(); if (defin == null || input.getPrimary()) { defin = input; } } } if (count == 1 || foundPrimary) { env.setDefaultReadablePort(defin); } } }
public XInput(XProcRuntime runtime, Input input) { this.runtime = runtime; node = input.getNode(); port = input.getPort(); sequenceOk = input.getSequence(); isParameters = input.getParameterInput(); readers = new Vector<ReadablePipe> (); }
@Override protected void augmentIO() { if (getInput("#iteration-source") == null) { Input isource = new Input(runtime, node); isource.setPort("#iteration-source"); isource.setPrimary(true); isource.setSequence(true); addInput(isource); } super.augmentIO(); }
declInputs.put(input.getPort(), input); if (input == null) { logger.trace(MessageFormatter.nodeMessage(node, "Added " + portName + " input to " + getName())); input = new Input(runtime, node); input.setPort(portName); input.setParameterInput(dinput.getParameterInput()); if (dinput.getPrimarySet()) { input.setPrimary(dinput.getPrimary()); input.setSequence(dinput.getSequence()); input.setPosition(++position); addInput(input); } else { input.setParameterInput(dinput.getParameterInput()); input.setPrimary(dinput.getPrimary()); input.setSequence(dinput.getSequence());
Input pInput = new Input(runtime, input.getNode()); pInput.setPort(input.getPort()); pInput.setPrimary(input.getPrimary()); pInput.setSequence(input.getSequence()); pInput.setParameterInput(input.getParameterInput()); pipeline.addInput(pInput); PipeNameBinding pnb = new PipeNameBinding(runtime, input.getNode()); pnb.setStep(wrapper); pnb.setPort(pInput.getPort()); input.addBinding(pnb); pOutput.setSequence(output.getSequence()); Input pInput = new Input(runtime, output.getNode()); pInput.setPort("|" + output.getPort()); pInput.setSequence(output.getSequence()); pipeline.addInput(pInput); pnb.setStep(step.getName()); pnb.setPort(output.getPort()); pInput.addBinding(pnb);
protected void augmentIO() { if (getInput("#xpath-context") == null) { Input isource = new Input(runtime, node); isource.setPort("#xpath-context"); addInput(isource); } // Assume that everything will be OK when we validate... if (subpipeline.size() > 0) { Step step = subpipeline.get(0); for (Input input : step.inputs()) { Input cinput = new Input(runtime, step.getNode()); cinput.setPort(input.getPort()); cinput.setPrimary(input.getPrimary()); cinput.setSequence(input.getSequence()); addInput(cinput); } for (Output output : step.outputs()) { Output coutput = new Output(runtime, step.getNode()); coutput.setPort(output.getPort()); coutput.setPrimary(output.getPrimary()); coutput.setSequence(output.getSequence()); addOutput(coutput); } } super.augmentIO(); }
if (input.getPrimarySet() && input.getPrimary()) { if (!allowPrimary) { throw XProcException.staticError(8, node, "The \"primary\" attribute is not allowed in this context."); if (input.getParameterInput()) { primaryParamInputCount++; if (primaryParamInputCount > 1) { input.setPosition(pos++); if (step.getInput(input.getPort()) != null || step.getOutput(input.getPort()) != null) { runtime.error(null, node, "Duplicate port name: " + input.getPort(), XProcConstants.staticError(11)); } else { step.addInput(input); Input input = new Input(runtime, output.getNode()); input.setPort("|" + output.getPort()); for (Binding binding : output.getBinding()) { input.addBinding(binding); input.setPrimary(output.getPrimary()); input.setSequence(output.getSequence()); step.addInput(input); Input maybePrimaryInput = null; for (Input input : step.inputs()) { if (!input.getParameterInput() && !input.getPort().startsWith("|")) { inputCount++; maybePrimaryInput = input;
logger.trace(MessageFormatter.nodeMessage(node, "Check bindings for " + input.getPort() + " on " + getName())); if (input.getBinding().size() == 0) { if (input.getParameterInput()) { if (input.getPrimary()) { int count = 0; for (Input pinput : pipeline.inputs()) { if (pinput.getParameterInput()) { count++; if (paramsin == null || pinput.getPrimary()) { paramsin = pinput; if (paramsin == null || (!paramsin.getPrimary() && count > 1)) { if (params.size() > 0) { input.addBinding(binding); } else { valid = false; error("Parameter input " + input.getPort() + " unbound on " + getType() + " step named " + getName() + " and no default binding available.", XProcConstants.staticError(55)); binding.setPort(paramsin.getPort()); input.addBinding(binding); input.addBinding(binding); if (input.getPort().startsWith("|")) { if (subpipeline.size() > 0) {
Input input = new Input(runtime, node); input.setPort(port); input.setSequence(sequence); input.setPrimary(primary); input.setParameterInput(); input.setSequence(true); input.setDebugReader(node.getAttributeValue(new QName(XProcConstants.NS_CALABASH_EX, "debug-reader")) != null); input.setDebugWriter(node.getAttributeValue(new QName(XProcConstants.NS_CALABASH_EX, "debug-writer")) != null); input.setSelect(select); Binding binding = readBinding(parent, snode); if (binding != null) { input.addBinding(binding);
Input input = new Input(runtime, node); input.setPort("source"); input.setPrimary(true); input.setSequence(false); step.addInput(input); input = new Input(runtime, node); input.setPort("parameters"); input.setParameterInput(true); input.setPrimary(true); input.setSequence(true); step.addInput(input); if (input.getBinding().size() != 0) { runtime.error(null,input.getNode(),"Input bindings are not allowed on an atomic step",XProcConstants.staticError(42)); if (!input.getPort().startsWith("|")) { for (Binding binding : input.getBinding()) { if (binding.getBindingType() == Binding.PIPE_NAME_BINDING) { runtime.error(null,input.getNode(),"Default input bindings cannot use p:pipe",XProcConstants.staticError(44));
Input input = getInput("|" + output.getPort()); if (input == null) { input = new Input(runtime, output.getNode()); input.setPort("|" + output.getPort()); input.setSequence(true); // the other half will check input.setPrimary(output.getPrimary()); addInput(input); if (!input.getPort().startsWith("|") && !input.getPort().startsWith("#")) { Output output = new Output(runtime, input.getNode()); output.setPort(input.getPort() + "|"); output.setSequence(true); // the other half will check output.setPrimary(input.getPrimary()); addOutput(output);
protected void patchEnvironment(Environment env) { if (atomic) { //nop; } else { // See if there's exactly one "ordinary" input int count = 0; Input defin = null; boolean foundPrimary = false; for (Input input : inputs) { if (!input.getPort().startsWith("|") && !input.getParameterInput()) { count++; foundPrimary |= input.getPrimary(); if (!input.getPrimary() && input.getPrimarySet()) { // nop; if the port is explicitly marked primary=false, it can't count } else { if (defin == null || input.getPrimary()) { defin = input; } } } } if (count == 1 || foundPrimary) { env.setDefaultReadablePort(defin); } } }
if (input.getBinding().size() == 0) { Port port = null; if ("#xpath-context".equals(input.getPort())) { if (this instanceof When) { if ("#iteration-source".equals(input.getPort()) || "#viewport-source".equals(input.getPort())) { port = env.getParent().getDefaultReadablePort(); Step decl = declaration; for (Input dinput : decl.inputs()) { if (dinput.getPort().equals(input.getPort())) { declBinding = dinput.getBinding(); if (input.getPrimary() && input.getPort().startsWith("|") && subpipeline.size() > 0) { error("Output port '" + input.getPort().substring(1) + "' on " + getStep() + " unbound", XProcConstants.staticError(5)); valid = false; if (input.getPort().startsWith("|") && parent != null) { String oport = input.getPort().substring(1); output = getOutput(oport); input.addBinding(binding); if (declBinding != null) { for (Binding binding : declBinding) { input.addBinding(binding);
public PipelineConfiguration(XProcRuntime runtime, XPipeline xpipeline, Calendar expires) { this.runtime = runtime; this.pipeline = xpipeline; this.expires = expires; DeclareStep pipeline = xpipeline.getDeclareStep(); // Figure out the default input port for (String port : xpipeline.getInputs()) { inputPorts.add(port); com.xmlcalabash.model.Input input = pipeline.getInput(port); if (!input.getParameterInput() && input.getPrimary()) { definput = port; } } // Figure out the default output port for (String port : xpipeline.getOutputs()) { outputPorts.add(port); com.xmlcalabash.model.Output output = pipeline.getOutput(port); if (output.getPrimary()) { defoutput = port; } } }
protected void instantiateReaders(Step step) { for (Input input : step.inputs()) { String port = input.getPort(); if (!port.startsWith("|")) { Vector<ReadablePipe> readers = null; if (inputs.containsKey(port)) { readers = inputs.get(port); } else { readers = new Vector<ReadablePipe> (); inputs.put(port, readers); } for (Binding binding : input.getBinding()) { ReadablePipe pipe = getPipeFromBinding(binding); pipe.canReadSequence(input.getSequence()); if (input.getSelect() != null) { logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " selects from " + pipe + " for " + port)); pipe = new XSelect(runtime, this, pipe, input.getSelect(), input.getNode()); } readers.add(pipe); logger.trace(MessageFormatter.nodeMessage(step.getNode(), step.getName() + " reads from " + pipe + " for " + port)); } XInput xinput = new XInput(runtime, input); addInput(xinput); } } }
if (!input.getParameterInput()) { builder.withPort(XProcPortInfo.newInputPort( input.getPort(), input.getSequence(), input.getPrimary())); } else { builder.withPort(XProcPortInfo.newParameterPort( input.getPort(), input.getPrimary()));
boolean primaryParamPort = false; for (Input input : step.inputs()) { if (input.getParameterInput()) { primaryParamPort = primaryParamPort | input.getPrimary(); paramPorts.add(input.getPort()); loopdone = loopdone && (input.getPosition() <= position); if (input.getPosition() == position) { for (ReadablePipe source : inputs.get(port)) { while (source.moreDocuments()) {
private void xmlReport(Input input) { if (!input.getPort().startsWith("|")) { pr.print(" <input port='" + input.getPort() + "'"); if (input.getParameterInput()) { pr.print(" kind='parameter'"); } if (input.getSelect() != null) { pr.print(" select='" + input.getSelect() + "'"); } pr.println(">"); for (Binding binding : input.getBinding()) { xmlReport(binding); } pr.println(" </input>"); } }