Package de.intarsys.tools.reader
Class DirectTagReader
java.lang.Object
java.io.Reader
java.io.FilterReader
de.intarsys.tools.reader.DirectTagReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Direct Known Subclasses:
EntityDecoder
A
Reader that is aware of embedded tags. An example is processing a
JSP page, where java is embededd using "invalid input: '<'%...%>". After recognizing such a
tag, the associated IDirectTagHandler is informed to handle the tag.
After handling, the result of the IDirectTagHandler is streamd as a
replacement for the tag itself. After streaming the processed tag content,
reading the input continues as normal.-
Field Summary
FieldsFields inherited from class java.io.FilterReader
in -
Constructor Summary
ConstructorsConstructorDescriptionDirectTagReader(Reader pReader, IDirectTagHandler handler, Object context) DirectTagReader(Reader pReader, IDirectTagHandler handler, Object context, boolean escape) -
Method Summary
Modifier and TypeMethodDescriptionprotected intRead from either the read buffer or the underlying stream.static Stringprotected IDirectTagHandlerprotected booleanisSpecialTag(String tag) intread()Read a character until we encounter a tag.intread(char[] cbuf, int off, int len) protected intprotected intscanTag()Scan the stream for tagged content.protected intScan the content between start and end tag and process the result.voidvoidsetStartTag(String tag) protected inttagRead()Read the underlying stream until the end tag is encountered.protected voidunread(char[] chars, int start, int len) protected voidunread(int c) Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset, skipMethods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Field Details
-
ESCAPE_CHARACTER
public static final char ESCAPE_CHARACTER- See Also:
-
DefaultEscapeMap
-
-
Constructor Details
-
DirectTagReader
-
DirectTagReader
-
-
Method Details
-
escape
-
basicRead
Read from either the read buffer or the underlying stream.- Returns:
- The next character available frm the read buffer or underlying stream.
- Throws:
IOException
-
getHandler
-
isSpecialTag
-
read
Read a character until we encounter a tag.- Overrides:
readin classFilterReader- Throws:
IOException- See Also:
-
read
- Overrides:
readin classFilterReader- Throws:
IOException
-
scanEndTag
- Throws:
IOException
-
scanTag
Scan the stream for tagged content. We check the presence of the start tag. If found the stream is read until the presence of the end tag. If the start tag is not completely found, we return the literal stream content.- Returns:
- Throws:
IOException
-
scanTagContent
Scan the content between start and end tag and process the result.- Throws:
IOException
-
setEndTag
-
setStartTag
-
tagRead
Read the underlying stream until the end tag is encountered. When we find the end tag, we return -1, anything else is IOException.- Returns:
- next char from stream between tags
- Throws:
IOException
-
unread
protected void unread(char[] chars, int start, int len) -
unread
protected void unread(int c)
-