Class JspReader


  • class JspReader
    extends java.lang.Object
    JspReader is an input buffer for the JSP parser. It should allow unlimited lookahead and pushback. It also has a bunch of parsing utility methods for understanding htmlesque thingies.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) java.lang.String getFile​(int fileid)  
      (package private) JspCompilationContext getJspCompilationContext()  
      (package private) java.net.URL getResource​(java.lang.String path)
      Gets the URL for the given path name.
      (package private) java.lang.String getText​(Mark start, Mark stop)  
      (package private) boolean hasMoreInput()  
      private boolean isDelimiter()
      Parse utils - Is current character a token delimiter ? Delimiters are currently defined to be =, >, <, ", and ' or any any space character as defined by isSpace.
      (package private) boolean isSpace()  
      (package private) Mark mark()  
      (package private) boolean matches​(java.lang.String string)
      search the stream for a match to a string
      (package private) boolean matchesETag​(java.lang.String tagName)  
      (package private) boolean matchesETagWithoutLessThan​(java.lang.String tagName)  
      (package private) boolean matchesIgnoreCase​(java.lang.String string)  
      (package private) boolean matchesOptionalSpacesFollowedBy​(java.lang.String s)
      Looks ahead to see if there are optional spaces followed by the given String.
      (package private) int nextChar()  
      (package private) java.lang.String parseToken​(boolean quoted)
      Parse a space delimited token.
      (package private) int peekChar()  
      private boolean popFile()
      Pop a file from the file stack.
      (package private) void pushChar()
      Back up the current cursor by one char, assumes current.cursor > 0, and that the char to be pushed back is not '\n'.
      private void pushFile​(java.lang.String file, java.lang.String encoding, java.io.InputStreamReader reader)
      Push a file (and its associated Stream) on the file stack.
      private int registerSourceFile​(java.lang.String file)
      Register a new source file.
      (package private) void reset​(Mark mark)  
      (package private) void setSingleFile​(boolean val)  
      (package private) int skipSpaces()  
      (package private) Mark skipUntil​(java.lang.String limit)
      Skip until the given string is matched in the stream.
      (package private) Mark skipUntilETag​(java.lang.String tag)
      Skip until the given end tag is matched in the stream.
      (package private) Mark skipUntilIgnoreEsc​(java.lang.String limit)
      Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\'.
      private int unregisterSourceFile​(java.lang.String file)
      Unregister the source file.
      • Methods inherited from class java.lang.Object

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

      • log

        private static java.util.logging.Logger log
      • current

        private Mark current
      • master

        private java.lang.String master
      • sourceFiles

        private java.util.ArrayList<java.lang.String> sourceFiles
      • currFileId

        private int currFileId
      • size

        private int size
      • singleFile

        private boolean singleFile
    • Method Detail

      • getFile

        java.lang.String getFile​(int fileid)
      • pushChar

        void pushChar()
        Back up the current cursor by one char, assumes current.cursor > 0, and that the char to be pushed back is not '\n'.
      • reset

        void reset​(Mark mark)
      • matches

        boolean matches​(java.lang.String string)
                 throws JasperException
        search the stream for a match to a string
        Parameters:
        string - The string to match
        Returns:
        true is one is found, the current position in stream is positioned after the search string, false otherwise, position in stream unchanged.
        Throws:
        JasperException
      • matchesOptionalSpacesFollowedBy

        boolean matchesOptionalSpacesFollowedBy​(java.lang.String s)
                                         throws JasperException
        Looks ahead to see if there are optional spaces followed by the given String. If so, true is returned and those spaces and characters are skipped. If not, false is returned and the position is restored to where we were before.
        Throws:
        JasperException
      • skipUntil

        Mark skipUntil​(java.lang.String limit)
                throws JasperException
        Skip until the given string is matched in the stream. When returned, the context is positioned past the end of the match.
        Parameters:
        s - The String to match.
        Returns:
        A non-null Mark instance (positioned immediately before the search string) if found, null otherwise.
        Throws:
        JasperException
      • skipUntilIgnoreEsc

        Mark skipUntilIgnoreEsc​(java.lang.String limit)
                         throws JasperException
        Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\'. When returned, the context is positioned past the end of the match.
        Parameters:
        s - The String to match.
        Returns:
        A non-null Mark instance (positioned immediately before the search string) if found, null otherwise.
        Throws:
        JasperException
      • skipUntilETag

        Mark skipUntilETag​(java.lang.String tag)
                    throws JasperException
        Skip until the given end tag is matched in the stream. When returned, the context is positioned past the end of the tag.
        Parameters:
        tag - The name of the tag whose ETag () to match.
        Returns:
        A non-null Mark instance (positioned immediately before the ETag) if found, null otherwise.
        Throws:
        JasperException
      • parseToken

        java.lang.String parseToken​(boolean quoted)
                             throws JasperException
        Parse a space delimited token. If quoted the token will consume all characters up to a matching quote, otherwise, it consumes up to the first delimiter character.
        Parameters:
        quoted - If true accept quoted strings.
        Throws:
        JasperException
      • setSingleFile

        void setSingleFile​(boolean val)
      • getResource

        java.net.URL getResource​(java.lang.String path)
                          throws java.net.MalformedURLException
        Gets the URL for the given path name.
        Parameters:
        path - Path name
        Returns:
        URL for the given path name.
        Throws:
        java.net.MalformedURLException - if the path name is not given in the correct form
      • isDelimiter

        private boolean isDelimiter()
                             throws JasperException
        Parse utils - Is current character a token delimiter ? Delimiters are currently defined to be =, >, <, ", and ' or any any space character as defined by isSpace.
        Returns:
        A boolean.
        Throws:
        JasperException
      • registerSourceFile

        private int registerSourceFile​(java.lang.String file)
        Register a new source file. This method is used to implement file inclusion. Each included file gets a unique identifier (which is the index in the array of source files).
        Returns:
        The index of the now registered file.
      • unregisterSourceFile

        private int unregisterSourceFile​(java.lang.String file)
        Unregister the source file. This method is used to implement file inclusion. Each included file gets a uniq identifier (which is the index in the array of source files).
        Returns:
        The index of the now registered file.
      • pushFile

        private void pushFile​(java.lang.String file,
                              java.lang.String encoding,
                              java.io.InputStreamReader reader)
                       throws JasperException,
                              java.io.FileNotFoundException
        Push a file (and its associated Stream) on the file stack. THe current position in the current file is remembered.
        Throws:
        JasperException
        java.io.FileNotFoundException
      • popFile

        private boolean popFile()
                         throws JasperException
        Pop a file from the file stack. The field "current" is retored to the value to point to the previous files, if any, and is set to null otherwise.
        Returns:
        true is there is a previous file on the stck. false otherwise.
        Throws:
        JasperException