001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.debug; 020 021import lucee.runtime.PageSource; 022 023 024/** 025 * a single debug entry 026 */ 027public final class DebugEntryTemplateImpl extends DebugEntrySupport implements DebugEntryTemplate { 028 029 private static final long serialVersionUID = 809949164432900481L; 030 031 private long fileLoadTime; 032 private String key; 033 private long queryTime; 034 035 /** 036 * constructor of the class 037 * @param source 038 * @param key 039 */ 040 protected DebugEntryTemplateImpl(PageSource source, String key) { 041 super(source); 042 this.key=key; 043 } 044 045 046 @Override 047 public long getFileLoadTime() { 048 return positiv(fileLoadTime); 049 } 050 051 @Override 052 public void updateFileLoadTime(long fileLoadTime) { 053 if(fileLoadTime>0)this.fileLoadTime+= fileLoadTime; 054 } 055 056 @Override 057 public void updateQueryTime(long queryTime) { 058 if(queryTime>0)this.queryTime+=queryTime; 059 } 060 061 @Override 062 public String getSrc() { 063 return getSrc(getPath(),key); 064 } 065 066 /** 067 * @param source 068 * @param key 069 * @return Returns the src. 070 */ 071 static String getSrc(String path, String key) { 072 return 073 path 074 + 075 (key==null?"":"$"+key); 076 } 077 078 @Override 079 public long getQueryTime() { 080 return positiv(queryTime); 081 } 082 083 @Override 084 public void resetQueryTime() { 085 this.queryTime=0; 086 } 087}