001    /**
002     * Implements the Cold Fusion Function structkeyexists
003     */
004    package railo.runtime.functions.struct;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.ext.function.Function;
008    import railo.runtime.functions.query.QueryColumnExists;
009    import railo.runtime.type.Collection;
010    import railo.runtime.type.CollectionStruct;
011    import railo.runtime.type.KeyImpl;
012    import railo.runtime.type.Query;
013    
014    public final class StructKeyExists implements Function {
015    
016            private static final long serialVersionUID = 7659087310641834209L;
017    
018            public static boolean call(PageContext pc , railo.runtime.type.Struct struct, String key) {
019                    return call(pc, struct, KeyImpl.init(key));
020            }
021            
022            public static boolean call(PageContext pc , railo.runtime.type.Struct struct, Collection.Key key) {
023                    if(struct instanceof CollectionStruct) {
024                            Collection c=((CollectionStruct) struct).getCollection();
025                            if(c instanceof Query) {
026                                    return QueryColumnExists.call(pc, (Query)c, key);
027                            }
028                    }
029                    return struct.containsKey(key) && struct.get(key,null)!=null;// do not change, this has do be this way
030            }
031    }