/*
 * Automatically generated by jrpcgen 1.1.6 on 21.02.24 22:11
 * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
 * See http://remotetea.sourceforge.net for details
 */
package tests.org.acplt.oncrpc.jrpcgen;
import org.acplt.oncrpc.*;
import java.io.IOException;

/** TODO */
public class STRING implements XdrAble, java.io.Serializable {
    /** TODO */
    public String value;

    private static final long serialVersionUID = -3550520278981460557L;

    public STRING() {
    }

    public STRING(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        xdrDecode(xdr);
    }

    public STRING(String value) {
        this.value = value;
    }

    @Override
    public void xdrEncode(XdrEncodingStream xdr)
           throws OncRpcException, IOException {
        xdr.xdrEncodeString(value);
    }

    @Override
    public void xdrDecode(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        value = xdr.xdrDecodeString();
    }

    @Override
    public String toString() {
        return "STRING ["
        + "value=" + value
        + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        STRING other = (STRING)obj;
        if (! java.util.Objects.equals(this.value, other.value)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        return XdrHashCode.hashCode(this);
    }

    public static void xdrEncodeFixedVector(XdrEncodingStream xdr, STRING[] vector, int size)
           throws OncRpcException, IOException {
        if (vector.length != size) {
            throw new IllegalArgumentException("array size does not match protocol specification");
        }

        for (int index = 0; index < size; index++) {
            vector[index].xdrEncode(xdr);
        }
    }

    public static STRING[] xdrDecodeFixedVector(XdrDecodingStream xdr, int size)
           throws OncRpcException, IOException {
        STRING[] vector = new STRING[size];

        for (int index = 0; index < size; index++) {
            vector[index] = new STRING(xdr);
        }

        return vector;
    }

    public static void xdrEncodeDynamicVector(XdrEncodingStream xdr, STRING[] vector)
           throws OncRpcException, IOException {
        xdr.xdrEncodeInt(vector.length);
        xdrEncodeFixedVector(xdr, vector, vector.length);
    }

    public static STRING[] xdrDecodeDynamicVector(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        return xdrDecodeFixedVector(xdr, xdr.xdrDecodeInt());
    }

}
// End of STRING.java
