Class DirectTagReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable
    Direct Known Subclasses:
    EntityDecoder

    public class DirectTagReader
    extends java.io.FilterReader
    A Reader that is aware of embedded tags. An example is processing a JSP page, where java is embededd using "<%...%>". 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

      Fields 
      Modifier and Type Field Description
      static java.util.Map DefaultEscapeMap  
      static char ESCAPE_CHARACTER  
      • Fields inherited from class java.io.FilterReader

        in
      • Fields inherited from class java.io.Reader

        lock
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int basicRead()
      Read from either the read buffer or the underlying stream.
      static java.lang.String escape​(java.lang.String value)  
      protected IDirectTagHandler getHandler()  
      protected boolean isSpecialTag​(java.lang.String tag)  
      int read()
      Read a character until we encounter a tag.
      int read​(char[] cbuf, int off, int len)  
      protected int scanEndTag()  
      protected int scanTag()
      Scan the stream for tagged content.
      protected int scanTagContent()
      Scan the content between start and end tag and process the result.
      void setEndTag​(java.lang.String tag)  
      void setStartTag​(java.lang.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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DefaultEscapeMap

        public static final java.util.Map DefaultEscapeMap
    • Constructor Detail

      • DirectTagReader

        public DirectTagReader​(java.io.Reader pReader,
                               IDirectTagHandler handler,
                               java.lang.Object context)
      • DirectTagReader

        public DirectTagReader​(java.io.Reader pReader,
                               IDirectTagHandler handler,
                               java.lang.Object context,
                               boolean escape)
    • Method Detail

      • escape

        public static java.lang.String escape​(java.lang.String value)
      • basicRead

        protected int basicRead()
                         throws java.io.IOException
        Read from either the read buffer or the underlying stream.
        Returns:
        The next character available frm the read buffer or underlying stream.
        Throws:
        java.io.IOException
      • isSpecialTag

        protected boolean isSpecialTag​(java.lang.String tag)
      • read

        public int read()
                 throws java.io.IOException
        Read a character until we encounter a tag.
        Overrides:
        read in class java.io.FilterReader
        Throws:
        java.io.IOException
        See Also:
        Reader.read()
      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterReader
        Throws:
        java.io.IOException
      • scanEndTag

        protected int scanEndTag()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • scanTag

        protected int scanTag()
                       throws java.io.IOException
        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:
        java.io.IOException
      • scanTagContent

        protected int scanTagContent()
                              throws java.io.IOException
        Scan the content between start and end tag and process the result.
        Throws:
        java.io.IOException
      • setEndTag

        public void setEndTag​(java.lang.String tag)
      • setStartTag

        public void setStartTag​(java.lang.String tag)
      • tagRead

        protected int tagRead()
                       throws java.io.IOException
        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:
        java.io.IOException
      • unread

        protected void unread​(char[] chars,
                              int start,
                              int len)
      • unread

        protected void unread​(int c)