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 int
Read from either the read buffer or the underlying stream.static String
protected IDirectTagHandler
protected boolean
isSpecialTag
(String tag) int
read()
Read a character until we encounter a tag.int
read
(char[] cbuf, int off, int len) protected int
protected int
scanTag()
Scan the stream for tagged content.protected int
Scan the content between start and end tag and process the result.void
void
setStartTag
(String tag) protected int
tagRead()
Read the underlying stream until the end tag is encountered.protected void
unread
(char[] chars, int start, int len) protected void
unread
(int c) Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset, skip
Methods 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:
read
in classFilterReader
- Throws:
IOException
- See Also:
-
read
- Overrides:
read
in 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)
-