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

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

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

import java.io.Serializable;

import org.nakedobjects.noa.util.ByteDecoder;
import org.nakedobjects.noa.util.ByteEncoder;
import org.nakedobjects.noa.util.Encodable;
import org.nakedobjects.nof.core.util.ToString;


public class Response implements Encodable, Serializable {
    private static final long serialVersionUID = 1L;
    private final int id;
    private final Object object;

    public Response(final Request request) {
        this.id = request.getId();
        this.object = request.getResponse();
    }

    public Response(final ByteDecoder decoder) {
        id = decoder.getInt();
        object = decoder.getObject();
    }
    
    public Response(final Request request, final Exception e) {
        this.id = request.getId();
        object = e;
    }

    public void encode(final ByteEncoder encoder) {
        encoder.add(id);
        encoder.add(object);
    }
    
    public Object getObject() {
        return object;
    }

    public int getId() {
        return id;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy