001    /**
002     * Implements the Cold Fusion Function structcopy
003     */
004    package railo.runtime.functions.struct;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.exp.PageException;
008    import railo.runtime.ext.function.Function;
009    import railo.runtime.type.Array;
010    import railo.runtime.type.Collection;
011    import railo.runtime.type.Struct;
012    
013    public final class StructCopy implements Function {
014            public static Object call(PageContext pc , Struct src) throws PageException {
015                    
016                    Collection trg = src.duplicate(false);
017                    
018                    
019                    Collection.Key[] keys=trg.keys();
020                    Collection.Key key;
021                    Object o;
022                    for(int i=0;i<keys.length;i++) {
023                            key=keys[i];
024                            o=src.get(key,null);
025                            if(o instanceof Array)
026                                    trg.set(key,(((Array)o).duplicate(false)));
027                    }
028                    return trg;
029            }
030    }