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;
020
021import java.io.IOException;
022
023import lucee.commons.io.res.Resource;
024import lucee.runtime.config.ConfigWeb;
025import lucee.runtime.exp.PageException;
026
027/**
028 * extends the source file with class features 
029 */
030public interface PageSource extends SourceFile {
031
032    /**
033     * loads the Page from this PageSource
034     * @param config
035     * @return page Loaded
036     * @throws PageException
037     */
038    public abstract Page loadPage(ConfigWeb config) throws PageException;
039    
040    public abstract Page loadPage(PageContext pc) throws PageException;
041    
042    /**
043     * loads the Page from this PageSource
044     * @param config
045     * @param defaultValue
046     * @return Page loaded
047     * @throws PageException 
048     */
049    public abstract Page loadPage(ConfigWeb config, Page defaultValue) throws PageException;
050        public abstract Page loadPage(PageContext pc, Page defaultValue) throws PageException;
051    
052    /**
053     * returns the ralpath without the mapping
054     * @return Returns the relpath.
055     */
056    public abstract String getRealpath();
057
058    /**
059     * Returns the full name (mapping/relpath).
060     * @return mapping/relpath
061     */
062    public abstract String getFullRealpath();
063
064    /**
065     * @return returns the full class name (Example: lucee.web.test_cfm)
066     */
067    public abstract String getClazz();
068
069    /**
070     * @return return the file name of the source file (test.cfm)
071     */
072    public abstract String getFileName();
073
074    /**
075     * if the pageSource is based on a archive, Lucee returns the ra:// path
076     * @return return the Resource matching this PageSource
077     */
078    public abstract Resource getResource();
079    
080
081    /**
082     * if the pageSource is based on a archive, translate the source to a zip:// Resource
083     * @return return the Resource matching this PageSource
084     * @param pc the Page Context Object
085     */
086    public abstract Resource getResourceTranslated(PageContext pc) throws PageException;
087
088    /**
089     * @return returns the a classname matching to filename (Example: /lucee/web/test_cfm)
090     */
091    public abstract String getJavaName();
092
093    /**
094     * @return returns the a package matching to file (Example: lucee.web)
095     */
096    public abstract String getComponentName();
097
098    /**
099     * @return returns mapping where PageSource based on
100     */
101    public abstract Mapping getMapping();
102
103    /**
104     * @return returns if page source exists or not
105     */
106    public abstract boolean exists();
107
108    /**
109     * @return returns if the physical part of the source file exists
110     */
111    public abstract boolean physcalExists();
112
113    /**
114     * @return return the sozrce of the file as String array
115     * @throws IOException
116     */
117    public abstract String[] getSource() throws IOException;
118
119    /**
120     * get an new Pagesoure from ralpath
121     * @param relPath
122     * @return new Pagesource
123     */
124    public abstract PageSource getRealPage(String relPath);
125
126    /**
127     * sets time last accessed page
128     * @param lastAccess time ast accessed
129     */
130    public abstract void setLastAccessTime(long lastAccess);
131
132    /**
133     * 
134     * @return returns time last accessed page
135     */
136    public abstract long getLastAccessTime();
137
138    /**
139     * set time last accessed (now)
140     */
141    public abstract void setLastAccessTime();
142
143    /**
144     * @return returns how many this page is accessed since server is in use.
145     */
146    public abstract int getAccessCount();
147
148}