001 /** 002 * Implements the Cold Fusion Function structappend 003 */ 004 package railo.runtime.functions.struct; 005 006 import java.util.Iterator; 007 008 import railo.runtime.PageContext; 009 import railo.runtime.exp.PageException; 010 import railo.runtime.ext.function.Function; 011 import railo.runtime.type.Collection.Key; 012 import railo.runtime.type.KeyImpl; 013 import railo.runtime.type.Struct; 014 015 public final class StructAppend implements Function { 016 public static boolean call(PageContext pc , Struct struct1, Struct struct2) throws PageException { 017 return call(pc , struct1, struct2, true); 018 } 019 public static boolean call(PageContext pc , Struct struct1, Struct struct2, boolean overwrite) throws PageException { 020 Iterator it = struct2.keyIterator(); 021 Key key; 022 while(it.hasNext()) { 023 key=KeyImpl.toKey(it.next()); 024 if(overwrite || struct1.get(key,null)==null) 025 struct1.setEL(key,struct2.get(key,null)); 026 } 027 return true; 028 } 029 030 }