Examples of xPL_MutableMessageI


Examples of org.cdp1802.xpl.xPL_MutableMessageI

      @ParamDoc(name="msgType") String msgType,
      @ParamDoc(name="schema") String schema,     
      @ParamDoc(name="bodyElements") String ... bodyElements
          )
  {   
    xPL_MutableMessageI theMessage  = xPL_Utils.createMessage();
   
      xPL_IdentifierI targetIdentifier = xplTransportService.parseNamedIdentifier(target);
    if (targetIdentifier == null) {
      logger.error("Invalid target identifier");
      return false;
    }
     
      theMessage.setTarget(targetIdentifier);
     
      // Parse type
      if (msgType.equalsIgnoreCase("TRIGGER"))
        theMessage.setType(xPL_MessageI.MessageType.TRIGGER);
      else if (msgType.equalsIgnoreCase("STATUS"))
        theMessage.setType(xPL_MessageI.MessageType.STATUS);
      else if (msgType.equalsIgnoreCase("COMMAND"))
        theMessage.setType(xPL_MessageI.MessageType.COMMAND);
      else {
      logger.error("Invalid message type");
      return false;
    }

      // Parse Schema
      int delimPtr = schema.indexOf(".");
    if (delimPtr == -1) {
      logger.error("Invalid/improperly formatted schema class.type");
      return false;
    }
   
      String schemaClass = schema.substring(0, delimPtr);
      String schemaType = schema.substring(delimPtr + 1);
      if ((schemaClass.length() == 0) || (schemaType.length() == 0)) {
      logger.error("Empty/missing parts of schema class.type");
      return false;
    }
     
      theMessage.setSchema(schemaClass, schemaType);
     
      // Parse name/value pairs     
      String theName = null;
      String theValue = null;
      theMessage.clearMessageBody();
     
      for (int pairPtr = 0; pairPtr < bodyElements.length; pairPtr++) {
        if ((delimPtr = bodyElements[pairPtr].indexOf("=")) == -1) {
        logger.error("Invalid message body name/value pair");
        return false;
        }
        if ((theName = bodyElements[pairPtr].substring(0, delimPtr)).length() == 0) {
        logger.error("Empty name in message body name/value pair");
        return false;
        }
       
        theValue = bodyElements[pairPtr].substring(delimPtr + 1);

        theMessage.addNamedValue(theName, theValue);
      }
     
      xplTransportService.sendMessage(theMessage);
     
    return true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.