IppPropByteArray.java 3.82 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.scene7.is.ipp.messages;

import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppByte;
import com.scene7.is.ipp.messages.IppByteArray;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.IppProp;
import com.scene7.is.ipp.messages.IppPropId;
import com.scene7.is.ipp.messages.IppPropType;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.Writer;

public class IppPropByteArray
extends IppProp {
    private int id_;
    private byte[] value_;

    public IppPropByteArray(int id, byte[] value) {
        this.id_ = id;
        this.value_ = value;
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        buffer.append("id: ").append(String.valueOf(this.id_)).append(" ");
        buffer.append("value: ").append(String.valueOf(this.value_)).append(" ");
        buffer.append("]");
        return buffer.toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof IppPropByteArray)) {
            return false;
        }
        IppPropByteArray e = (IppPropByteArray)o;
        if (this.id_ != e.id_) {
            return false;
        }
        if (this.value_.length != e.value_.length) {
            return false;
        }
        for (int i = 0; i < this.value_.length; ++i) {
            if (this.value_[i] == e.value_[i]) continue;
            return false;
        }
        return true;
    }

    public static IppPropByteArray UnstuffDerived(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppPropByteArray align");
        int type = IppInt.Unstuff(arr, arrayPos);
        int id = IppInt.Unstuff(arr, arrayPos);
        byte[] value = IppByteArray.Unstuff(arr, arrayPos);
        IppByte.UnstuffFixedArray(arr, arrayPos, 32);
        Ipp.Assert(type == 65542, "IppPropByteArray enum id");
        return new IppPropByteArray(id, value);
    }

    public static void StuffDerived(byte[] arr, Offset arrayPos, Offset varPos, IppPropByteArray val) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppPropByteArray align");
        if (val != null) {
            IppInt.Stuff(arr, arrayPos, varPos, val.type());
            IppInt.Stuff(arr, arrayPos, varPos, val.id());
            IppByteArray.Stuff(arr, arrayPos, varPos, val.value());
            Ipp.StuffNullBytes(arr, arrayPos, 32);
        } else {
            Ipp.StuffNullBytes(arr, arrayPos, 48);
        }
    }

    public static void Print(Writer tf, String label, IppPropByteArray it) throws IOException {
        String ll = label + "IppPropByteArray: ";
        if (it == null) {
            tf.write(ll + "NULL!!\n");
            return;
        }
        tf.write(ll + "\n");
        IppPropType.Print(tf, ll + "type: ", it.type());
        IppPropId.Print(tf, ll + "id: ", it.id());
        IppByteArray.Print(tf, ll + "value: ", it.value());
    }

    public static void PrintArray(Writer tf, String label, IppPropByteArray[] it) throws IOException {
        String ll = label + "IppPropByteArray Array, length: ";
        tf.write(ll);
        if (it == null) {
            tf.write("NULL!!!\n");
            return;
        }
        tf.write("" + it.length + "\n");
        for (int i = 0; i < it.length; ++i) {
            ll = label + "IppPropByteArray[" + String.valueOf(i) + "]: ";
            IppPropByteArray.Print(tf, ll, it[i]);
        }
    }

    public void adjustVarPos(Offset varPos) {
        varPos.val += this.value_.length;
    }

    public int type() {
        return 65542;
    }

    public int id() {
        return this.id_;
    }

    public byte[] value() {
        return this.value_;
    }

    public String toStringDerived() {
        return String.valueOf(this.value());
    }

    public Object getValue() {
        return this.value();
    }
}