001: /* IXMLReader.java NanoXML/Java
002: *
003: * $Revision: 1421 $
004: * $Date: 2006-03-12 09:32:32 -0700 (Sun, 12 Mar 2006) $
005: * $Name$
006: *
007: * This file is part of NanoXML 2 for Java.
008: * Copyright (C) 2001 Marc De Scheemaecker, All Rights Reserved.
009: *
010: * This software is provided 'as-is', without any express or implied warranty.
011: * In no event will the authors be held liable for any damages arising from the
012: * use of this software.
013: *
014: * Permission is granted to anyone to use this software for any purpose,
015: * including commercial applications, and to alter it and redistribute it
016: * freely, subject to the following restrictions:
017: *
018: * 1. The origin of this software must not be misrepresented; you must not
019: * claim that you wrote the original software. If you use this software in
020: * a product, an acknowledgment in the product documentation would be
021: * appreciated but is not required.
022: *
023: * 2. Altered source versions must be plainly marked as such, and must not be
024: * misrepresented as being the original software.
025: *
026: * 3. This notice may not be removed or altered from any source distribution.
027: */
028:
029: package net.n3.nanoxml;
030:
031: import java.io.FileNotFoundException;
032: import java.io.IOException;
033: import java.io.Reader;
034: import java.net.MalformedURLException;
035:
036: /**
037: * IXMLReader reads the data to be parsed.
038: *
039: * @author Marc De Scheemaecker
040: * @version $Name$, $Revision: 1421 $
041: */
042: public interface IXMLReader {
043:
044: /**
045: * Reads a character.
046: *
047: * @return the character
048: *
049: * @throws java.io.IOException if no character could be read
050: */
051: public char read() throws IOException;
052:
053: /**
054: * Returns true if the current stream has no more characters left to be read.
055: *
056: * @throws java.io.IOException if an I/O error occurred
057: */
058: public boolean atEOFOfCurrentStream() throws IOException;
059:
060: /**
061: * Returns true if there are no more characters left to be read.
062: *
063: * @throws java.io.IOException if an I/O error occurred
064: */
065: public boolean atEOF() throws IOException;
066:
067: /**
068: * Pushes the last character read back to the stream.
069: *
070: * @param ch the character to push back
071: *
072: * @throws java.io.IOException if an I/O error occurred
073: */
074: public void unread(char ch) throws IOException;
075:
076: /**
077: * Returns the line number of the data in the current stream.
078: */
079: public int getLineNr();
080:
081: /**
082: * Opens a stream from a public and system ID.
083: *
084: * @param publicID the public ID, which may be null
085: * @param systemID the system ID, which is never null
086: *
087: * @throws java.net.MalformedURLException if the system ID does not contain a valid URL
088: * @throws java.io.FileNotFoundException if the system ID refers to a local file which does not
089: * exist
090: * @throws java.io.IOException if an error occurred opening the stream
091: */
092: public Reader openStream(String publicID, String systemID)
093: throws MalformedURLException, FileNotFoundException,
094: IOException;
095:
096: /**
097: * Starts a new stream from a Java reader. The new stream is used temporary to read data from.
098: * If that stream is exhausted, control returns to the parent stream.
099: *
100: * @param reader the reader to read the new data from
101: */
102: public void startNewStream(Reader reader);
103:
104: /**
105: * Sets the system ID of the current stream.
106: *
107: * @param systemID the system ID
108: *
109: * @throws java.net.MalformedURLException if the system ID does not contain a valid URL
110: */
111: public void setSystemID(String systemID)
112: throws MalformedURLException;
113:
114: /**
115: * Sets the public ID of the current stream.
116: *
117: * @param publicID the public ID
118: */
119: public void setPublicID(String publicID);
120:
121: /**
122: * Returns the current system ID.
123: */
124: public String getSystemID();
125:
126: /**
127: * Returns the current public ID.
128: */
129: public String getPublicID();
130:
131: }
|