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.tag.TagLib;
016    import railo.transformer.library.tag.TagLibTag;
017    
018    public final class GetTagList implements Function {
019            
020            private static Struct sct;
021            
022    
023            public synchronized static railo.runtime.type.Struct call(PageContext pc) throws PageException {
024                    if(sct==null) {
025                        sct=new StructImpl();
026                            //synchronized(sct) {
027                                    //hasSet=true;
028                                    TagLib[] tlds;
029                                    TagLibTag tag;
030                                    tlds = ((ConfigImpl)pc.getConfig()).getTLDs();
031                                    
032                                    for(int i=0;i<tlds.length;i++) {
033                                        String ns = tlds[i].getNameSpaceAndSeparator();
034                                        
035                                        
036                                            Map tags = tlds[i].getTags();
037                                            Iterator it = tags.keySet().iterator();
038                                            Struct inner=new StructImpl();
039                        sct.set(ns,inner);
040                                            while(it.hasNext()){
041                                                    Object n=it.next();
042                                                    tag = tlds[i].getTag(n.toString());
043                                                    if(tag.getStatus()!=TagLib.STATUS_HIDDEN && tag.getStatus()!=TagLib.STATUS_UNIMPLEMENTED)
044                                                            inner.set(n.toString(),"");
045                                            }
046                                            
047                                    }
048                            //}
049                    }
050                    return sct;
051            }
052    }