/**********************************************************************************
Feedzeo!
A free and open source RSS/Atom/RDF feed aggregator
Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
************************************************************************************/
/*
* HTMLPage.java
*
* Created on August 11, 2005, 10:27 PM
*/
package ui;
import java.io.*;
import java.util.*;
import util.*;
/**
*
* @author Anand Rao
*/
public class HTMLPage {
/** Creates a new instance of HTMLPage */
private PrintWriter File;
/// HTML Tags
private HTMLTag Page;
private HTMLTag Head;
private HTMLTag Body;
private void initHTMLPage() {
Page = new HTMLTag(TagName.PAGE_TAG);
Head = new HTMLTag(TagName.HEAD_TAG);
HTMLTag title = new HTMLTag(TagName.PAGE_TITLE_TAG);
Page.add(title);
Page.add(Head);
Body = new HTMLTag(TagName.PAGE_BODY_TAG);
Page.add(Body);
}
public HTMLPage(String FileNamePath) {
try {
File = new PrintWriter(new BufferedWriter(
new FileWriter(FileNamePath, false)));
initHTMLPage();
} catch (Exception e) {
ExceptionUtil.reportException(e);
}
}
public void addStyleSheetFile(String FileNamePath) {
//System.out.println("StyleSheet:"+FileNamePath);
/*
* HTML code corresponding to this:
* <link rel="stylesheet" type="text/css" href="style.css">
*/
HTMLTag link = new HTMLTag(TagName.LINK_TAG, false);
link.addAttribute("rel", "stylesheet");
link.addAttribute("type", "text/css");
link.addAttribute("href", FileNamePath);
Head.add(link);
}
public void setTableData(String MainData)
{
Body.add(MainData);
}
public void writePage() {
String Code = Page.toString();
try {
File.println(Code);
} catch (Exception e) {
ExceptionUtil.reportException(e);
}
}
public void closePage() {
try {
File.close();
} catch (Exception e) {
ExceptionUtil.reportException(e);
}
}
}
|