001 /** 002 * Implements the CFML Function ljustify 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 LJustify implements Function { 011 public static String call(PageContext pc , String str, double length) throws ExpressionException { 012 int len=(int) length; 013 if(len<1) throw new ExpressionException("Parameter 2 of function lJustify which is now ["+len+"] must be a positive integer"); 014 else if((len-=str.length())<=0) return str; 015 else { 016 StringBuffer sb=new StringBuffer(str.length()+len); 017 sb.append(str); 018 for(int i=1;i<=len;i++) { 019 //str+=" "; 020 sb.append(' '); 021 } 022 return sb.toString(); 023 } 024 } 025 }