001: /* IXMLReader.java NanoXML/Java
002: *
003: * $Revision: 1.17 $
004: * $Date: 2005/01/05 17:20:04 $
005: * $Name: $
006: *
007: * This file is part of NanoXML 2 for Java.
008: * Copyright (C) 2000-2002 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.Reader;
032: import java.io.IOException;
033: import java.io.FileNotFoundException;
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: 1.17 $
041: */
042: public interface IXMLReader {
043:
044: /**
045: * Reads a character.
046: *
047: * @return the character
048: *
049: * @throws java.io.IOException
050: * If no character could be read.
051: */
052: public char read() throws IOException;
053:
054: /**
055: * Returns true if the current stream has no more characters left to be
056: * read.
057: *
058: * @throws java.io.IOException
059: * If an I/O error occurred.
060: */
061: public boolean atEOFOfCurrentStream() throws IOException;
062:
063: /**
064: * Returns true if there are no more characters left to be read.
065: *
066: * @throws java.io.IOException
067: * If an I/O error occurred.
068: */
069: public boolean atEOF() throws IOException;
070:
071: /**
072: * Pushes the last character read back to the stream.
073: *
074: * @param ch the character to push back.
075: *
076: * @throws java.io.IOException
077: * If an I/O error occurred.
078: */
079: public void unread(char ch) throws IOException;
080:
081: /**
082: * Returns the line number of the data in the current stream.
083: */
084: public int getLineNr();
085:
086: /**
087: * Opens a stream from a public and system ID.
088: *
089: * @param publicID the public ID, which may be null.
090: * @param systemID the system ID, which is never null.
091: *
092: * @throws java.net.MalformedURLException
093: * If the system ID does not contain a valid URL.
094: * @throws java.io.FileNotFoundException
095: * If the system ID refers to a local file which does not exist.
096: * @throws java.io.IOException
097: * If an error occurred opening the stream.
098: */
099: public Reader openStream(String publicID, String systemID)
100: throws MalformedURLException, FileNotFoundException,
101: IOException;
102:
103: /**
104: * Starts a new stream from a Java reader. The new stream is used
105: * temporary to read data from. If that stream is exhausted, control
106: * returns to the "parent" stream.
107: *
108: * @param reader the reader to read the new data from.
109: */
110: public void startNewStream(Reader reader);
111:
112: /**
113: * Starts a new stream from a Java reader. The new stream is used
114: * temporary to read data from. If that stream is exhausted, control
115: * returns to the parent stream.
116: *
117: * @param reader the non-null reader to read the new data from
118: * @param isInternalEntity true if the reader is produced by resolving
119: * an internal entity
120: */
121: public void startNewStream(Reader reader, boolean isInternalEntity);
122:
123: /**
124: * Returns the current "level" of the stream on the stack of streams.
125: */
126: public int getStreamLevel();
127:
128: /**
129: * Sets the system ID of the current stream.
130: *
131: * @param systemID the system ID.
132: *
133: * @throws java.net.MalformedURLException
134: * If the system ID does not contain a valid URL.
135: */
136: public void setSystemID(String systemID)
137: throws MalformedURLException;
138:
139: /**
140: * Sets the public ID of the current stream.
141: *
142: * @param publicID the public ID.
143: */
144: public void setPublicID(String publicID);
145:
146: /**
147: * Returns the current system ID.
148: */
149: public String getSystemID();
150:
151: /**
152: * Returns the current public ID.
153: */
154: public String getPublicID();
155:
156: }
|