com.google.caja.render
Class JsPrettyPrinter

java.lang.Object
  extended by com.google.caja.render.BufferingRenderer
      extended by com.google.caja.render.JsPrettyPrinter
All Implemented Interfaces:
TokenConsumer

public final class JsPrettyPrinter
extends BufferingRenderer

A formatter that indents code for a C-style language with statement delimited by curly brackets, and expression blocks delimited by square brackets and parentheses.

Author:
mikesamuel@gmail.com

Field Summary
private  boolean breakAfterComment
           
private  int lineLengthLimit
           
 
Constructor Summary
JsPrettyPrinter(Concatenator out)
           
 
Method Summary
 int getLineLengthLimit()
           
 boolean isBreakAfterComment()
           
 void setBreakAfterComment(boolean breakAfterComment)
           
 void setLineLengthLimit(int lineLengthLimit)
           
(package private)  java.util.List<java.lang.String> splitTokens(java.util.List<java.lang.Object> tokens)
          Generates a list of output tokens consisting of non-whitespace tokens, space tokens (" ") and newline tokens ('\n' followed by any number of spaces).
 
Methods inherited from class com.google.caja.render.BufferingRenderer
consume, mark, noMoreTokens
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineLengthLimit

private int lineLengthLimit

breakAfterComment

private boolean breakAfterComment
Constructor Detail

JsPrettyPrinter

public JsPrettyPrinter(Concatenator out)
Parameters:
out - receives the rendered text.
Method Detail

setLineLengthLimit

public void setLineLengthLimit(int lineLengthLimit)

getLineLengthLimit

public int getLineLengthLimit()

setBreakAfterComment

public void setBreakAfterComment(boolean breakAfterComment)

isBreakAfterComment

public boolean isBreakAfterComment()

splitTokens

java.util.List<java.lang.String> splitTokens(java.util.List<java.lang.Object> tokens)
Description copied from class: BufferingRenderer
Generates a list of output tokens consisting of non-whitespace tokens, space tokens (" ") and newline tokens ('\n' followed by any number of spaces).

Specified by:
splitTokens in class BufferingRenderer
Parameters:
tokens - a heterogeneous array containing String tokens and FilePosition marks.
Returns:
the strings in tokens in order with newline and space tokens inserted as appropriate.


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0