Rev

Rev 1822 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
1133 berge 1
/**
2
 * @author      ETSI / STF462 / Alexandre Berge
3
 * @version     $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/BasicHeader.java $
4
 *              $Id: BasicHeader.java 2655 2017-01-26 10:46:08Z filatov $
5
 */
6
package org.etsi.ttcn.codec.its.geonetworking;
7
 
8
import org.etsi.ttcn.codec.generic.Record;
9
import org.etsi.ttcn.codec.MainCodec;
10
import org.etsi.ttcn.codec.CodecBuffer;
11
 
12
import org.etsi.ttcn.tci.EnumeratedValue;
13
import org.etsi.ttcn.tci.RecordValue;
14
import org.etsi.ttcn.tci.Type;
15
 
16
public class BasicHeader extends Record {
17
 
18
    public BasicHeader(MainCodec mainCodec) {
19
        super(mainCodec);
1822 berge 20
        setLengths();
1133 berge 21
    }
22
 
1822 berge 23
    private void setLengths() {
24
        mainCodec.setHint("LtBaseLen", "2");
25
        mainCodec.setHint("BasicNextHeaderLen", "4");
26
        mainCodec.setHint("HeaderTypeLen", "4");
27
    }
28
 
1133 berge 29
    @Override
1822 berge 30
    protected void postEncodeField(String fieldName, CodecBuffer buf) {
2655 filatov 31
//        TERFactory.getInstance().logDebug(">>> BasicHeader.postEncodeField: " + fieldName);
1822 berge 32
 
33
        if(fieldName.equals("nextHeader")) {
34
            mainCodec.setHint("GnNextHeader", Integer.toString(buf.getBytes(buf.getNbBytes() - 1, 1)[0]));
35
        }
36
    }
37
 
38
    @Override
39
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 40
//        TERFactory.getInstance().logDebug(">>> BasicHeader.preDecodeField: " + fieldName + ", " + decodingHypothesis);
1822 berge 41
    }
42
 
43
    @Override
1133 berge 44
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 45
//        TERFactory.getInstance().logDebug(">>> BasicHeader.postDecodeField: " + fieldName + ", " + decodingHypothesis);
1133 berge 46
 
47
        if(fieldName.equals("nextHeader")) {
48
            int nh = ((EnumeratedValue)(rv.getField(fieldName))).getInt();
49
            mainCodec.setHint("GnNextHeader", Integer.toString(nh));
50
        }
51
    }
52
}