/**
 * @author      ETSI / STF462 / Alexandre Berge
 * @version     $URL$
 *              $Id$
 */
package org.etsi.ttcn.codec.its.geonetworking;

import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.tci.Value;

public class GnNonSecuredPacket extends Record {

    public GnNonSecuredPacket(MainCodec mainCodec) {
        super(mainCodec);
    }

    @Override
    protected void postEncodeField(String fieldName, CodecBuffer buf) {

        if(fieldName.equals("payload")) {
            // Compute Payload's length and set a hint
            int length = buf.getNbBits() / 8;
            mainCodec.setHint("payloadLength", Integer.toString(length));
        }
    }

    @Override
    public CodecBuffer preEncode(Value value) {
        
        mainCodec.setHint("payloadLength", Integer.toString(0));
        return new CodecBuffer();
    }
}