001    /**
002     * Implements the Cold Fusion Function arrayset
003     */
004    package railo.runtime.functions.arrays;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.exp.ExpressionException;
008    import railo.runtime.exp.PageException;
009    import railo.runtime.ext.function.Function;
010    import railo.runtime.op.Duplicator;
011    import railo.runtime.type.Array;
012    
013    public final class ArraySet implements Function {
014            public static boolean call(PageContext pc , Array array, double from, double to, Object value) throws PageException {
015                    int f=(int) from;
016                    int t=(int) to;
017                    if(f<1)
018                            throw new ExpressionException("second parameter of the function arraySet must be greater than zero, now ["+f+"]");
019                    if(f>t)
020                            throw new ExpressionException("third parameter of the function arraySet must be greater than second parameter now [second:"+f+", third:"+t+"]");
021                    if(array.getDimension()>1)
022                            throw new ExpressionException("function arraySet can only be used with 1 dimensional array, this array has "+array.getDimension()+" dimension");
023            for(int i=f;i<=t;i++) {
024                            array.setE(i,Duplicator.duplicate(value,true));
025                    }
026    
027                    return true;
028            }
029    }