All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.n3r.eql.matrix.func.PrefixFunction Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
package org.n3r.eql.matrix.func;


import org.n3r.eql.matrix.MatrixTableFieldValue;

public class PrefixFunction extends SingleFieldBaseFunction {
    protected int prefixSize;


    @Override
    public String apply(MatrixTableFieldValue... fieldValues) {
        String value = find(fieldValues);

        return prefixSize < value.length() ? value.substring(0, prefixSize) : value;
    }

    @Override
    public void configFunctionParameters(String... realFuncParams) {
        if (realFuncParams.length != 1) {
            throw new RuntimeException("prefix/postfix function need only size param");
        }

        prefixSize = Integer.parseInt(realFuncParams[0]);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy