public class PPrint
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static short |
ATTRIBVALUE
position: attribute value.
|
private static short |
CDATA
position: cdata.
|
private static java.lang.String |
CDATA_END
End cdata token.
|
private static java.lang.String |
CDATA_START
Start cdata token.
|
private static short |
COMMENT
position: comment.
|
private Configuration |
configuration
current configuration.
|
private int |
count
Total slides count.
|
private static java.lang.String |
CSS_COMMENT_END
CSS comment end.
|
private static java.lang.String |
CSS_COMMENT_START
CSS comment start.
|
private static java.lang.String |
DEFAULT_COMMENT_END
Default comment end.
|
private static java.lang.String |
DEFAULT_COMMENT_START
Default comment start.
|
private boolean |
inAttVal |
private boolean |
inString |
private static java.lang.String |
JS_COMMENT_END
Javascript comment end.
|
private static java.lang.String |
JS_COMMENT_START
Javascript comment start.
|
private int |
lbufsize |
private int[] |
linebuf |
private int |
linelen |
private static short |
NORMAL
position: normal.
|
private static short |
NOWRAP
position: nowrap.
|
private static short |
PREFORMATTED
position: preformatted text.
|
private int |
slide
Current slide number.
|
private Node |
slidecontent |
private static java.lang.String |
VB_COMMENT_END
VB comment end.
|
private static java.lang.String |
VB_COMMENT_START
VB comment start.
|
private int |
wraphere |
Constructor and Description |
---|
PPrint(Configuration configuration)
Instantiates a new PPrint.
|
Modifier and Type | Method and Description |
---|---|
private int |
addAsciiString(java.lang.String str,
int index)
Adds an ascii String.
|
private void |
addC(int c,
int index) |
void |
addTransitionEffect(Lexer lexer,
Node root,
double duration)
Add meta element for page transition effect, this works on IE but not NS.
|
private static boolean |
afterSpace(Node node)
Line can be wrapped immediately after inline start tag provided if follows a text node ending in a space, or it
parent is an inline element that that rule applies to.
|
void |
condFlushLine(Out fout,
int indent) |
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.
|
(package private) int |
cWrapLen(int ind) |
void |
flushLine(Out fout,
int indent) |
static int |
getUTF8(byte[] str,
int start,
int[] ch)
return one less than the number of bytes used by the UTF-8 byte sequence.
|
(package private) static boolean |
hasCDATA(Lexer lexer,
Node node)
Does the current node contain a CDATA section?
|
private boolean |
insideHead(Node node)
Is the current node inside HEAD?
|
private void |
printAsp(Out fout,
int indent,
Node node)
note ASP and JSTE share <% ...
|
private void |
printAttribute(Out fout,
int indent,
Node node,
AttVal attr) |
private void |
printAttrs(Out fout,
int indent,
Node node,
AttVal attr) |
private void |
printAttrValue(Out fout,
int indent,
java.lang.String value,
int delim,
boolean wrappable) |
(package private) void |
printBody(Out fout,
Lexer lexer,
Node root,
boolean xml)
Print just the content of the body element.
|
private void |
printCDATA(Out fout,
int indent,
Node node) |
private void |
printChar(int c,
short mode) |
private void |
printComment(Out fout,
int indent,
Node node) |
private void |
printDocType(Out fout,
int indent,
Lexer lexer,
Node node) |
private void |
printEndTag(short mode,
int indent,
Node node) |
private void |
printJste(Out fout,
int indent,
Node node)
JSTE also supports <# ...
|
private void |
printNavBar(Out fout,
int indent) |
private void |
printPhp(Out fout,
int indent,
Node node)
PHP is based on XML processing instructions.
|
private void |
printPI(Out fout,
int indent,
Node node) |
private void |
printScriptStyle(Out fout,
short mode,
int indent,
Lexer lexer,
Node node)
Print script and style elements.
|
private void |
printSection(Out fout,
int indent,
Node node) |
void |
printSlide(Out fout,
short mode,
int indent,
Lexer lexer)
Called from printTree to print the content of a slide from the node slidecontent.
|
private void |
printString(java.lang.String str) |
private void |
printTag(Lexer lexer,
Out fout,
short mode,
int indent,
Node node) |
private void |
printText(Out fout,
short mode,
int indent,
byte[] textarray,
int start,
int end)
The line buffer is uint not char so we can hold Unicode values unencoded.
|
void |
printTree(Out fout,
short mode,
int indent,
Lexer lexer,
Node node) |
private void |
printXmlDecl(Out fout,
int indent,
Node node)
Pretty print the xml declaration.
|
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.
|
private boolean |
shouldIndent(Node node)
Should tidy indent the give tag?
|
private int |
textEndsWithNewline(Lexer lexer,
Node node)
Is text node and already ends w/ a newline? Used to pretty print CDATA/PRE text content.
|
private void |
wrapAttrVal(Out fout,
int indent,
boolean inString) |
private void |
wrapLine(Out fout,
int indent) |
private static final short NORMAL
private static final short PREFORMATTED
private static final short COMMENT
private static final short ATTRIBVALUE
private static final short NOWRAP
private static final short CDATA
private static final java.lang.String CDATA_START
private static final java.lang.String CDATA_END
private static final java.lang.String JS_COMMENT_START
private static final java.lang.String JS_COMMENT_END
private static final java.lang.String VB_COMMENT_START
private static final java.lang.String VB_COMMENT_END
private static final java.lang.String CSS_COMMENT_START
private static final java.lang.String CSS_COMMENT_END
private static final java.lang.String DEFAULT_COMMENT_START
private static final java.lang.String DEFAULT_COMMENT_END
private int[] linebuf
private int lbufsize
private int linelen
private int wraphere
private boolean inAttVal
private boolean inString
private int slide
private int count
private Node slidecontent
private Configuration configuration
public PPrint(Configuration configuration)
configuration
- configurationint cWrapLen(int ind)
ind
- public static int getUTF8(byte[] str, int start, int[] ch)
str
- points to the UTF-8 byte sequencestart
- starting offset in strch
- initialized to 1st byte, passed as an array to allow modificationpublic static int putUTF8(byte[] buf, int start, int c)
buf
- start
- c
- private void addC(int c, int index)
private int addAsciiString(java.lang.String str, int index)
str
- String to be addedindex
- actual line lenghtprivate void wrapLine(Out fout, int indent)
fout
- indent
- private void wrapAttrVal(Out fout, int indent, boolean inString)
fout
- indent
- inString
- public void flushLine(Out fout, int indent)
fout
- indent
- public void condFlushLine(Out fout, int indent)
fout
- indent
- private void printChar(int c, short mode)
c
- mode
- private void printText(Out fout, short mode, int indent, byte[] textarray, int start, int end)
fout
- mode
- indent
- textarray
- start
- end
- private void printString(java.lang.String str)
str
- private void printAttrValue(Out fout, int indent, java.lang.String value, int delim, boolean wrappable)
fout
- indent
- value
- delim
- wrappable
- private void printAttribute(Out fout, int indent, Node node, AttVal attr)
fout
- indent
- node
- attr
- private void printAttrs(Out fout, int indent, Node node, AttVal attr)
fout
- indent
- node
- attr
- private static boolean afterSpace(Node node)
node
- current Nodetrue
if the current char follows a spaceprivate void printTag(Lexer lexer, Out fout, short mode, int indent, Node node)
lexer
- fout
- mode
- indent
- node
- private void printEndTag(short mode, int indent, Node node)
mode
- indent
- node
- private void printComment(Out fout, int indent, Node node)
fout
- indent
- node
- private void printDocType(Out fout, int indent, Lexer lexer, Node node)
fout
- indent
- lexer
- node
- private void printXmlDecl(Out fout, int indent, Node node)
fout
- indent
- node
- private void printAsp(Out fout, int indent, Node node)
fout
- indent
- node
- private void printJste(Out fout, int indent, Node node)
fout
- indent
- node
- private void printPhp(Out fout, int indent, Node node)
fout
- indent
- node
- private void printCDATA(Out fout, int indent, Node node)
fout
- indent
- node
- private void printSection(Out fout, int indent, Node node)
fout
- indent
- node
- private boolean insideHead(Node node)
node
- Nodetrue
if node is inside an HEAD tagprivate int textEndsWithNewline(Lexer lexer, Node node)
lexer
- Lexernode
- text nodestatic boolean hasCDATA(Lexer lexer, Node node)
lexer
- Lexernode
- Nodetrue
if node contains a CDATA sectionprivate void printScriptStyle(Out fout, short mode, int indent, Lexer lexer, Node node)
JavaScript: //<![CDATA[ content //]]> VBScript: '<![CDATA[ content ']]> CSS: /*<![CDATA[* / content /*]]>* / other: <![CDATA[ content ]]>
fout
- mode
- indent
- lexer
- node
- private boolean shouldIndent(Node node)
node
- actual nodetrue
if line should be indentedvoid printBody(Out fout, Lexer lexer, Node root, boolean xml)
fout
- lexer
- root
- xml
- public void printTree(Out fout, short mode, int indent, Lexer lexer, Node node)
fout
- mode
- indent
- lexer
- node
- public void printXMLTree(Out fout, short mode, int indent, Lexer lexer, Node node)
fout
- mode
- indent
- lexer
- node
- public int countSlides(Node node)
node
- root nodeprivate void printNavBar(Out fout, int indent)
fout
- indent
- public void printSlide(Out fout, short mode, int indent, Lexer lexer)
fout
- mode
- indent
- lexer
- public void addTransitionEffect(Lexer lexer, Node root, double duration)
lexer
- root
- duration
-