package org.ts.ddcs.DataItemTemplate;

import org.ts.ddcs.DataTemplate.ItemTemplateSet;
import org.ts.ddcs.log.LogHelper;
import org.ts.ddcs.Tool.BytesHelp;

import java.math.BigDecimal;

public class UnknownDataItemTemplate extends DataItemTemplate implements DataItemTemplateInterface {
    @Override
    public void Init(ItemTemplateSet template) {
        this.feture = template.getFeature();
    }

    @Override
    public BigDecimal GetDecimal() {
        return null;
    }

    @Override
    public String GetVarchar() {
        return null;
    }

    @Override
    public byte[] GetByteArray() {
        return new byte[0];
    }

    @Override
    public byte[] Stream(byte[] data) {
        byte[] remain = data;
        try {
            int count = 0;
            String flag = BytesHelp.byte2HexStr(remain, count, 1);
            count += 1;
            byte[] dataSize = BytesHelp.subBytes(remain, count, 1);
            count += 1;
            int dataTotalLen = dataSize[0] >> 3;
            count += dataTotalLen;
            LogHelper.info("***************************UNKNOWN:" + BytesHelp.byte2HexStr(BytesHelp.subBytes(remain, 0, count)));
            remain = BytesHelp.subBytes(remain, count, remain.length - count);
        } catch (Exception e) {
            LogHelper.error(e);
        }
        return remain;
    }

    @Override
    public boolean Macth() {
        return false;
    }
}
