001    /**
002     * Implements the Cold Fusion Function getfunctionlist
003     */
004    package railo.runtime.functions.other;
005    
006    import java.util.Iterator;
007    import java.util.Map;
008    
009    import railo.runtime.PageContext;
010    import railo.runtime.config.ConfigImpl;
011    import railo.runtime.exp.PageException;
012    import railo.runtime.ext.function.Function;
013    import railo.runtime.type.Struct;
014    import railo.runtime.type.StructImpl;
015    import railo.transformer.library.function.FunctionLib;
016    import railo.transformer.library.function.FunctionLibFunction;
017    import railo.transformer.library.tag.TagLib;
018    
019    public final class GetFunctionList implements Function {
020            
021            private static Struct functions;
022            
023            public synchronized static railo.runtime.type.Struct call(PageContext pc) throws PageException {
024                    
025                    
026                    if(functions==null) {
027                            Struct sct=new StructImpl();
028                            //synchronized(sct) {
029                                    //hasSet=true;
030                            FunctionLib[] flds;
031                            flds = ((ConfigImpl)pc.getConfig()).getFLDs();
032                            FunctionLibFunction func;
033                            for(int i=0;i<flds.length;i++) {
034                                    Map functions = flds[i].getFunctions();
035                                    Iterator it = functions.keySet().iterator();
036                                    
037                                    while(it.hasNext()){
038                                            Object n=it.next();
039                                            func = flds[i].getFunction(n.toString());
040                                            if(func.getStatus()!=TagLib.STATUS_HIDDEN && func.getStatus()!=TagLib.STATUS_UNIMPLEMENTED)
041                                                    sct.set(n.toString(),"");
042                                    }
043                            }
044                            functions=sct;
045                            //}
046                    }
047                    return functions;
048            }
049    }