001 /** 002 * Implements the CFML Function left 003 */ 004 package railo.runtime.functions.string; 005 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.ExpressionException; 008 import railo.runtime.ext.function.Function; 009 010 public final class Left implements Function { 011 public static String call(PageContext pc , String str, double number) throws ExpressionException { 012 int len=(int) number; 013 if(len<1) throw new ExpressionException("parameter 2 of the function left must be a positive number now ["+len+"]"); 014 if(len>=str.length()) return str; 015 return str.substring(0,len); 016 } 017 }