001    package railo.runtime.debug;
002    
003    import railo.runtime.PageSource;
004    
005    
006    /**
007     * a single debug entry
008     */
009    public final class DebugEntryTemplateImpl extends DebugEntrySupport implements DebugEntryTemplate {
010            
011            private static final long serialVersionUID = 809949164432900481L;
012            
013            private long fileLoadTime;
014            private String key;
015        private long queryTime;
016    
017            /**
018             * constructor of the class
019             * @param source 
020             * @param key 
021             */
022        protected DebugEntryTemplateImpl(PageSource source, String key) {
023            super(source);
024                    this.key=key;
025            }
026    
027        
028        @Override
029            public long getFileLoadTime() {
030            return positiv(fileLoadTime);
031            }
032    
033        @Override
034            public void updateFileLoadTime(long fileLoadTime) {
035                    if(fileLoadTime>0)this.fileLoadTime+= fileLoadTime;
036            }
037        
038        @Override
039            public void updateQueryTime(long queryTime) {
040            if(queryTime>0)this.queryTime+=queryTime;
041        }
042        
043        @Override
044            public String getSrc() {
045            return getSrc(getPath(),key);
046        }
047        
048        /**
049         * @param source 
050         * @param key 
051         * @return Returns the src.
052         */
053        static String getSrc(String path, String key) {
054            return 
055                    path
056                +
057                (key==null?"":"$"+key);
058        }
059        
060        @Override
061            public long getQueryTime() {
062            return positiv(queryTime);
063        }
064        
065        @Override
066            public void resetQueryTime() {
067            this.queryTime=0;
068        }
069    }