|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream com.sun.faban.harness.webclient.XMLInputStream
public class XMLInputStream
The XML input stream rudimentary parses an xml input file for completion. It checks that the outermost element is properly closed. Otherwise the stream will not end.
Nested Class Summary | |
---|---|
static interface |
XMLInputStream.EOFListener
A listener to listen to end-of-file events of XMLInputStream. |
Field Summary |
---|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
XMLInputStream(File file)
Creates a FileInputStream by
opening a connection to an actual file,
the file named by the File
object file in the file system. |
|
XMLInputStream(FileDescriptor fdObj)
Creates a FileInputStream by using the file descriptor
fdObj , which represents an existing connection to an
actual file in the file system. |
|
XMLInputStream(String name)
Creates a XMLInputStream by
opening a connection to an actual file,
the file named by the path name name
in the file system. |
Method Summary | |
---|---|
void |
addEOFListener(XMLInputStream.EOFListener listener)
Adds the EOF listener. |
void |
mark(int readlimit)
Marks the current position in this input stream. |
boolean |
markSupported()
Tests if this input stream supports the mark
and reset methods. |
int |
read()
Reads a byte of data from this input stream. |
int |
read(byte[] b)
Reads up to byte.length bytes of data from this
input stream into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this input stream
into an array of bytes. |
void |
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream. |
long |
skip(long n)
This method actually reads the skipped bytes from the stream. |
Methods inherited from class java.io.FilterInputStream |
---|
available, close |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLInputStream(String name) throws FileNotFoundException
XMLInputStream
by
opening a connection to an actual file,
the file named by the path name name
in the file system. A new FileDescriptor
object is created to represent this file
connection.
First, if there is a security
manager, its checkRead
method
is called with the name
argument
as its argument.
If the named file does not exist, is a directory rather than a regular
file, or for some other reason cannot be opened for reading then a
FileNotFoundException
is thrown.
name
- the system-dependent file name.
FileNotFoundException
- if the file does not exist,
is a directory rather than a regular file,
or for some other reason cannot be opened for
reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access
to the file.SecurityManager.checkRead(String)
public XMLInputStream(File file) throws FileNotFoundException
FileInputStream
by
opening a connection to an actual file,
the file named by the File
object file
in the file system.
A new FileDescriptor
object
is created to represent this file connection.
First, if there is a security manager,
its checkRead
method is called
with the path represented by the file
argument as its argument.
If the named file does not exist, is a directory rather than a regular
file, or for some other reason cannot be opened for reading then a
FileNotFoundException
is thrown.
file
- the file to be opened for reading.
FileNotFoundException
- if the file does not exist,
is a directory rather than a regular file,
or for some other reason cannot be opened for
reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the file.File.getPath()
,
SecurityManager.checkRead(String)
public XMLInputStream(FileDescriptor fdObj)
FileInputStream
by using the file descriptor
fdObj
, which represents an existing connection to an
actual file in the file system.
If there is a security manager, its checkRead
method is
called with the file descriptor fdObj
as its argument to
see if it's ok to read the file descriptor. If read access is denied
to the file descriptor a SecurityException
is thrown.
If fdObj
is null then a NullPointerException
is thrown.
fdObj
- the file descriptor to be opened for reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the
file descriptor.SecurityManager.checkRead(java.io.FileDescriptor)
Method Detail |
---|
public void addEOFListener(XMLInputStream.EOFListener listener)
listener
- The listener to addpublic int read() throws IOException
read
in class FilterInputStream
-1
if the end of the
file is reached.
IOException
- if an I/O error occurs.public int read(byte[] b) throws IOException
byte.length
bytes of data from this
input stream into an array of bytes. This method blocks until some
input is available.
This method simply performs the call
read(b, 0, b.length)
and returns
the result. It is important that it does
not do in.read(b)
instead;
certain subclasses of FilterInputStream
depend on the implementation strategy actually
used.
read
in class FilterInputStream
b
- the buffer into which the data is read.
-1
if there is no more data because the end of
the stream has been reached.
IOException
- if an I/O error occurs.FilterInputStream.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from this input stream
into an array of bytes. If len
is not zero, the method
blocks until some input is available; otherwise, no
bytes are read and 0
is returned.
read
in class FilterInputStream
b
- the buffer into which the data is read.off
- the start offset in the destination array b
len
- the maximum number of bytes read.
-1
if there is no more data because the end of
the file has been reached.
NullPointerException
- If b
is null
.
IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is greater than
b.length - off
IOException
- if an I/O error occurs.public boolean markSupported()
mark
and reset
methods.
This method always returns false. Mark is not supported in
XMLInputStream.
markSupported
in class FilterInputStream
true
if this stream type supports the
mark
and reset
method;
false
otherwise.FilterInputStream.in
,
InputStream.mark(int)
,
InputStream.reset()
public long skip(long n) throws IOException
skip
in class FilterInputStream
IOException
public void mark(int readlimit)
reset
method repositions this stream at
the last marked position so that subsequent reads re-read the same bytes.
The readlimit
argument tells this input stream to
allow that many bytes to be read before the mark position gets
invalidated.
Since mark is not supported in XMLInputStream, this method is a NOOP.
mark
in class FilterInputStream
readlimit
- the maximum limit of bytes that can be read before
the mark position becomes invalid.FilterInputStream.in
,
FilterInputStream.reset()
public void reset() throws IOException
mark
method was last called on this input stream.
This method
simply performs in.reset()
.
Stream marks are intended to be used in
situations where you need to read ahead a little to see what's in
the stream. Often this is most easily done by invoking some
general parser. If the stream is of the type handled by the
parse, it just chugs along happily. If the stream is not of
that type, the parser should toss an exception when it fails.
If this happens within readlimit bytes, it allows the outer
code to reset the stream and try another parser.
reset
in class FilterInputStream
IOException
- if the stream has not been marked or if the
mark has been invalidated.FilterInputStream.in
,
FilterInputStream.mark(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |