001: /* $Id: HTMLDocument.java,v 1.1.1.1 2002/10/02 18:42:54 wastl Exp $ */
002: package net.wastl.webmail.ui.html;
003:
004: import net.wastl.webmail.server.Storage;
005: import java.util.*;
006:
007: /*
008: * HTMLDocument.java
009: *
010: * Created: Wed Feb 3 16:13:20 1999
011: *
012: * Copyright (C) 1999-2000 Sebastian Schaffert
013: *
014: * This program is free software; you can redistribute it and/or
015: * modify it under the terms of the GNU General Public License
016: * as published by the Free Software Foundation; either version 2
017: * of the License, or (at your option) any later version.
018: *
019: * This program is distributed in the hope that it will be useful,
020: * but WITHOUT ANY WARRANTY; without even the implied warranty of
021: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022: * GNU General Public License for more details.
023: *
024: * You should have received a copy of the GNU General Public License
025: * along with this program; if not, write to the Free Software
026: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
027: */
028:
029: /**
030: * WebMail's class for representing HTML Documents.
031: *
032: * @author Sebastian Schaffert
033: * @version $Revision: 1.1.1.1 $
034: */
035: public class HTMLDocument {
036:
037: protected String content;
038: protected HTMLHeader header;
039:
040: protected Hashtable httpheaders;
041:
042: protected int returncode = 200;
043: protected String returnstatus = "OK";
044:
045: public HTMLDocument() {
046: }
047:
048: public HTMLDocument(String title, String content) {
049: header = new HTMLHeader(title);
050: this .content = content;
051: }
052:
053: public HTMLDocument(String title, String cont, String basepath) {
054: this (title, cont);
055:
056: // try {
057: // RE regexp2=new RE("<<BASE>>",RE.REG_ICASE & RE.REG_MULTILINE);
058: // content=regexp2.substituteAll(content,basepath);
059: // } catch(Exception e) {
060: // e.printStackTrace();
061: // }
062: }
063:
064: // public HTMLDocument(String title,Storage loader, String docname) {
065: // this(title,loader.getTextFile(loader.getStringResource(docname,Locale.getDefault()),Locale.getDefault()));
066: // }
067:
068: // public HTMLDocument(String title,Storage loader, String docname, String basepath) {
069: // this(title,loader.getTextFile(loader.getStringResource(docname,Locale.getDefault()),Locale.getDefault()),basepath);
070: // }
071:
072: public void addHTTPHeader(String key, String value) {
073: if (httpheaders == null) {
074: httpheaders = new Hashtable(5);
075: }
076: httpheaders.put(key, value);
077: }
078:
079: public Enumeration getHTTPHeaderKeys() {
080: return httpheaders.keys();
081: }
082:
083: public String getHTTPHeader(String key) {
084: return (String) httpheaders.get(key);
085: }
086:
087: public boolean hasHTTPHeader() {
088: return (httpheaders != null) && !httpheaders.isEmpty();
089: }
090:
091: public int getReturnCode() {
092: return returncode;
093: }
094:
095: public String getReturnStatus() {
096: return returnstatus;
097: }
098:
099: public void setStatus(int code, String status) {
100: returncode = code;
101: returnstatus = status;
102: }
103:
104: public String toString() {
105: return header.toString() + "\r\n" + content;
106: }
107:
108: public int length() {
109: return header.toString().length() + 1 + content.length();
110: }
111: } // HTMLDocument
|