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

Alachisoft.NCache.Common.RPCFramework.TargetMethodParameter Maven / Gradle / Ivy

package Alachisoft.NCache.Common.RPCFramework;

import com.alachisoft.ncache.serialization.core.io.ICompactSerializable;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectInput;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectOutput;

import java.io.IOException;

public class TargetMethodParameter implements ICompactSerializable {

    private java.util.ArrayList _parameterList = new java.util.ArrayList();

    public final java.util.ArrayList getParameterList() {
        return _parameterList;
    }

    public final void TargetMethodArguments() {
        _parameterList = new java.util.ArrayList();
    }

    public final void TargetMethodArguments(java.util.ArrayList parameter) {
        _parameterList = parameter;
    }

    public final void AddParameter(Object parameter) {
        _parameterList.add(parameter);
    }

    //
    public final void deserialize(NCacheObjectInput reader) throws ClassNotFoundException, IOException {
        _parameterList = new java.util.ArrayList();
        int length = reader.readInt();

        boolean isByteArray = false;
        for (int i = 0; i < length; i++) {
            isByteArray = reader.readBoolean();
            if (isByteArray) {
                int count = reader.readInt();
                byte[] buffer = new byte[count];
                reader.readFully(buffer);
                _parameterList.add(buffer);
            } else
                _parameterList.add(reader.readObject());
        }

    }

    public final void serialize(NCacheObjectOutput writer) throws IOException {
        writer.writeInt(_parameterList.size());
        boolean isByteArray = false;
        for (int i = 0; i < _parameterList.size(); i++) {
            isByteArray = _parameterList.get(i) != null && _parameterList.get(i).getClass() == byte[].class;
            writer.writeBoolean(isByteArray);
            if (isByteArray) {
                byte[] buffer = (byte[]) _parameterList.get(i);
                writer.writeInt(buffer.length);
                writer.write(buffer);
            } else
                writer.writeObject(_parameterList.get(i));
        }

    }
    //
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy