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