indexing description: "Generic message type." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class O_GENERIC_MESSAGE inherit O_MESSAGE rename make as make_message end create make create {O_MESSAGE_FACTORY} make_from_p2p_message feature {NONE} -- Initialization make (a_namespace: like namespace; a_type: like type) is -- Create. require a_namespace_ok: a_namespace /= Void and then not a_namespace.is_empty a_type_ok: a_type /= Void and then not a_type.is_empty do make_message namespace := a_namespace type := a_type create arguments.make (5) ensure namespace_set: namespace = a_namespace type_set: type = a_type end make_from_p2p_message (a_message: P2P_MESSAGE) is -- Create from a_message. require a_message_not_void: a_message /= Void local l_args: DS_LIST_CURSOR [P2P_MESSAGE_ELEMENT] l_elm: P2P_MESSAGE_ELEMENT do create id.make_from_string (a_message.element_by_namespace_and_name (message_namespace, id_element).content) namespace := a_message.element_by_namespace_and_name (message_namespace, namespace_element).content type := a_message.element_by_namespace_and_name (message_namespace, type_element).content create peer.make_from_urn (a_message.element_by_namespace_and_name (message_namespace, peer_element).content) peer_name := a_message.element_by_namespace_and_name (message_namespace, peer_name_element).content l_elm := a_message.element_by_namespace_and_name (message_namespace, reply_id_element) if l_elm /= Void then create reply_id.make_from_string (l_elm.content) end from create arguments.make (5) l_args := a_message.all_elements_of_namespace (message_argument_namespace).new_cursor l_args.start until l_args.after loop l_elm := l_args.item arguments.force (l_elm.content, l_elm.name) l_args.forth end end feature -- Access namespace: STRING -- Namespace of the message type. type: STRING -- Type of the message. arguments: HASH_TABLE [STRING, STRING] -- Table with named arguments. feature -- Update add_argument (a_key, a_value: STRING) is -- Add a new argument. require a_key_valid: a_key /= Void and then not a_key.is_empty a_value_valid: a_value /= Void and then not a_value.is_empty do arguments.force (a_value, a_key) end set_arguments (a_arguments: like arguments) is -- Set arguments to a_arguments. require a_arguments_set: a_arguments /= Void do arguments := a_arguments ensure arguments_set: arguments = a_arguments end end