001    package railo.runtime.debug;
002    
003    import railo.runtime.PageSource;
004    import railo.runtime.op.Caster;
005    
006    public abstract class DebugEntrySupport implements DebugEntry {
007    
008            private static final long serialVersionUID = -2495816599745340388L;
009    
010            private static int _id=1;
011        private String id;
012        
013            private long exeTime;
014            private String path;
015        private int count=1;
016        private long min=0;
017        private long max=0;
018            
019    
020            /**
021             * constructor of the class
022             * @param source 
023             * @param key 
024             */
025            protected DebugEntrySupport(PageSource source) {
026                    this.path=source==null?"":source.getDisplayPath();
027                    id=Caster.toString(++_id);
028            }
029            
030        
031        @Override
032            public long getExeTime() {
033                    return positiv(exeTime);
034            }
035        
036        @Override
037            public void updateExeTime(long exeTime) {
038                    if(exeTime>=0) {
039                if(count==1 || min>exeTime)min=exeTime;
040                if(max<exeTime)max=exeTime;
041                
042                this.exeTime += exeTime;
043            }
044            }
045        
046        @Override
047            public String getPath() {
048            return path;
049        }
050    
051        @Override
052            public String getId() {
053                    return id;
054            }
055        
056        /**
057         * increment the inner counter
058         */
059        protected void countPP() {
060            count++;
061            
062        }
063        
064        @Override
065            public int getCount() {
066            return count;
067        }
068        
069        @Override
070            public long getMax() {
071            return positiv(max);
072        }
073        
074        @Override
075            public long getMin() {
076            return positiv(min);
077        }
078        
079        protected long positiv(long time) {
080            if(time<0)return 0;
081            return time;
082        }
083    
084    }