001: /*
002: * regain - A file search engine providing plenty of formats
003: * Copyright (C) 2004 Til Schneider
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, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Contact: Til Schneider, info@murfman.de
020: *
021: * CVS information:
022: * $RCSfile$
023: * $Source$
024: * $Date: 2006-04-12 16:44:20 +0200 (Mi, 12 Apr 2006) $
025: * $Author: til132 $
026: * $Revision: 209 $
027: */
028: package net.sf.regain.util.sharedtag;
029:
030: import java.io.OutputStream;
031:
032: import net.sf.regain.RegainException;
033: import net.sf.regain.RegainToolkit;
034: import net.sf.regain.util.io.Printer;
035:
036: /**
037: * A page response.
038: *
039: * @author Til Schneider, www.murfman.de
040: */
041: public abstract class PageResponse implements Printer {
042:
043: /**
044: * Gets the character encoding of the response.
045: *
046: * @return The character encoding of the response.
047: * @throws RegainException If getting th encoding failed.
048: */
049: public abstract String getEncoding() throws RegainException;
050:
051: /**
052: * Sets the header with the given name.
053: *
054: * @param name The name of the header.
055: * @param value The header value to set.
056: * @throws RegainException If getting the header failed.
057: */
058: public abstract void setHeader(String name, String value)
059: throws RegainException;
060:
061: /**
062: * Sets the header with the given name as date.
063: *
064: * @param name The name of the header.
065: * @param value The header value to set.
066: * @throws RegainException If getting the header failed.
067: */
068: public abstract void setHeaderAsDate(String name, long value)
069: throws RegainException;
070:
071: /**
072: * Gets the OutputStream to use for sending binary data.
073: *
074: * @return The OutputStream to use for sending binary data.
075: * @throws RegainException If getting the OutputStream failed.
076: */
077: public abstract OutputStream getOutputStream()
078: throws RegainException;
079:
080: /**
081: * Prints text to a page.
082: *
083: * @param text The text to print.
084: * @throws RegainException If printing failed.
085: */
086: public abstract void print(String text) throws RegainException;
087:
088: /**
089: * Prints text to a page and escapes all HTML tags.
090: *
091: * @param text The text to print.
092: * @throws RegainException If printing failed.
093: */
094: public void printNoHtml(String text) throws RegainException {
095: if (text != null) {
096: text = RegainToolkit.replace(text, "<", "<");
097: text = RegainToolkit.replace(text, ">", ">");
098: }
099:
100: print(text);
101: }
102:
103: /**
104: * Redirects the request to another URL.
105: *
106: * @param url The URL to redirect to.
107: * @throws RegainException If redirecting failed.
108: */
109: public abstract void sendRedirect(String url)
110: throws RegainException;
111:
112: /**
113: * Sends a HTTP error.
114: *
115: * @param errorCode The error code to send.
116: * @throws RegainException If sending the error failed.
117: */
118: public abstract void sendError(int errorCode)
119: throws RegainException;
120:
121: }
|