com.ibm.wbi
Class MarkPreservedException
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.io.IOException
|
+--com.ibm.wbi.MarkPreservedException
- All Implemented Interfaces:
- java.io.Serializable
- public class MarkPreservedException
- extends java.io.IOException
MarkPreservedException is thrown by
MegInputStream.read() whenever a read is attempted on
a marked, preserved stream and the read would exceed the readlimit
supplied to mark(). The mark is left intact.
This is useful when you want to mark a stream so you can reject a
request later, but you don't have direct control over how many
bytes are read from the stream. If too many bytes are read, the
mark will become invalid and you won't be able to reject the
request anymore. Here is an example:
void handleRequest(RequestEvent e) throws RequestRejectedException {
MegInputStream in = e.getMegInputStream();
MegOutputStream out = e.getMegOutputStream();
HtmlEditor ed = new HtmlEditor(in, out);
// Look for a tag, but if it's not found in the first
// 10k, you really don't want to deal with this document anyway.
in.mark(10000);
in.preserveMark();
HtmlItem item;
try {
item = ed.readUntil("TITLE");
} catch (MarkPreservedException mpe) {
// This happens if ed.readUntil() tries to read more than 10000
// bytes. If preserveMark() had not been called, the
// HtmlEditor would keep reading, the mark would become
// invalid, and you would not be able to reject the request
// anymore.
throw new RequestRejectedException("No in first 10k");
}
// If it did find the tag, now you have it here in "item".
}
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
MarkPreservedException
public MarkPreservedException()
MarkPreservedException
public MarkPreservedException(java.lang.String msg)