ByteArrayHelper.java 1.62 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.native2pdf.bmc;

import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;

public abstract class ByteArrayHelper {
    private static String _id = "IDL:com/adobe/native2pdf/bmc/ByteArray:1.0";
    private static TypeCode __typeCode = null;

    public static void insert(Any a, byte[] that) {
        OutputStream out = a.create_output_stream();
        a.type(ByteArrayHelper.type());
        ByteArrayHelper.write(out, that);
        a.read_value(out.create_input_stream(), ByteArrayHelper.type());
    }

    public static byte[] extract(Any a) {
        return ByteArrayHelper.read(a.create_input_stream());
    }

    public static synchronized TypeCode type() {
        if (__typeCode == null) {
            __typeCode = ORB.init().get_primitive_tc(TCKind.tk_octet);
            __typeCode = ORB.init().create_sequence_tc(0, __typeCode);
            __typeCode = ORB.init().create_alias_tc(ByteArrayHelper.id(), "ByteArray", __typeCode);
        }
        return __typeCode;
    }

    public static String id() {
        return _id;
    }

    public static byte[] read(InputStream istream) {
        byte[] value = null;
        int _len0 = istream.read_long();
        value = new byte[_len0];
        istream.read_octet_array(value, 0, _len0);
        return value;
    }

    public static void write(OutputStream ostream, byte[] value) {
        ostream.write_long(value.length);
        ostream.write_octet_array(value, 0, value.length);
    }
}