MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2017-03-11 22:13:36

badhic
Member
Registered: 2015-05-29
Posts: 4

ACLMessage content

hello,
i'm working with the last version of madkit (5.1.1), and i try to use the setContent() method to fill the content of an ACLMessage, and the getContent() method to retrieve the value.

please, am i using the right methods ?

it seems that these two methods don't proceed on the same variable.
in the source code the setContent() method is overridden in ACLMessage class and putting the value in a Hashtable structure while getContent is retrieve value from String content variable.

thank you in advance for your help

Offline


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/clients/7e4bc2f7e893962ca21d7e305619d422/web/madkit/forum/include/parser.php on line 821

#2 2017-03-12 15:42:28

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 178
Website

Re: ACLMessage content

In fact, using the ACL class, you should use getFieldValue(String key) with content as key to get what was set using setContent(), i.e. getFieldValue("content").

But, indeed there is an API problem here in the sense that the behavior of getContent is very misleading in the ACL class and should be overridden. I will fix that.
Still, the fact is that this class's code is very old and implement a lot of features which are now available in MDK, i.e. conversation/reply mechanisms of communication methods of agents.
If you do not use ACL semantics and are only interested in tagging conversation and using messages containing a map, maybe that you could consider this new class that I will add in a near future:

package madkit.message;

import java.util.HashMap;
import java.util.Map;

/**
 * This class could be used to build message conveying {@link Map} 
 * objects between MaDKit agents.
 * 
 * @author Fabien Michel
 * @since MaDKit 5.1.2
 * @version 0.9
 *
 */
public class MapMessage<K,V> extends ObjectMessage<Map<K,V>> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6301488493002636831L;

	/**
	 * Builds a <code>MapMessage</code> containing the specified map
	 * @param map the original map
	 */
	public MapMessage(final Map<K,V> map) {
		super(map);
	}

	/**
	/**
	 * Builds a <code>MapMessage</code> containing an empty  {@link HashMap}}
	 */
	public MapMessage() {
		this(new HashMap<>());
	}

	/**
	 * invoke {@link Map#put(K, V)} on the map contained in this message
	 * 
	 * @param key key with which the specified value is to be associated
	 * @param value value to be associated with the specified key
	 * @return the previous value associated with <tt>key</tt>, or
	 *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
	 *         (A <tt>null</tt> return can also indicate that the map
	 *         previously associated <tt>null</tt> with <tt>key</tt>,
	 *         if the implementation supports <tt>null</tt> values.)
	 *         
	 * @see Map#put(K, V)  
	 */
	public V put(K key, V value){
		return getContent().put(key, value);
	}

	/**
	 * invoke {@link Map#get(K)} on the map contained in this message
	 * 
     * @param key key with which the specified value is to be associated
     * @param value value to be associated with the specified key
     * @return the previous value associated with <tt>key</tt>, or
     *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
     *         (A <tt>null</tt> return can also indicate that the map
     *         previously associated <tt>null</tt> with <tt>key</tt>,
     *         if the implementation supports <tt>null</tt> values.)
 	 */
	public V get(K key){
		return getContent().get(key);
	}

}

Offline

Board footer