com.cri.xcat.api
Class XcatInputStream
java.lang.Object
java.io.InputStream
com.cri.xcat.api.XcatInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class XcatInputStream
- extends java.io.InputStream
Extends any InputStream by forcing a input stream to report the end of
reading once a
</xcatresponse>
tag is read in. After this point, all other read
calls
will return a -1
(signifying the end of the stream).
This class is useful when attempting to use a SAX parser on the XML response
from the xCAT daemon. By default, a SAX handler will attempt to read even
after the entire XML response is read in (because the handler has no idea the
entire message has been received). This would result in the socket attempting
to read after there is no more data left, causing a timeout on the socket and
an error being thrown. This class fixes this problem by searching for the end
response tag and forcing a end of stream after that tag.
This class, as well as the other types of InputStream classes uses the
decorator design pattern to add specific functionality to an input stream.
- Author:
- Scott Brown
Constructor Summary |
XcatInputStream(java.io.InputStream stream)
The constructor for this class must include an input stream to decorate. |
Method Summary |
int |
read()
|
Methods inherited from class java.io.InputStream |
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XcatInputStream
public XcatInputStream(java.io.InputStream stream)
- The constructor for this class must include an input stream to decorate.
- Parameters:
stream
- The input stream that will be decorated.
read
public int read()
throws java.io.IOException
- Specified by:
read
in class java.io.InputStream
- Throws:
java.io.IOException