001: /**********************************************************************************
002:
003: Feedzeo!
004: A free and open source RSS/Atom/RDF feed aggregator
005:
006: Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
007:
008: This library is free software; you can redistribute it and/or
009: modify it under the terms of the GNU Lesser General Public
010: License as published by the Free Software Foundation; either
011: version 2.1 of the License, or (at your option) any later version.
012:
013: This library is distributed in the hope that it will be useful,
014: but WITHOUT ANY WARRANTY; without even the implied warranty of
015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: Lesser General Public License for more details.
017:
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
021:
022: ************************************************************************************/package ui;
023:
024: import java.io.*;
025: import java.util.*;
026:
027: import util.*;
028:
029: /**
030: *
031: * @author Anand Rao
032: */
033: public class HTMLPage {
034:
035: /** Creates a new instance of HTMLPage */
036:
037: private PrintWriter File;
038:
039: /// HTML Tags
040: private HTMLTag Page;
041: private HTMLTag Head;
042: private HTMLTag Body;
043:
044: private void initHTMLPage() {
045:
046: Page = new HTMLTag(TagName.PAGE_TAG);
047: Head = new HTMLTag(TagName.HEAD_TAG);
048: HTMLTag title = new HTMLTag(TagName.PAGE_TITLE_TAG);
049: Page.add(title);
050: Page.add(Head);
051: Body = new HTMLTag(TagName.PAGE_BODY_TAG);
052: Page.add(Body);
053: }
054:
055: public HTMLPage(String FileNamePath) {
056: try {
057: File = new PrintWriter(new BufferedWriter(new FileWriter(
058: FileNamePath, false)));
059: initHTMLPage();
060: } catch (Exception e) {
061: ExceptionUtil.reportException(e);
062: }
063: }
064:
065: public void addStyleSheetFile(String FileNamePath) {
066: //System.out.println("StyleSheet:"+FileNamePath);
067: /*
068: * HTML code corresponding to this:
069: * <link rel="stylesheet" type="text/css" href="style.css">
070: */
071: HTMLTag link = new HTMLTag(TagName.LINK_TAG, false);
072: link.addAttribute("rel", "stylesheet");
073: link.addAttribute("type", "text/css");
074: link.addAttribute("href", FileNamePath);
075:
076: Head.add(link);
077: }
078:
079: public void setTableData(String MainData) {
080: Body.add(MainData);
081: }
082:
083: public void writePage() {
084: String Code = Page.toString();
085: try {
086: File.println(Code);
087: } catch (Exception e) {
088: ExceptionUtil.reportException(e);
089: }
090: }
091:
092: public void closePage() {
093: try {
094: File.close();
095: } catch (Exception e) {
096: ExceptionUtil.reportException(e);
097: }
098: }
099:
100: }
|