/**
 * Protocols test
 * Copyright (C) 2007 Bull S.A.S.
 * Contact: jonas-team@objectweb.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.ow2.jonas.protocols.test.ejbs;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;

/**
 * @author Francois Waeselynck
 */
public class Request implements Serializable {

	/**
     *
     */
    private static final long serialVersionUID = 1L;

    public Request(String root) {
		id = root
			+ "-" + Long.toString(System.currentTimeMillis())
			+ "-" + Thread.currentThread().getName();
	}

	public String getId() {
		return id;
	}

	public void addStamp(String name,String progress) {
		String s = name + ":" + progress;
		map.put(s, s + "-" + new Date().toString());
	}

	public String getStamp(String stamp) {
		return (String) map.get(stamp);
	}

	public HashMap getStamps() {
		return (HashMap) map.clone();
	}

	public String toString() {
		StringBuffer buf = new StringBuffer(1024);
		buf.append("\n<REQUESTID>");
		buf.append(id);
		buf.append("</REQUESTID>\n");
		buf.append("\n<KEYS>\n");
		buf.append(map.toString());
		buf.append("\n</KEYS>\n");
		return buf.toString();

	}


	private String id = null;
	private HashMap map = new HashMap();
}
