Package org.hxzon.asn1.goose

Source Code of org.hxzon.asn1.goose.GoosePduParser

package org.hxzon.asn1.goose;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import org.hxzon.asn1.core.parse.BerInputStream;
import org.hxzon.asn1.core.parse.BerParser;
import org.hxzon.asn1.core.parse.Tag;
import org.hxzon.asn1.core.parse.ext.Asn1Utils;
import org.hxzon.asn1.core.type.base.BerNode;
import org.hxzon.util.BytesUtil;

public class GoosePduParser extends BerParser {

    public static final GoosePduParser parser = new GoosePduParser();

    protected GoosePduParser() {

    }

    @Override
    public BerNode create(int tag, BerInputStream stream) {
        switch (tag) {
        case Tag.APPLICATION | 1:
            return new GoosePdu().init("goose pdu", "goose pdu", tag, stream);
        default:
            return Asn1Utils.createUnknown(tag, stream);
        }
    }

    public BerNode parseGoose(byte[] data, int offset) {
        ByteArrayInputStream inStream = new ByteArrayInputStream(BytesUtil.copyBytes(data, offset));
        BerInputStream in = new BerInputStream(inStream);
        in.setTagOffset(offset);
        try {
            return super.readPacket(in);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
TOP

Related Classes of org.hxzon.asn1.goose.GoosePduParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.