Package org.boris.expr.function.excel

Source Code of org.boris.expr.function.excel.LEFT

package org.boris.expr.function.excel;

import org.boris.expr.Expr;
import org.boris.expr.ExprException;
import org.boris.expr.ExprString;
import org.boris.expr.function.AbstractFunction;

public class LEFT extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertMinArgCount(args, 1);
        assertMaxArgCount(args, 2);
        String str = asString(args[0], false);
        int r = 1;
        if (args.length == 2) {
            r = asInteger(args[1], true);
        }
        if (r > str.length())
            r = str.length();
        return new ExprString(str.substring(0, r));
    }
}
TOP

Related Classes of org.boris.expr.function.excel.LEFT

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.