package com.ch.jedge.jbot.knbase.domain;

import com.changhong.qlib.util.StringUtils;

public class JedgeGdeDomainBlock {
    public final String domainFileName;
    public final String blockContent;
    public final String blockTitle;
    public final int    blockIndex;
    public final String vectorIndex;

    public JedgeGdeDomainBlock(String domainFilePath, int blockIndex, String currentBlockTitle, String blockContent) {
        this.domainFileName = domainFilePath;
        this.blockIndex = blockIndex;
        this.blockTitle = currentBlockTitle;
        this.blockContent = blockContent;
        this.vectorIndex = makeBlockHashId(domainFilePath, blockIndex);
    }

    public String getBlockInfo() {
        return String.format("[%s:%03d.%s]", domainFileName, blockIndex, blockTitle);
    }

    public static String makeBlockHashId(String ldgDomainFileName, int blockIndex) {
        return  StringUtils.getMD5Short(ldgDomainFileName+blockIndex, 31);
    }

}
