Parses a simple message

        :param msg: the json-decoded value
        :param name: the requested name

        :raises UnknownMessageType: if the type is not 'simple'
        :raises InvalidMessage: if the message cannot be parsed or validated
765942
def parse(self, msg, name):
        

        # On requests we imply 'simple' if there is no input message
        if msg is None:
            return

        if not isinstance(msg, string_types):
            raise InvalidMessage("The 'value' attribute is not a string")

        self.name = name
        self.payload = msg
        self.msg_type = 'simple'
125801
static void checkUnqualifiedName(int version, final String name,
            final String msg) {
        if ((version & 0xFFFF) < Opcodes.V1_5) {
            checkIdentifier(name, msg);
        } else {
            for (int i = 0; i < name.length(); ++i) {
                if (".;[/".indexOf(name.charAt(i)) != -1) {
                    throw new IllegalArgumentException("Invalid " + msg
                            + " (must be a valid unqualified name): " + name);
                }
            }
        }
    }
146646
def deserialize(self, msg):
        ''
        self.logger.debug('deserializing %s', msg)
        return json.loads(msg)
1096522
def parse_message(xml):
    
    if not xml:
        return
    message = xmltodict.parse(to_text(xml))['xml']
    message_type = message['MsgType'].lower()
    event_type = None
    if message_type == 'event' or message_type.startswith('device_'):
        if 'Event' in message:
            event_type = message['Event'].lower()
        # special event type for device_event
        if event_type is None and message_type.startswith('device_'):
            event_type = message_type
        elif message_type.startswith('device_'):
            event_type = 'device_{event}'.format(event=event_type)

        if event_type == 'subscribe' and message.get('EventKey'):
            event_key = message['EventKey']
            if event_key.startswith(('scanbarcode|', 'scanimage|')):
                event_type = 'subscribe_scan_product'
                message['Event'] = event_type
            elif event_key.startswith('qrscene_'):
                # Scan to subscribe with scene id event
                event_type = 'subscribe_scan'
                message['Event'] = event_type
                message['EventKey'] = event_key[len('qrscene_'):]
        message_class = EVENT_TYPES.get(event_type, UnknownMessage)
    else:
        message_class = MESSAGE_TYPES.get(message_type, UnknownMessage)
    return message_class(message)
1175060
def _DecodeUnknownMessages(message, encoded_message, pair_type):
    """"""
    field_type = pair_type.value.type
    new_values = []
    all_field_names = [x.name for x in message.all_fields()]
    for name, value_dict in six.iteritems(encoded_message):
        if name in all_field_names:
            continue
        value = PyValueToMessage(field_type, value_dict)
        if pair_type.value.repeated:
            value = _AsMessageList(value)
        new_pair = pair_type(key=name, value=value)
        new_values.append(new_pair)
    return new_values
951030
def decode(self, msg):
        """"""
        _check_message_valid(msg)
        cmd = msg[2:4]
        decoder = getattr(self, '_{}_decode'.format(cmd.lower()), None)
        if not decoder:
            cmd = 'unknown'
            decoder = self._unknown_decode
        decoded_msg = decoder(msg)
        for handler in self._handlers.get(cmd, []):
            handler(**decoded_msg)
1089145
def __decode_dictionary(self, message_type, dictionary):
        
        message = message_type()
        for key, value in six.iteritems(dictionary):
            if value is None:
                try:
                    message.reset(key)
                except AttributeError:
                    pass  # This is an unrecognized field, skip it.
                continue

            try:
                field = message.field_by_name(key)
            except KeyError:
                # Save unknown values.
                variant = self.__find_variant(value)
                if variant:
                    message.set_unrecognized_field(key, value, variant)
                continue

            if field.repeated:
                # This should be unnecessary? Or in fact become an error.
                if not isinstance(value, list):
                    value = [value]
                valid_value = [self.decode_field(field, item)
                               for item in value]
                setattr(message, field.name, valid_value)
                continue
            # This is just for consistency with the old behavior.
            if value == []:
                continue
            try:
                setattr(message, field.name, self.decode_field(field, value))
            except messages.DecodeError:
                # Save unknown enum values.
                if not isinstance(field, messages.EnumField):
                    raise
                variant = self.__find_variant(value)
                if variant:
                    message.set_unrecognized_field(key, value, variant)

        return message
951779
async def message(self, msg, msg_type=None):
        
        elem_type = msg_type if msg_type is not None else msg.__class__

        if hasattr(elem_type, 'blob_serialize'):
            msg = elem_type() if msg is None else msg
            return await msg.blob_serialize(self)

        fields = elem_type.f_specs()
        for field in fields:
            await self.message_field(msg=msg, field=field)

        return msg
812980
protected boolean checkSupportedMessageTypes(Message msg) {
        if (msg instanceof TextMessage) {
            return true;
        } else {
            try {
                log.error("Unsupported message type: " + msg.getJMSType());
            } catch (JMSException ignore) {
            }
            sendToInvalidMessageQueue(msg);
            return false;
        }
    }
531910
def decode(data):
    
    decoded = None
    try:
        decoded = json.loads(data)
    except Exception, e:
        raise MetaParsingException("Can't parse your JSON data: %s" % e.message)

    decoded = validator.check_structure(decoded)

    return decoded
290887
public B message(String messageName) {
    Message message = findMessageForName(messageName);
    return message(message);
  }
1270204
def message
      return {} unless params[:_message]
      begin
        Marshal.load(Merb::Parse.unescape(params[:_message]).unpack("m").first)
      rescue ArgumentError, TypeError
        {}
      end
    end
1024869
def _is_msg(self, msg):
        
        if not msg or len(msg) < self.prefix_len:
            return False
        length = self._extract_len(msg[:self.prefix_len])
        msg_type = msg[self.prefix_len:].split(' ', 1)[0]
        if length == len(msg[self.prefix_len:]) and msg_type in self.msg_types:
            return True
        return False
514163
async def send_message(self, name, level, message):
        

        if name not in self.services:
            raise ArgumentError("Unknown service name", short_name=name)

        msg = self.services[name]['state'].post_message(level, message)
        await self._notify_update(name, 'new_message', msg.to_dict())
1171369
def _AsMessageList(msg):
    """"""
    # This really needs to live in extra_types, but extra_types needs
    # to import this file to be able to register codecs.
    # TODO(craigcitro): Split out a codecs module and fix this ugly
    # import.
    from apitools.base.py import extra_types

    def _IsRepeatedJsonValue(msg):
        """Return True if msg is a repeated value as a JsonValue."""
        if isinstance(msg, extra_types.JsonArray):
            return True
        if isinstance(msg, extra_types.JsonValue) and msg.array_value:
            return True
        return False

    if not _IsRepeatedJsonValue(msg):
        raise ValueError('invalid argument to _AsMessageList')
    if isinstance(msg, extra_types.JsonValue):
        msg = msg.array_value
    if isinstance(msg, extra_types.JsonArray):
        msg = msg.entries
    return msg
811159
def ParseMessage(descriptor, byte_str):
  
  result_class = MakeClass(descriptor)
  new_msg = result_class()
  new_msg.ParseFromString(byte_str)
  return new_msg
527929
def _validate_message_type(self):
        
        if self._unsupported_message_type():
            self.logger.warning(
                'Received unsupported message type: %s', self.message_type)
            if self._drop_invalid:
                if self._drop_exchange:
                    self._republish_dropped_message('invalid type')
                raise DropMessage
            raise MessageException