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

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

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.CriteriaData;
import org.nakedobjects.nof.reflect.remote.data.Distribution;
import org.nakedobjects.nof.reflect.remote.data.ObjectData;


public class FindInstances extends AbstractRequest {
    private static final long serialVersionUID = 1L;
    private final CriteriaData criteria;

    public FindInstances(final Session session, final CriteriaData criteria) {
        super(session);
        this.criteria = criteria;
    }
    
    public FindInstances(final ByteDecoder decoder) {
        super(decoder);
        criteria = (CriteriaData) decoder.getObject();
    }

    protected void doEncode(final ByteEncoder encoder) {
        encoder.add(criteria);
    }

    public void execute(final Distribution distribution) {
        ObjectData[] instances = distribution.findInstances(session, criteria);
        setResponse(instances);
    }

    public ObjectData[] getInstances() {
        return (ObjectData[]) response;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy