View Javadoc
1 package org.apache.turbine.util; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Turbine" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * "Apache Turbine", nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 import java.io.IOException; 58 import java.io.PrintWriter; 59 import java.util.Hashtable; 60 import java.util.Locale; 61 62 import javax.servlet.ServletConfig; 63 import javax.servlet.ServletContext; 64 import javax.servlet.http.HttpServletRequest; 65 import javax.servlet.http.HttpServletResponse; 66 import javax.servlet.http.HttpSession; 67 68 import org.apache.turbine.om.security.User; 69 70 import org.apache.turbine.util.security.AccessControlList; 71 import org.apache.turbine.util.template.TemplateInfo; 72 73 import org.apache.ecs.Document; 74 import org.apache.ecs.Element; 75 import org.apache.ecs.StringElement; 76 77 /*** 78 * RunData is an interface to run-rime information that is passed 79 * within Turbine. This provides the threading mechanism for the 80 * entire system because multiple requests can potentially come in 81 * at the same time. Thus, there is only one RunData implementation 82 * for each request that is being serviced. 83 * 84 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a> 85 * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a> 86 * @author <a href="mailto:bhoeneis@ee.ethz.ch">Bernie Hoeneisen</a> 87 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a> 88 * @version $Id: RunData.java,v 1.1.1.1 2001/08/16 05:09:40 jvanzyl Exp $ 89 */ 90 public interface RunData 91 { 92 /*** 93 * Gets the parameters. 94 * 95 * @return a parameter parser. 96 */ 97 public ParameterParser getParameters(); 98 99 /*** 100 * Gets the cookies. 101 * 102 * @return a cookie parser. 103 */ 104 public CookieParser getCookies(); 105 106 /*** 107 * Gets the servlet request. 108 * 109 * @return the request. 110 */ 111 public HttpServletRequest getRequest(); 112 113 /*** 114 * Gets the servlet response. 115 * 116 * @return the resposne. 117 */ 118 public HttpServletResponse getResponse(); 119 120 /*** 121 * Gets the servlet session information. 122 * 123 * @return the session. 124 */ 125 public HttpSession getSession(); 126 127 /*** 128 * Gets the servlet configuration used during servlet init. 129 * 130 * @return the configuration. 131 */ 132 public ServletConfig getServletConfig(); 133 134 /*** 135 * Gets the servlet context used during servlet init. 136 * 137 * @return the context. 138 */ 139 public ServletContext getServletContext(); 140 141 /*** 142 * Gets the access control list. 143 * 144 * @return the access control list. 145 */ 146 public AccessControlList getACL(); 147 148 /*** 149 * Sets the access control list. 150 * 151 * @param acl an access control list. 152 */ 153 public void setACL(AccessControlList acl); 154 155 /*** 156 * Checks to see if the page is set. 157 * 158 * @return true if the page is set. 159 */ 160 public boolean isPageSet(); 161 162 /*** 163 * Gets the page. 164 * 165 * @return a document. 166 */ 167 public Document getPage(); 168 169 /*** 170 * Whether or not an action has been defined. 171 * 172 * @return true if an action has been defined. 173 */ 174 public boolean hasAction(); 175 176 /*** 177 * Gets the action. It returns an empty string if null so 178 * that it is easy to do conditionals on it based on the 179 * equalsIgnoreCase() method. 180 * 181 * @return a string, "" if null. 182 */ 183 public String getAction(); 184 185 /*** 186 * Sets the action for the request. 187 * 188 * @param action a atring. 189 */ 190 public void setAction(String action); 191 192 /*** 193 * If the Layout has not been defined by the screen then set the 194 * layout to be "DefaultLayout". The screen object can also 195 * override this method to provide intelligent determination of 196 * the Layout to execute. You can also define that logic here as 197 * well if you want it to apply on a global scale. For example, 198 * if you wanted to allow someone to define layout "preferences" 199 * where they could dynamicially change the layout for the entire 200 * site. 201 * 202 * @return a string. 203 */ 204 public String getLayout(); 205 206 /*** 207 * Set the layout for the request. 208 * 209 * @param layout a string. 210 */ 211 public void setLayout(String layout); 212 213 /*** 214 * Convenience method for a template info that 215 * returns the layout template being used. 216 * 217 * @return a string. 218 */ 219 public String getLayoutTemplate(); 220 221 /*** 222 * Modifies the layout template for the screen. This convenience 223 * method allows for a layout to be modified from within a 224 * template. For example; 225 * 226 * $data.setLayoutTemplate("/NewLayout.vm") 227 * 228 * @param layout a layout template. 229 */ 230 public void setLayoutTemplate(String layout); 231 232 /*** 233 * Whether or not a screen has been defined. 234 * 235 * @return true if a screen has been defined. 236 */ 237 public boolean hasScreen(); 238 239 /*** 240 * Gets the screen to execute. 241 * 242 * @return a string. 243 */ 244 public String getScreen(); 245 246 /*** 247 * Sets the screen for the request. 248 * 249 * @param screen a string. 250 */ 251 public void setScreen(String screen); 252 253 /*** 254 * Convenience method for a template info that 255 * returns the name of the template being used. 256 * 257 * @return a string. 258 */ 259 public String getScreenTemplate(); 260 261 /*** 262 * Sets the screen template for the request. For 263 * example; 264 * 265 * $data.setScreenTemplate("NewScreen.vm") 266 * 267 * @param screen a screen template. 268 */ 269 public void setScreenTemplate(String screen); 270 271 /*** 272 * Gets the character encoding to use for reading template files. 273 * 274 * @return the template encoding or null if not specified. 275 */ 276 public String getTemplateEncoding(); 277 278 /*** 279 * Sets the character encoding to use for reading template files. 280 * 281 * @param encoding the template encoding. 282 */ 283 public void setTemplateEncoding(String encoding); 284 285 /*** 286 * Gets the template info. Creates a new one if needed. 287 * 288 * @return a template info. 289 */ 290 public TemplateInfo getTemplateInfo(); 291 292 /*** 293 * Whether or not a message has been defined. 294 * 295 * @return true if a message has been defined. 296 */ 297 public boolean hasMessage(); 298 299 /*** 300 * Gets the results of an action or another message 301 * to be displayed as a string. 302 * 303 * @return a string. 304 */ 305 public String getMessage(); 306 307 /*** 308 * Sets the message for the request as a string. 309 * 310 * @param msg a string. 311 */ 312 public void setMessage(String msg); 313 314 /*** 315 * Adds the string to message. If message has prior messages from 316 * other actions or screens, this method can be used to chain them. 317 * 318 * @param msg a string. 319 */ 320 public void addMessage(String msg); 321 322 /*** 323 * Gets the results of an action or another message 324 * to be displayed as an ECS string element. 325 * 326 * @return a string element. 327 */ 328 public StringElement getMessageAsHTML(); 329 330 /*** 331 * Sets the message for the request as an ECS element. 332 * 333 * @param msg an element. 334 */ 335 public void setMessage(Element msg); 336 337 /*** 338 * Adds the ECS element to message. If message has prior messages from 339 * other actions or screens, this method can be used to chain them. 340 * 341 * @param msg an element. 342 */ 343 public void addMessage(Element msg); 344 345 /*** 346 * Unsets the message for the request. 347 */ 348 public void unsetMessage(); 349 350 /*** 351 * Gets a FormMessages object where all the messages to the 352 * user should be stored. 353 * 354 * @return a FormMessages. 355 */ 356 public FormMessages getMessages(); 357 358 /*** 359 * Sets the FormMessages object for the request. 360 * 361 * @param msgs A FormMessages. 362 */ 363 public void setMessages(FormMessages msgs); 364 365 /*** 366 * Gets the title of the page. 367 * 368 * @return a string. 369 */ 370 public String getTitle(); 371 372 /*** 373 * Sets the title of the page. 374 * 375 * @param title a string. 376 */ 377 public void setTitle(String title); 378 379 /*** 380 * Checks if a user exists in this session. 381 * 382 * @return true if a user exists in this session. 383 */ 384 public boolean userExists(); 385 386 /*** 387 * Gets the user. 388 * 389 * @return a user. 390 */ 391 public User getUser(); 392 393 /*** 394 * Sets the user. 395 * 396 * @param user a user. 397 */ 398 public void setUser(User user); 399 400 /*** 401 * Attempts to get the user from the session. If it does 402 * not exist, it returns null. 403 * 404 * @return a user. 405 */ 406 public User getUserFromSession(); 407 408 /*** 409 * Allows one to invalidate the user in the default session. 410 * 411 * @return true if user was invalidated. 412 */ 413 public boolean removeUserFromSession(); 414 415 /*** 416 * Checks to see if out is set. 417 * 418 * @return true if out is set. 419 */ 420 public boolean isOutSet(); 421 422 /*** 423 * Gets the print writer. First time calling this 424 * will set the print writer via the response. 425 * 426 * @return a print writer. 427 * @throws IOException. 428 */ 429 public PrintWriter getOut() 430 throws IOException; 431 432 /*** 433 * Declares that output will be direct to the response stream, 434 * even though getOut() may never be called. Useful for response 435 * mechanisms that may call res.getWriter() themselves 436 * (such as JSP.) 437 */ 438 public void declareDirectResponse(); 439 440 /*** 441 * Gets the locale. If it has not already been defined with 442 * setLocale(), then properties named "locale.default.lang" 443 * and "locale.default.country" are checked from the Resource 444 * Service and the corresponding locale is returned. If these 445 * properties are undefined, JVM's default locale is returned. 446 * 447 * @return the locale. 448 */ 449 public Locale getLocale(); 450 451 /*** 452 * Sets the locale. 453 * 454 * @param locale the new locale. 455 */ 456 public void setLocale(Locale locale); 457 458 /*** 459 * Gets the charset. If it has not already been defined with 460 * setCharSet(), then a property named "locale.default.charset" 461 * is checked from the Resource Service and returned. If this 462 * property is undefined, the default charset of the locale 463 * is returned. If the locale is undefined, null is returned. 464 * 465 * @return the name of the charset or null. 466 */ 467 public String getCharSet(); 468 469 /*** 470 * Sets the charset. 471 * 472 * @param charset the name of the new charset. 473 */ 474 public void setCharSet(String charset); 475 476 /*** 477 * Gets the HTTP content type to return. If a charset 478 * has been specified, it is included in the content type. 479 * If the charset has not been specified and the main type 480 * of the content type is "text", the default charset is 481 * included. If the default charset is undefined, but the 482 * default locale is defined and it is not the US locale, 483 * a locale specific charset is included. 484 * 485 * @return the content type or an empty string. 486 */ 487 public String getContentType(); 488 489 /*** 490 * Sets the HTTP content type to return. 491 * 492 * @param ct the new content type. 493 */ 494 public void setContentType(String ct); 495 496 /*** 497 * Gets the redirect URI. If this is set, also make sure to set 498 * the status code to 302. 499 * 500 * @return a string, "" if null. 501 */ 502 public String getRedirectURI(); 503 504 /*** 505 * Sets the redirect uri. If this is set, also make sure to set 506 * the status code to 302. 507 * 508 * @param ruri a string. 509 */ 510 public void setRedirectURI(String ruri); 511 512 /*** 513 * Gets the HTTP status code to return. 514 * 515 * @return the status. 516 */ 517 public int getStatusCode(); 518 519 /*** 520 * Sets the HTTP status code to return. 521 * 522 * @param sc the status. 523 */ 524 public void setStatusCode(int sc); 525 526 /*** 527 * Gets an array of system errors. 528 * 529 * @return a SystemError[]. 530 */ 531 public SystemError[] getSystemErrors(); 532 533 /*** 534 * Adds a critical system error. 535 * 536 * @param err a system error. 537 */ 538 public void setSystemError(SystemError err); 539 540 /*** 541 * Gets JNDI Contexts. 542 * 543 * @return a hashtable. 544 */ 545 public Hashtable getJNDIContexts(); 546 547 /*** 548 * Sets JNDI Contexts. 549 * 550 * @param contexts a hashtable. 551 */ 552 public void setJNDIContexts(Hashtable contexts); 553 554 /*** 555 * Gets the cached server scheme. 556 * 557 * @return a string. 558 */ 559 public String getServerScheme(); 560 561 /*** 562 * Gets the cached server name. 563 * 564 * @return a string. 565 */ 566 public String getServerName(); 567 568 /*** 569 * Gets the cached server port. 570 * 571 * @return an int. 572 */ 573 public int getServerPort(); 574 575 /*** 576 * Gets the cached context path. 577 * 578 * @return a string. 579 */ 580 public String getContextPath(); 581 582 /*** 583 * Gets the cached script name. 584 * 585 * @return a string. 586 */ 587 public String getScriptName(); 588 589 /*** 590 * Gets the server data used by the request. 591 * 592 * @return server data. 593 */ 594 public ServerData getServerData(); 595 596 /*** 597 * Gets the IP address of the client that sent the request. 598 * 599 * @return a string. 600 */ 601 public String getRemoteAddr(); 602 603 /*** 604 * Gets the qualified name of the client that sent the request. 605 * 606 * @return a string. 607 */ 608 public String getRemoteHost(); 609 610 /*** 611 * Get the user agent for the request. 612 * 613 * @return a string. 614 */ 615 public String getUserAgent(); 616 617 /*** 618 * Pulls a user object from the session and increments the access 619 * counter and sets the last access date for the object. 620 */ 621 public void populate(); 622 623 /*** 624 * Saves a user object into the session. 625 */ 626 public void save(); 627 628 /*** 629 * Gets the stack trace if set. 630 * 631 * @return the stack trace. 632 */ 633 public String getStackTrace(); 634 635 /*** 636 * Gets the stack trace exception if set. 637 * 638 * @return the stack exception. 639 */ 640 public Throwable getStackTraceException(); 641 642 /*** 643 * Sets the stack trace. 644 * 645 * @param trace the stack trace. 646 * @param exp the exception. 647 */ 648 public void setStackTrace(String trace, 649 Throwable exp); 650 651 /*** 652 * Gets a table of debug variables. 653 * 654 * @return a hashtable for debug variables. 655 */ 656 public Hashtable getVarDebug(); 657 }

This page was automatically generated by Maven