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.util; 020 021import java.io.File; 022import java.io.InputStream; 023import java.io.OutputStream; 024import java.io.Serializable; 025import java.util.Map; 026 027import javax.servlet.http.Cookie; 028import javax.servlet.http.HttpServletRequest; 029import javax.servlet.http.HttpServletResponse; 030import javax.servlet.http.HttpSession; 031 032import lucee.commons.io.res.Resource; 033import lucee.runtime.Component; 034import lucee.runtime.PageContext; 035import lucee.runtime.config.RemoteClient; 036import lucee.runtime.db.DatasourceConnection; 037import lucee.runtime.db.SQL; 038import lucee.runtime.exp.PageException; 039import lucee.runtime.spooler.ExecutionPlan; 040import lucee.runtime.spooler.SpoolerTask; 041import lucee.runtime.type.Array; 042import lucee.runtime.type.Collection; 043import lucee.runtime.type.Collection.Key; 044import lucee.runtime.type.Query; 045import lucee.runtime.type.Struct; 046import lucee.runtime.type.dt.Date; 047import lucee.runtime.type.dt.DateTime; 048import lucee.runtime.type.dt.Time; 049import lucee.runtime.type.dt.TimeSpan; 050import lucee.runtime.type.scope.ClusterEntry; 051 052import org.w3c.dom.Document; 053 054/** 055 * Creation of different Objects 056 */ 057public interface Creation { 058 059 /** 060 * creates and returns a array instance 061 * @return array 062 */ 063 public abstract Array createArray(); 064 065 066 /** 067 * creates and returns a array based on a string list 068 * @return array 069 */ 070 public abstract Array createArray(String list, String delimiter,boolean removeEmptyItem,boolean trim); 071 072 /** 073 * creates and returns a DateTime instance 074 * @param time 075 * @return DateTime 076 */ 077 public abstract DateTime createDateTime(long time); 078 079 /** 080 * creates and returns a DateTime instance 081 * @param year 082 * @param month 083 * @param day 084 * @param hour 085 * @param minute 086 * @param seond 087 * @param millis 088 * @return DateTime 089 */ 090 public abstract DateTime createDateTime(int year,int month,int day,int hour,int minute,int seond,int millis) throws PageException; 091 092 /** 093 * creates and returns a Date instance 094 * @param time 095 * @return DateTime 096 */ 097 public abstract Date createDate(long time); 098 099 /** 100 * creates and returns a Date instance 101 * @param year 102 * @param month 103 * @param day 104 * @return DateTime 105 */ 106 public abstract Date createDate(int year,int month,int day) throws PageException; 107 108 /** 109 * creates and returns a Time instance 110 * @param time 111 * @return DateTime 112 */ 113 public abstract Time createTime(long time); 114 115 /** 116 * creates and returns a Time instance 117 * @param hour 118 * @param minute 119 * @param second 120 * @param millis 121 * @return DateTime 122 */ 123 public abstract Time createTime(int hour,int minute,int second,int millis); 124 125 /** 126 * creates and returns a TimeSpan instance 127 * @param day 128 * @param hour 129 * @param minute 130 * @param second 131 * @return TimeSpan 132 */ 133 public abstract TimeSpan createTimeSpan(int day,int hour,int minute,int second); 134 135 /** 136 * creates and returns a array instance 137 * @param dimension 138 * @return array 139 * @throws PageException 140 */ 141 public abstract Array createArray(int dimension) throws PageException; 142 143 /** 144 * creates and returns a struct instance 145 * @return struct 146 */ 147 public abstract Struct createStruct(); 148 149 public abstract Struct createStruct(int type); 150 151 // FUTURE public abstract Struct createStruct(String type); 152 153 /** 154 * creates a query object with given data 155 * @param columns 156 * @param rows 157 * @param name 158 * @return created query Object 159 * @deprecated usse instead <code>createQuery(Collection.Key[] columns, int rows, String name)</code> 160 */ 161 public abstract Query createQuery(String[] columns, int rows, String name); 162 163 /** 164 * creates a query object with given data 165 * @param columns 166 * @param rows 167 * @param name 168 * @return created query Object 169 */ 170 public abstract Query createQuery(Collection.Key[] columns, int rows, String name) throws PageException; 171 172 /** 173 * creates a query object with a resultset from a sql query 174 * @param dc Connection to a database 175 * @param name 176 * @param sql sql to execute 177 * @param maxrow maxrow for the resultset 178 * @throws PageException 179 * @deprecated replaced with <code>{@link #createQuery(DatasourceConnection, SQL, int, int, int, String)}</code> 180 */ 181 public abstract Query createQuery(DatasourceConnection dc,SQL sql,int maxrow, String name) throws PageException; 182 183 /** 184 * @param dc Connection to a database 185 * @param sql sql to execute 186 * @param maxrow maxrow for the resultset 187 * @param fetchsize 188 * @param timeout in seconds 189 * @param name 190 * @return created Query 191 * @throws PageException 192 */ 193 public abstract Query createQuery(DatasourceConnection dc,SQL sql,int maxrow, int fetchsize, int timeout,String name) throws PageException; 194 195 196 /** 197 * creates and returns a xml Document instance 198 * @return struct 199 * @throws PageException 200 */ 201 public abstract Document createDocument() throws PageException; 202 203 /** 204 * creates and returns a xml Document instance 205 * @param file 206 * @param isHtml 207 * @return struct 208 * @throws PageException 209 */ 210 public abstract Document createDocument(Resource file, boolean isHtml) throws PageException; 211 212 /** 213 * creates and returns a xml Document instance 214 * @param xml 215 * @param isHtml 216 * @return struct 217 * @throws PageException 218 */ 219 public abstract Document createDocument(String xml, boolean isHtml) throws PageException; 220 221 /** 222 * creates and returns a xml Document instance 223 * @param is 224 * @param isHtml 225 * @return struct 226 * @throws PageException 227 */ 228 public abstract Document createDocument(InputStream is, boolean isHtml) throws PageException; 229 230 /** 231 * creates a collecton Key out of a String 232 * @param key 233 */ 234 public abstract Collection.Key createKey(String key); 235 236 public SpoolerTask createRemoteClientTask(ExecutionPlan[] plans,RemoteClient remoteClient,Struct attrColl,String callerId, String type); 237 238 public ClusterEntry createClusterEntry(Key key,Serializable value, int offset); 239 240 241 public Resource createResource(String path, boolean existing) throws PageException; 242 243 244 public abstract HttpServletRequest createHttpServletRequest(File contextRoot,String serverName, String scriptName,String queryString, 245 Cookie[] cookies, Map<String,Object> headers, Map<String, String> parameters, Map<String,Object> attributes, HttpSession session); 246 247 public abstract HttpServletResponse createHttpServletResponse(OutputStream io); 248 249 250 public abstract PageContext createPageContext(HttpServletRequest req, HttpServletResponse rsp, OutputStream out); 251 252 /** 253 * creates a component object from (Full)Name, for example lucee.extensions.net.HTTPUtil 254 * @param pc Pagecontext for loading the CFC 255 * @param fullname fullanem of the cfc example:lucee.extensions.net.HTTPUtil 256 * @return loaded cfc 257 * @throws PageException 258 */ 259 public abstract Component createComponentFromName(PageContext pc, String fullName) throws PageException; 260 261 /** 262 * creates a component object from a absolute local path, for example /Users/susi/Projects/Sorglos/wwwrooot/lucee/extensions/net/HTTPUtil.cfc 263 * @param pc Pagecontext for loading the CFC 264 * @param path path of the cfc example:/Users/susi/Projects/Sorglos/wwwrooot/lucee/extensions/net/HTTPUtil.cfc 265 * @return loaded cfc 266 * @throws PageException 267 */ 268 public abstract Component createComponentFromPath(PageContext pc, String path) throws PageException; 269 270 271 272 273}