001 package railo.runtime.functions.math; 002 003 import railo.runtime.PageContext; 004 import railo.runtime.exp.ExpressionException; 005 import railo.runtime.exp.FunctionException; 006 import railo.runtime.ext.function.Function; 007 008 /** 009 * Implements the CFML Function inputbasen 010 */ 011 public final class InputBaseN implements Function { 012 public static double call(PageContext pc , String string, double radix) throws ExpressionException { 013 if(radix<2 || radix>36) 014 throw new FunctionException(pc,"inputBaseN",2,"radix","radix must be between 2 an 36"); 015 016 string=string.trim().toLowerCase(); 017 if(string.startsWith("0x")) string=string.substring(2, string.length()); 018 019 if(string.length()>32) 020 throw new FunctionException(pc,"inputBaseN",1,"string","argument is to large can be a maximum of 32 digits (-0x at start)"); 021 022 //print.ln(string+"-"+radix); 023 return (int)Long.parseLong(string, (int)radix); 024 025 026 027 028 029 } 030 031 032 033 034 }