IppByte.java 1.71 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.Offset;
import java.io.IOException;
import java.io.Writer;

public class IppByte {
    public IppByte() {
        Ipp.Assert(false, "IppByte ctor");
    }

    public static byte Unstuff(byte[] arr, Offset arrayPos) {
        int pos = arrayPos.val++;
        return arr[pos];
    }

    public static byte[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
        byte[] result = new byte[count];
        System.arraycopy(arr, arrayPos.val, result, 0, count);
        arrayPos.val += count;
        return result;
    }

    public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, byte val) {
        arr[arrayPos.val] = val;
        ++arrayPos.val;
    }

    public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, byte[] val) {
        Ipp.Assert(count == val.length, "IppByte count");
        System.arraycopy(val, 0, arr, arrayPos.val, count);
        arrayPos.val += count;
    }

    public static void Print(Writer tf, String label, byte it) throws IOException {
        String ll = label + "IppByte: ";
        tf.write(ll);
        tf.write("" + it + "\n");
    }

    public static void PrintArray(Writer tf, String label, byte[] it) throws IOException {
        String ll = label + "IppByte 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 + "IppByte[" + String.valueOf(i) + "]: ";
            IppByte.Print(tf, ll, it[i]);
        }
    }
}