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
023public class DebugEntryTemplatePartImpl extends DebugEntrySupport implements DebugEntryTemplatePart {
024
025        private int startPos, startLine;
026        private int endPos, endLine;
027        private String snippet = "";
028
029        protected DebugEntryTemplatePartImpl(PageSource source, int startPos, int endPos) {
030                super(source);
031                this.startPos=startPos;
032                this.endPos=endPos;
033        }
034
035        protected DebugEntryTemplatePartImpl(PageSource source, int startPos, int endPos, int startLine, int endLine, String snippet) {
036                super(source);
037                this.startPos=startPos;
038                this.endPos=endPos;
039                this.startLine = startLine;
040                this.endLine = endLine;
041                this.snippet = snippet;
042        }
043
044        @Override
045        public String getSrc() {
046                return getSrc(getPath(),startPos,endPos);
047        }
048
049        @Override
050        public int getStartPosition() {
051                return startPos;
052        }
053
054        @Override
055        public int getEndPosition() {
056                return endPos;
057        }
058        
059        static String getSrc(String path, int startPos, int endPos) {
060        return path+":"+startPos+" - "+endPos;
061    }
062
063    public int getStartLine() {
064        return startLine;
065    }
066
067    public int getEndLine() {
068        return endLine;
069    }
070
071    public String getSnippet() {
072        return snippet;
073    }
074}