Handles a complex message with placeholders.
333229
private Statement handleTranslationWithPlaceholders(
      MsgNode msg,
      ImmutableList<SoyPrintDirective> escapingDirectives,
      Expression soyMsgParts,
      Expression locale,
      MsgPartsAndIds partsAndId) {
    // We need to render placeholders into a buffer and then pack them into a map to pass to
    // Runtime.renderSoyMsgWithPlaceholders.

    Map<String, Function<Expression, Statement>> placeholderNameToPutStatement =
        new LinkedHashMap<>();
    putPlaceholdersIntoMap(msg, partsAndId.parts, placeholderNameToPutStatement);
    // sanity check
    checkState(!placeholderNameToPutStatement.isEmpty());
    ConstructorRef cstruct =
        msg.isPlrselMsg() ? ConstructorRef.PLRSEL_MSG_RENDERER : ConstructorRef.MSG_RENDERER;
    Statement initRendererStatement =
        variables
            .getCurrentRenderee()
            .putInstanceField(
                thisVar,
                cstruct.construct(
                    constant(partsAndId.id),
                    soyMsgParts,
                    locale,
                    constant(placeholderNameToPutStatement.size())));
    List<Statement> initializationStatements = new ArrayList<>();
    initializationStatements.add(initRendererStatement);
    for (Function<Expression, Statement> fn : placeholderNameToPutStatement.values()) {
      initializationStatements.add(fn.apply(variables.getCurrentRenderee().accessor(thisVar)));
    }

    Statement initMsgRenderer = Statement.concat(initializationStatements);
    Statement render;
    if (areAllPrintDirectivesStreamable(escapingDirectives)) {
      AppendableAndOptions wrappedAppendable =
          applyStreamingEscapingDirectives(
              escapingDirectives,
              appendableExpression,
              parameterLookup.getPluginContext(),
              variables);
      FieldRef currentAppendableField = variables.getCurrentAppendable();
      Statement initAppendable =
          currentAppendableField.putInstanceField(thisVar, wrappedAppendable.appendable());
      Expression appendableExpression = currentAppendableField.accessor(thisVar);
      Statement clearAppendable =
          currentAppendableField.putInstanceField(
              thisVar, constantNull(LOGGING_ADVISING_APPENDABLE_TYPE));
      if (wrappedAppendable.closeable()) {
        clearAppendable =
            Statement.concat(
                appendableExpression
                    .checkedCast(BytecodeUtils.CLOSEABLE_TYPE)
                    .invokeVoid(MethodRef.CLOSEABLE_CLOSE),
                clearAppendable);
      }
      render =
          Statement.concat(
              initAppendable,
              detachState.detachForRender(
                  variables
                      .getCurrentRenderee()
                      .accessor(thisVar)
                      .invoke(
                          MethodRef.SOY_VALUE_PROVIDER_RENDER_AND_RESOLVE,
                          appendableExpression,
                          // set the isLast field to true since we know this will only be rendered
                          // once.
                          /* isLast=*/ constant(true))),
              clearAppendable);
    } else {
      Label start = new Label();
      SoyExpression value =
          SoyExpression.forSoyValue(
              StringType.getInstance(),
              detachState
                  .createExpressionDetacher(start)
                  .resolveSoyValueProvider(variables.getCurrentRenderee().accessor(thisVar))
                  .checkedCast(SOY_STRING_TYPE));
      for (SoyPrintDirective directive : escapingDirectives) {
        value = parameterLookup.getRenderContext().applyPrintDirective(directive, value);
      }
      render =
          appendableExpression.appendString(value.unboxAsString()).toStatement().labelStart(start);
    }
    return Statement.concat(
        initMsgRenderer,
        render,
        // clear the field
        variables
            .getCurrentRenderee()
            .putInstanceField(
                thisVar,
                BytecodeUtils.constantNull(ConstructorRef.MSG_RENDERER.instanceClass().type())));
  }
715019
def _handler(self, sender, setting, value, **kwargs):
        
        if setting.startswith(self.prefix):
            self._set_attr(setting, value)
1350583
private void parseTextMessage(String message) {
        JSONObject data;
        try {
            data = new JSONObject(message);
            if(!data.has("type")){
                return;
            }

            String type = data.getString("type");
            if(type.equals("order")) {
                if(orderUpdateListener != null) {
                    orderUpdateListener.onOrderUpdate(getOrder(data));
                }
            }

        }catch (JSONException e) {
            e.printStackTrace();
        }
    }
372278
def _handle_message(self, data):
        

        try:
            data = data.decode('utf-8')
        except:
            raise InvalidMessageError('Decode failed for message: {0}'.format(data))

        if data is not None:
            data = data.lstrip('\0')

        if data is None or data == '':
            raise InvalidMessageError()

        msg = None
        header = data[0:4]

        if header[0] != '!' or header == '!KPM':
            msg = self._handle_keypad_message(data)

        elif header == '!EXP' or header == '!REL':
            msg = self._handle_expander_message(data)

        elif header == '!RFX':
            msg = self._handle_rfx(data)

        elif header == '!LRR':
            msg = self._handle_lrr(data)

        elif header == '!AUI':
            msg = self._handle_aui(data)

        elif data.startswith('!Ready'):
            self.on_boot()

        elif data.startswith('!CONFIG'):
            self._handle_config(data)

        elif data.startswith('!VER'):
            self._handle_version(data)

        elif data.startswith('!Sending'):
            self._handle_sending(data)

        return msg
601709
private void handleIncomingEvent(final Message message) {
        switch (EventTopic.valueOf(getStringHeaderKey(message, MessageHeaderKey.TOPIC, "EventTopic is null"))) {
        case UPDATE_ACTION_STATUS:
            updateActionStatus(message);
            break;
        case UPDATE_ATTRIBUTES:
            updateAttributes(message);
            break;
        default:
            logAndThrowMessageError(message, "Got event without appropriate topic.");
            break;
        }

    }
682503
def echo(self, message, *, encoding=_NOTSET):
        """"""
        return self.execute('ECHO', message, encoding=encoding)
305683
protected String handleError(final String message) {
        notifier().error(formatMessage(message));
        return formatMessage(message);
    }
210142
def handle_msg(self, msg, **config):
        
        match = self.__prefix__.match(msg['topic'])
        if match:
            return match.groups()[-1] or ""
479359
@SuppressWarnings("unchecked")
  private void doMessage(final JsonObject message) {
    Object value = deserializer.deserialize(message);
    if (value != null && messageHandler != null) {
      if (log.isDebugEnabled()) {
        log.debug(String.format("%s - Received: Message[id=%d, value=%s]", this, message.getLong("id"), value));
      }
      messageHandler.handle(value);
    }
    for (InputHook hook : hooks) {
      hook.handleReceive(value);
    }
  }
679976
def handle_message(self, msg):
        
        # log messages received so that no one else has to
        if self._logger.isEnabledFor(logging.DEBUG):
            self._logger.debug(
                "received from {}: {}"
                .format(self.bind_address_string, repr(str(msg))))

        if msg.mtype == Message.INFORM:
            return self.handle_inform(msg)
        elif msg.mtype == Message.REPLY:
            return self.handle_reply(msg)
        elif msg.mtype == Message.REQUEST:
            return self.handle_request(msg)
        else:
            self._logger.error("Unexpected message type from server ['%s']."
                               % (msg,))
773809
def handle_symbol_info(self, call_id, payload):
        """"""
        with catch(KeyError, lambda e: self.editor.message("unknown_symbol")):
            decl_pos = payload["declPos"]
            f = decl_pos.get("file")
            call_options = self.call_options[call_id]
            self.log.debug('handle_symbol_info: call_options %s', call_options)
            display = call_options.get("display")
            if display and f:
                self.editor.raw_message(f)

            open_definition = call_options.get("open_definition")
            if open_definition and f:
                self.editor.clean_errors()
                self.editor.doautocmd('BufLeave')
                if call_options.get("split"):
                    vert = call_options.get("vert")
                    self.editor.split_window(f, vertical=vert)
                else:
                    self.editor.edit(f)
                self.editor.doautocmd('BufReadPre', 'BufRead', 'BufEnter')
                self.set_position(decl_pos)
                del self.call_options[call_id]
1373155
def substitute(self, msg, kind):
        

        # Safety checking.
        if 'lists' not in self.master._sorted:
            raise RepliesNotSortedError("You must call sort_replies() once you are done loading RiveScript documents")
        if kind not in self.master._sorted["lists"]:
            raise RepliesNotSortedError("You must call sort_replies() once you are done loading RiveScript documents")

        # Get the substitution map.
        subs = None
        if kind == 'sub':
            subs = self.master._sub
        else:
            subs = self.master._person

        # Make placeholders each time we substitute something.
        ph = []
        i  = 0

        for pattern in self.master._sorted["lists"][kind]:
            result = subs[pattern]

            # Make a placeholder.
            ph.append(result)
            placeholder = "\x00%d\x00" % i
            i += 1

            cache = self.master._regexc[kind][pattern]
            msg = re.sub(cache["sub1"], placeholder, msg)
            msg = re.sub(cache["sub2"], placeholder + r'\1', msg)
            msg = re.sub(cache["sub3"], r'\1' + placeholder + r'\2', msg)
            msg = re.sub(cache["sub4"], r'\1' + placeholder, msg)

        placeholders = re.findall(RE.placeholder, msg)
        for match in placeholders:
            i = int(match)
            result = ph[i]
            msg = msg.replace('\x00' + match + '\x00', result)

        # Strip & return.
        return msg.strip()
528048
def handle_event(self, message):
        """"""
        # _LOGGER.debug(message)
        needs_update = 0
        for zone in self.zones:
            if zone in message:
                _LOGGER.debug("Received message for zone: %s", zone)
                self.zones[zone].update_status(message[zone])

        if 'netusb' in message:
            needs_update += self.handle_netusb(message['netusb'])

        if needs_update > 0:
            _LOGGER.debug("needs_update: %d", needs_update)
            self.update_hass()
894669
def message(self, message, item, extra):
        """"""
        if item is not None:
            message += ": " + ascii(item)
        if extra is not None:
            message += " (" + str(extra) + ")"
        return message
78224
def format_message(severity, datetime, progname, msg)
      if String === msg then
        msg.inject('') { |s, line| s << super(severity, datetime, progname, line.chomp) }
      else
        super
      end
    end
1141501
protected function interpolate($message, array $placeholders = [])
    {
        if ($placeholders) {
            $replace = [];
            foreach ($placeholders as $key => $val) {
                $replace['{' . $key . '}'] = $val;
            }

            return strtr($message, $replace);
        } else {
            return $message;
        }
    }
1287015
function (message, context) {
                message = this.messages[message] || message.toString();
                if (context) {
                    $.each(context, function (key, value) {
                        message = message.replace('{' + key + '}', value);
                    });
                }
                return message;
            }