note description: "Generic message type." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class A_GENERIC_MESSAGE obsolete "Use separate message with proper type & namespace instead." inherit A_MESSAGE rename make as make_message redefine handle end create make create {A_MESSAGE_FACTORY} make_from_ems_message feature {NONE} -- Initialization make (a_namespace: like namespace; a_type: like type) -- 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 (create {DS_HASH_TABLE [A_STRING_VALUE, A_STRING_VALUE]}.make (16)) ensure namespace_set: namespace = a_namespace type_set: type = a_type end feature -- Message handling handle (a_handler: A_GENERIC_MESSAGE_HANDLER) -- do a_handler.handle_generic (Current) end feature -- Access namespace: STRING -- Namespace of the message type. type: STRING -- Type of the message. arguments: A_MAP_VALUE [A_STRING_VALUE] -- Table with named arguments. feature -- Update set_namespace (a_value: like namespace) -- Set `namespace' do namespace := a_value end set_type (a_value: like type) -- Set `type' do type := a_value end add_argument (a_key, a_value: STRING) -- 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.map.force (create {A_STRING_VALUE}.make (a_value), create {A_STRING_VALUE}.make (a_key)) end set_arguments (a_arguments: like arguments) -- Set arguments to a_arguments. require a_arguments_set: a_arguments /= Void do arguments := a_arguments ensure arguments_set: arguments = a_arguments end feature {NONE} -- Implementation serialization_list: attached STRING -- Lists the fields to serialize, and under which name do create Result.make_empty Result.append ("%"" + arguments_argument + "%":") Result.append (arguments.serialize) end parse_tag (a_tag: STRING; a_tokenizer: A_JSON_TOKENIZER) do if a_tag.is_equal (arguments_argument) then create arguments.make_from_tokenizer (a_tokenizer) end end feature {NONE} -- Implementation arguments_argument: STRING = "arguments" invariant arguments_exist: arguments /= Void end