//
// FlowStepPropGet.java - Copy message property to 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 FlowStepPropGet extends FlowStep
  {
  protected String prop;
  protected String var;
//...sFlowStepPropGet:2:
public FlowStepPropGet(Node eStep)
  throws FlowProcessorException
  {
  super(eStep);
  NamedNodeMap nnmStep = eStep.getAttributes();
  Node aProp = nnmStep.getNamedItem("prop");
  if ( aProp == null )
    throw new FlowProcessorException("unexpected missing prop in step "+name+", bad jmsadapter.xsd?");
  prop = aProp.getNodeValue();
  Node aVar = nnmStep.getNamedItem("var");
  var = ( aVar != null ) ? aVar.getNodeValue() : "v0";
  }
//...e
//...sprocess:2:
public void process(FlowContext c)
  throws FlowProcessorException, JMSException
  {
  JmsaMessage m = c.getMessage();
  Object o = m.getObjectProperty(prop);
    // Note: o is one of
    // Boolean
    // Byte
    // Short
    // Integer
    // Long
    // Float
    // Double
    // null
  c.setVar(var, o != null ? o : new FlowNullValue());
  }
//...e
  }
