package vermilion;

import java.util.ArrayList;

/**
 *
 */
public class PatternTrackNode extends UsefulFileObject
{
    public String columnName;
    public String paramName;
    public int paramType;

    public UsefulFileObjectIntMap commands;

    public PatternTrackNode(String colName, String parName, int parType)
    {
        columnName = colName;
        paramName = parName;
        paramType = parType;
        commands = new UsefulFileObjectIntMap();
    }

    @Override
    public String toString()
    {
        return columnName;
    }

    @Override
    public String getType() { return "COLUMN"; }
    @Override
    public int getVersion() { return 1; }

    @Override
    public UsefulFileObject loadImpl(String str, int version)
    {
        PatternTrackNode node = new PatternTrackNode(null, null, 0);

        ArrayList<String> data = stringToList(str);

        if (data.size() >= 4)
        {
            node.columnName = data.get(0);
            node.paramName = data.get(1);
            node.paramType = Integer.parseInt(data.get(2));
            node.commands = (UsefulFileObjectIntMap) UsefulFileObject.load(data.get(3));
        }

        return node;
    }

    @Override
    public String saveImpl()
    {
        ArrayList<String> strs = new ArrayList<String>();

        strs.add(columnName);
        strs.add(paramName);
        strs.add(String.valueOf(paramType));
        strs.add(commands.save());

        return listToString(strs);
    }
}
