// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package ws.server;

import java.util.*;

public class TestDoubleSigLog {
    public NameValuePair[] execute(NameValuePair[] arg) {
        Map m = toMap(arg);
        m.put("status", "ok");
        return fromMap(m);
    }
    private static NameValuePair[] fromMap(Map m) {
        NameValuePair[] nvp = new NameValuePair[m.size()];
        Iterator it = m.keySet().iterator();
        for(int i = 0; i < nvp.length; i++) {
            nvp[i] = new NameValuePair();
            nvp[i].setName((String)it.next());
            nvp[i].setValue((String)m.get(nvp[i].getName()));
        }
        return nvp;
    }
    private static Map toMap(NameValuePair[] nvp) {
        Map m = new HashMap();
        for(int i = 0; i < nvp.length; i++) {
            m.put(nvp[i].getName(), nvp[i].getValue());
        }
        return m;
    }
}
