//
// FlowStepVarDef.java - If not defined, or null, set a variable
//

package nyangau.jmsadapter;

//...simports:0:
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import javax.jms.JMSException;
//...e

public class FlowStepVarDef extends FlowStep
  {
  protected String var;
  protected String value;
//...sFlowStepVarDef:2:
public FlowStepVarDef(Node eStep)
  throws FlowProcessorException
  {
  super(eStep);
  NamedNodeMap nnmStep = eStep.getAttributes();
  Node aVar = nnmStep.getNamedItem("var");
  var = ( aVar != null ) ? aVar.getNodeValue() : "v0";
  Node aValue = nnmStep.getNamedItem("value");
  if ( aValue == null )
    throw new FlowProcessorException("unexpected missing value in step "+name+", bad jmsadapter.xsd?");
  value = aValue.getNodeValue();
  }
//...e
//...sprocess:2:
public void process(FlowContext c)
  throws FlowProcessorException, JMSException
  {
  Object o = c.getVar(var);
  if ( o == null || o instanceof FlowNullValue )
    c.setVar(var, value);
  }
//...e
  }
