All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.nos.remote.command.ExecuteClientAction Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package org.nakedobjects.nos.remote.command;

import org.nakedobjects.noa.security.Session;
import org.nakedobjects.noa.util.ByteDecoder;
import org.nakedobjects.noa.util.ByteEncoder;
import org.nakedobjects.nof.core.util.ToString;
import org.nakedobjects.nof.reflect.remote.data.ClientActionResultData;
import org.nakedobjects.nof.reflect.remote.data.Distribution;
import org.nakedobjects.nof.reflect.remote.data.ReferenceData;


public class ExecuteClientAction extends AbstractRequest {
    private static final long serialVersionUID = 1L;
    private final ReferenceData[] data;
    private final int[] types;

    public ExecuteClientAction(final Session session, final ReferenceData[] data, final int[] types) {
        super(session);
        this.data = data;
        this.types = types;
    }

    public ExecuteClientAction(ByteDecoder decoder) {
        super(decoder);
        int size = decoder.getInt();
        data = new ReferenceData[size];
        for (int i = 0; i < size; i++) {
            data[i] = (ReferenceData) decoder.getObject();
        } 
        
        size = decoder.getInt();
        types = new int[size];
        for (int i = 0; i < size; i++) {
            types[i] = decoder.getInt();
        } 
    }

    protected void doEncode(final ByteEncoder encoder) {
        encoder.add(data.length);
        for (int i = 0; i < data.length; i++) {
            encoder.add(data[i]);
        }
        encoder.add(types);
        for (int i = 0; i < types.length; i++) {
            encoder.add(types[i]);
        }
    }
    
    public void execute(final Distribution distribution) {
        setResponse(distribution.executeClientAction(session, data, types));
    }

    public ClientActionResultData getActionResult() {
        return (ClientActionResultData) getResponse();
    }

    public String toString() {
        ToString str = new ToString(this);
        str.append("data", data.length);
        return str.toString();
    }
}
// Copyright (c) Naked Objects Group Ltd.




© 2015 - 2025 Weber Informatics LLC | Privacy Policy