/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package textkeymatcher.service;

import org.apache.commons.lang3.StringUtils;
import textkeymatcher.entity.DefaultColumns;
import textkeymatcher.entity.Columns;

/**
 *
 * @author seraphy
 */
public class SimpleSplitCharColumnSplitter implements ColumnSplitter {
    
    private String splitChar;
    
    public SimpleSplitCharColumnSplitter(String splitChar) {
        this.splitChar = splitChar;
    }

    @Override
    public Columns splitColumns(String line) {
        String[] cols;
        if (StringUtils.isNotEmpty(line)) {
            cols = line.split(splitChar);

        } else {
            cols = new String[] {line};
        }

        return new DefaultColumns(cols);
    }
}

