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.tag;
020
021import lucee.runtime.Mapping;
022import lucee.runtime.PageContext;
023import lucee.runtime.config.ConfigWebImpl;
024import lucee.runtime.customtag.InitFile;
025import lucee.runtime.exp.PageException;
026
027public class CFTagCore extends CFTag {
028
029        private String name;
030        private String filename;
031        private boolean isweb;
032
033
034        /**
035         * @return the name
036         */
037        public String getName() {
038                return name;
039        }
040        /**
041         * @return the filename
042         */
043        public String getFilename() {
044                return filename;
045        }
046
047        
048        public void set__name(String name){
049                this.name=name;
050        }
051        public void set__filename(String filename){
052                this.filename=filename;
053        }
054        public void set__isweb(boolean isweb){
055                this.isweb=isweb;
056        }
057        public InitFile initFile(PageContext pageContext) throws PageException {
058        return createInitFile(pageContext,isweb,filename);
059     
060    }
061        
062        public static InitFile createInitFile(PageContext pageContext,boolean isweb,String filename) {
063        ConfigWebImpl config = (ConfigWebImpl) pageContext.getConfig();
064        Mapping mapping=isweb?config.getTagMapping():config.getServerTagMapping();
065        
066        return new InitFile(
067                        mapping.getPageSource(filename),
068                        filename,
069                        filename.endsWith('.'+config.getCFCExtension()));
070     
071    }
072}