Class GenericProxyReader

    • Field Detail

      • DEFAULT_TO_RENAME

        public static final String[] DEFAULT_TO_RENAME
      • DEFAULT_TO_STRIP

        public static final String[] DEFAULT_TO_STRIP
      • DEFAULT_TO_DROP

        public static final String[] DEFAULT_TO_DROP
      • toRename

        protected final Map<String,​String> toRename
        the tag names configuration of the filter reader
      • openTags

        protected Stack<com.composum.sling.core.proxy.GenericProxyReader.TagFilter> openTags
        the stack of handlers for open tags - the tomost handler is used for token reading
      • buffer

        protected char[] buffer
        the buffer filled if a 'look forward' to find a tag name has found no tag to filter out
      • bufferPos

        protected int bufferPos
    • Constructor Detail

      • GenericProxyReader

        public GenericProxyReader​(@NotNull
                                  @NotNull Reader in,
                                  @NotNull
                                  @NotNull String[] toRename,
                                  @NotNull
                                  @NotNull String[] toStrip,
                                  @NotNull
                                  @NotNull String[] toDrop)
        Creates a tag filtering reader to filter out the tags configured as sets of tag names
        Parameters:
        in - the reader to filter during read
        toRename - the set of tag names which should be kept but renamed (e.g. 'html:div' to keep the root)
        toStrip - the set of tag names to 'stripe' - remove the tags around and keep the body of the tags
        toDrop - the set of tag names to 'drop' - remove the tags including their body
      • GenericProxyReader

        public GenericProxyReader​(@NotNull
                                  @NotNull InputStream in,
                                  @NotNull
                                  @NotNull String[] toRename,
                                  @NotNull
                                  @NotNull String[] toStrip,
                                  @NotNull
                                  @NotNull String[] toDrop)
      • GenericProxyReader

        public GenericProxyReader​(@NotNull
                                  @NotNull InputStream in)
      • GenericProxyReader

        public GenericProxyReader​(@NotNull
                                  @NotNull Reader in)
    • Method Detail

      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws IOException
        uses the single token read() method to fill the buffer
        Overrides:
        read in class FilterReader
        Throws:
        IOException
      • read

        public int read()
                 throws IOException
        delegates the read to the current tag handler or to the 'scan' if no such handler is active (the handlers are also using the 'scan' method to find tags inside of open tags)
        Overrides:
        read in class FilterReader
        Throws:
        IOException
      • scan

        protected int scan()
                    throws IOException
        scans the token from the 'original' reader and determines tag starts / ends and the tag names controls the tag handler stack if tags found which should be filtered
        Returns:
        the next token for the readers 'read' method
        Throws:
        IOException
      • next

        protected int next()
                    throws IOException
        Returns:
        the next token from the 'original' reader
        Throws:
        IOException
      • buffer

        protected int buffer​(StringBuilder tagName)
        fills up the buffer with the string builders content and returns a 'tag start' tokone ('<')
      • getFilter

        protected com.composum.sling.core.proxy.GenericProxyReader.TagFilter getFilter​(String tagName)
        Returns:
        the filter to handle the found tag name; 'null' if the tag name is not configured for this filter