001 /** 002 * Implements the CFML Function right 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 Right 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 right must be a positive number now ["+len+"]"); 014 if(len>=str.length()) return str; 015 int l=str.length(); 016 return str.substring(l-len,l); 017 } 018 }