// Job: Jay's Own Browser, a web browser written in Java by Jay Skeer // Copyright (C) 1996 Jay Skeer, Jay Prime Positive // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // import java.io.*; import HtmlComponentStream; public class HtmlDocumentStream { HtmlComponentStream hcs; boolean eof; /** given a url (currently file name) return an HtmlDocumentStream */ public HtmlDocumentStream(String url) throws IOException { hcs= new HtmlComponentStream(url); eof= hcs.eof(); } /** given a url (currently file name) return an HtmlDocumentStream */ public HtmlDocumentStream(File url) throws IOException { hcs= new HtmlComponentStream(url); eof= hcs.eof(); } public boolean eof() { return (eof || hcs.eof()); } /** close the stream */ public void close() throws IOException { eof= true; hcs.close(); } /** returns the next HtmlComponent from the stream. */ public HtmlDocument readHtmlDocument() { //Jdb.enter("HCS.readHtmlDoc()"); HtmlDocument rv= null; if (! hcs.eof()) { HtmlComponent tv= hcs.readHtmlComponent(); if (HtmlComponent.HTML == tv.id) { rv= new HtmlDocument(tv); } else { rv= new HtmlDocument(); rv.add(tv); } while (! hcs.eof()) { rv.add(hcs.readHtmlComponent()); } } else { /* return EOF document??? */ } //Jdb.exit("HD.readHtmlDoc() == " + rv.toString()); return(rv); } }