Package org.w3c.tidy

Class PPrint


  • public class PPrint
    extends java.lang.Object
    Pretty print parse tree. Block-level and unknown elements are printed on new lines and their contents indented 2 spaces Inline elements are printed inline. Inline content is wrapped on spaces (except in attribute values or preformatted text, after start tags and before end tags.
    Version:
    $Revision$ ($Author$)
    Author:
    Dave Raggett dsr@w3.org , Andy Quick ac.quick@sympatico.ca (translation to Java), Fabrizio Giustina
    • Constructor Summary

      Constructors 
      Constructor Description
      PPrint​(Configuration configuration)
      Instantiates a new PPrint.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTransitionEffect​(Lexer lexer, Node root, double duration)
      Add meta element for page transition effect, this works on IE but not NS.
      void condFlushLine​(Out fout, int indent)
      Conditional flush the line.
      void condFlushLine​(Out fout, int indent, boolean shouldAddNewLine)
      Conditional flush the line.
      int countSlides​(Node node)
      Split parse tree by h2 elements and output to separate files.
      void createSlides​(Lexer lexer, Node root)
      Creates slides from h2.
      void flushLine​(Out fout, int indent)
      Flush the line.
      void flushLine​(Out fout, int indent, boolean shouldAddNewLine)
      Flush the line.
      static int getUTF8​(byte[] str, int start, int[] ch)
      Return one less than the number of bytes used by the UTF-8 byte sequence.
      void printSlide​(Out fout, short mode, int indent, Lexer lexer)
      Called from printTree to print the content of a slide from the node slide content.
      void printTree​(Out fout, short mode, int indent, Lexer lexer, Node node)  
      void printXMLTree​(Out fout, short mode, int indent, Lexer lexer, Node node)  
      static int putUTF8​(byte[] buf, int start, int c)
      Store char c as UTF-8 encoded byte stream.
      • Methods inherited from class java.lang.Object

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

      • PPrint

        public PPrint​(Configuration configuration)
        Instantiates a new PPrint.
        Parameters:
        configuration - configuration
    • Method Detail

      • getUTF8

        public static int getUTF8​(byte[] str,
                                  int start,
                                  int[] ch)
        Return one less than the number of bytes used by the UTF-8 byte sequence. The Unicode char is returned in ch.
        Parameters:
        str - points to the UTF-8 byte sequence
        start - starting offset in string
        ch - initialised to 1st byte, passed as an array to allow modification
        Returns:
        one less that the number of bytes used by UTF-8 char
      • putUTF8

        public static int putUTF8​(byte[] buf,
                                  int start,
                                  int c)
        Store char c as UTF-8 encoded byte stream.
        Parameters:
        buf - the buffer
        start - the start offset
        c - the char
        Returns:
        the current position
      • flushLine

        public void flushLine​(Out fout,
                              int indent,
                              boolean shouldAddNewLine)
        Flush the line.
        Parameters:
        fout - where to write output
        indent - the indent amount
        shouldAddNewLine - true to add new line after flush
      • flushLine

        public void flushLine​(Out fout,
                              int indent)
        Flush the line.
        Parameters:
        fout - where to write output
        indent - the indent amount
      • condFlushLine

        public void condFlushLine​(Out fout,
                                  int indent,
                                  boolean shouldAddNewLine)
        Conditional flush the line.
        Parameters:
        fout - where to write output
        indent - the indent amount
        shouldAddNewLine - true to add new line after flush
      • condFlushLine

        public void condFlushLine​(Out fout,
                                  int indent)
        Conditional flush the line.
        Parameters:
        fout - where to write output
        indent - the indent amount
      • printTree

        public void printTree​(Out fout,
                              short mode,
                              int indent,
                              Lexer lexer,
                              Node node)
        Parameters:
        fout - where to write output
        mode - the mode to use
        indent - the indent amount
        lexer - the Lexer to use
        node - the node to use
      • printXMLTree

        public void printXMLTree​(Out fout,
                                 short mode,
                                 int indent,
                                 Lexer lexer,
                                 Node node)
        Parameters:
        fout - where to write output
        mode - the mode to use
        indent - the indent amount
        lexer - the Lexer to use
        node - the node to use
      • countSlides

        public int countSlides​(Node node)
        Split parse tree by h2 elements and output to separate files. Counts number of h2 children (if any) belonging to node.
        Parameters:
        node - root node
        Returns:
        number of slides (number of h2 elements)
      • printSlide

        public void printSlide​(Out fout,
                               short mode,
                               int indent,
                               Lexer lexer)
        Called from printTree to print the content of a slide from the node slide content. On return slide content points to the node starting the next slide or null. The variables slide and count are used to customise the navigation bar.
        Parameters:
        fout - where to write output
        mode - the mode to use
        indent - the indent amount
        lexer - the Lexer to use
      • addTransitionEffect

        public void addTransitionEffect​(Lexer lexer,
                                        Node root,
                                        double duration)
        Add meta element for page transition effect, this works on IE but not NS.
        Parameters:
        lexer - the Lexer instance to use
        root - the root node
        duration - transition duration
      • createSlides

        public void createSlides​(Lexer lexer,
                                 Node root)
        Creates slides from h2.
        Parameters:
        lexer - Lexer
        root - root node