Java Doc for PrettyWriter.java in  » Scripting » Kawa » gnu » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » Kawa » gnu.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.Writer
      gnu.text.PrettyWriter

PrettyWriter
public class PrettyWriter extends java.io.Writer (Code)
A pretty printer. This code is transcribed from pprint.lisp in Steel Bank Common Lisp, which is again based on the code in CMU Common Lisp.


Field Summary
final public static  intNEWLINE_FILL
    
final public static  intNEWLINE_LINEAR
    
final public static  intNEWLINE_LITERAL
    
final public static  intNEWLINE_MANDATORY
    
final public static  intNEWLINE_MISER
    
final public static  intNEWLINE_SPACE
     A non-nested ' ' gets an implicit NEWLINE_SPACE. This is treated similarly to NEWLINE_FILL, but not quite.
final static  intQITEM_BASE_SIZE
     Size of "base part" of a QITEM.
final static  intQITEM_BLOCK_END_SIZE
    
final static  intQITEM_BLOCK_END_TYPE
    
final static  intQITEM_BLOCK_START_BLOCK_END
     If the QITEM_BLOCK_START_BLOCK_END < 0, it points to the previous (outer) un-closed block-start. If QITEM_BLOCK_START_BLOCK_END > 0, it points to the corresponding block-end node. In both cases the pointers are relative to the current BLOCK_START.
final static  intQITEM_BLOCK_START_PREFIX
    
final static  intQITEM_BLOCK_START_SIZE
    
final static  intQITEM_BLOCK_START_SUFFIX
    
final static  intQITEM_BLOCK_START_TYPE
     A "block-start" queue item.
final static  intQITEM_INDENTATION_AMOUNT
    
final static  charQITEM_INDENTATION_BLOCK
    
final static  charQITEM_INDENTATION_CURRENT
    
final static  intQITEM_INDENTATION_KIND
    
final static  intQITEM_INDENTATION_SIZE
    
final static  intQITEM_INDENTATION_TYPE
    
final static  intQITEM_NEWLINE_KIND
    
final static  intQITEM_NEWLINE_SIZE
    
final static  intQITEM_NEWLINE_TYPE
     A newline queue item.
final static  intQITEM_NOP_TYPE
     A dummy queue item used at the high end of the queue buffer when there isn't enough space for the needed queue item.
final static  intQITEM_POSN
    
final static  intQITEM_SECTION_START_DEPTH
    
final static  intQITEM_SECTION_START_SECTION_END
    
final static  intQITEM_SECTION_START_SIZE
     "Abstract" type for beginning of section. A section is from a block-start to a newline, from a newline to the next newline (in the same block?), or from a newline to the block end (?).
final static  intQITEM_TAB_COLINC
    
final static  intQITEM_TAB_COLNUM
    
final static  intQITEM_TAB_FLAGS
    
final static  intQITEM_TAB_IS_RELATIVE
    
final static  intQITEM_TAB_IS_SECTION
    
final static  intQITEM_TAB_SIZE
    
final static  intQITEM_TAB_TYPE
    
final static  intQITEM_TYPE_AND_SIZE
     The first it QITEM contains it type code and size. The type code is one of the QITEM_XXX_TYPE values below. The size is the corresponding QITEM_XXX_SIZE value below, except for the case of QITEM_NOP_TYPE (which is used as a filler).
final static  intQUEUE_INIT_ALLOC_SIZE
    
 intblockDepth
     The "stack pointer" in the blocks array.
 int[]blocks
     Stack of logical blocks in effect at the buffer start. I.e.
public  char[]buffer
     Holds all the text that has been output but not yet printed.
public  intbufferFillPointer
     The index into BUFFER where more text should be put.
 intbufferOffset
     Total amount of stuff that has been shifted out of the buffer. Whenever we output stuff from the buffer, we shift the remaining noise over.
 intbufferStartColumn
     The column the first character in the buffer will appear in. Normally zero, but if we end up with a very long line with no breaks in it we might have to output part of it.
 intcurrentBlock
     If >= 0, index (into queueInts) of current unclosed begin-block node.
public static  ThreadLocationindentLoc
    
public static  intinitialBufferSize
    
 intlineLength
     Line length we should format to.
public static  ThreadLocationlineLengthLoc
    
 intlineNumber
     The line number we are currently on.
 intmiserWidth
    
public static  ThreadLocationmiserWidthLoc
    
protected  Writerout
    
public  intpendingBlocksCount
     Number of startLogicalBlock - number of endLogicalBlock.
 char[]prefix
     Buffer holding the per-line prefix active at the buffer start. Indentation is included in this.
 intprettyPrintingMode
     The current pretty-printing mode. See setPrettyPrintingMode for valid values.
 int[]queueInts
     A queue of pending operations. This is primarily stored in the circular buffer queueInts.
 intqueueSize
     Number of elements (in queueInts and queueStrings) in use.
 String[]queueStrings
     For simplicity, queueStrings is the same size as queueInts.
 intqueueTail
     Index in queueInts and queueStrings of oldest enqueued operation.
 char[]suffix
     Buffer holding the total remaining suffix active at the buffer start. The characters are right-justified in the buffer to make it easier to output the buffer.
 booleanwordEndSeen
    

Constructor Summary
public  PrettyWriter(java.io.Writer out)
    
public  PrettyWriter(java.io.Writer out, int lineLength)
    
public  PrettyWriter(java.io.Writer out, boolean prettyPrintingMode)
    

Method Summary
public  voidaddIndentation(int amount, boolean current)
    
public  voidclearBuffer()
    
public  voidclearWordEnd()
    
public  voidclose()
    
 intcomputeTabSize(int tab, int sectionStart, int column)
    
public  voidendLogicalBlock()
    
public  voidendLogicalBlock(String suffix)
    
public  intenqueue(int kind, int size)
    
public  intenqueueIndent(char kind, int amount)
    
public  voidenqueueNewline(int kind)
    
 intenqueueTab(int flags, int colnum, int colinc)
    
 intensureSpaceInBuffer(int want)
    
 voidexpandTabs(int through)
    
 intfitsOnLine(int sectionEnd, boolean forceNewlines)
     Return 1 if true; -1 if false; 0 if don't know.
public  voidflush()
    
public  voidforcePrettyOutput()
    
public  intgetColumnNumber()
     Not meaningful if prettyPrintingMode > 0 .
 intgetMaxLines()
    
protected  intgetMiserWidth()
    
public  intgetPrettyPrintingMode()
     Return pretty-printing mode.
 intindexColumn(int index)
    
 booleanisMisering()
    
public  booleanisPrettyPrinting()
    
public  voidlineAbbreviationHappened()
    
 booleanmaybeOutput(boolean forceNewlines, boolean flushing)
    
 voidoutputLine(int newline)
     Output a new line.
 voidoutputPartialLine()
    
 booleanprintReadably()
    
 voidreallyEndLogicalBlock()
    
 voidreallyStartLogicalBlock(int column, String prefix, String suffix)
    
public  voidsetColumnNumber(int column)
    
public  voidsetIndentation(int column)
    
public  voidsetPrettyPrinting(boolean mode)
     Turn pretty printing on or off.
public  voidsetPrettyPrintingMode(int mode)
     Control pretty-printing mode.
public  voidstartLogicalBlock(String prefix, boolean perLine, String suffix)
    
public  voidwrite(int ch)
    
public  voidwrite(String str)
    
public  voidwrite(String str, int start, int count)
    
public  voidwrite(char[] str)
    
public  voidwrite(char[] str, int start, int count)
    
final public  voidwriteBreak(int kind)
    
public  voidwriteWordEnd()
     Note the end of a "word".
public  voidwriteWordStart()
     Maybe write a word-separating space. Specifically, write a space if the previous output was PrettyWriter.writeWordEnd .

Field Detail
NEWLINE_FILL
final public static int NEWLINE_FILL(Code)



NEWLINE_LINEAR
final public static int NEWLINE_LINEAR(Code)



NEWLINE_LITERAL
final public static int NEWLINE_LITERAL(Code)



NEWLINE_MANDATORY
final public static int NEWLINE_MANDATORY(Code)



NEWLINE_MISER
final public static int NEWLINE_MISER(Code)



NEWLINE_SPACE
final public static int NEWLINE_SPACE(Code)
A non-nested ' ' gets an implicit NEWLINE_SPACE. This is treated similarly to NEWLINE_FILL, but not quite.



QITEM_BASE_SIZE
final static int QITEM_BASE_SIZE(Code)
Size of "base part" of a QITEM.



QITEM_BLOCK_END_SIZE
final static int QITEM_BLOCK_END_SIZE(Code)



QITEM_BLOCK_END_TYPE
final static int QITEM_BLOCK_END_TYPE(Code)



QITEM_BLOCK_START_BLOCK_END
final static int QITEM_BLOCK_START_BLOCK_END(Code)
If the QITEM_BLOCK_START_BLOCK_END < 0, it points to the previous (outer) un-closed block-start. If QITEM_BLOCK_START_BLOCK_END > 0, it points to the corresponding block-end node. In both cases the pointers are relative to the current BLOCK_START.



QITEM_BLOCK_START_PREFIX
final static int QITEM_BLOCK_START_PREFIX(Code)



QITEM_BLOCK_START_SIZE
final static int QITEM_BLOCK_START_SIZE(Code)



QITEM_BLOCK_START_SUFFIX
final static int QITEM_BLOCK_START_SUFFIX(Code)



QITEM_BLOCK_START_TYPE
final static int QITEM_BLOCK_START_TYPE(Code)
A "block-start" queue item.



QITEM_INDENTATION_AMOUNT
final static int QITEM_INDENTATION_AMOUNT(Code)



QITEM_INDENTATION_BLOCK
final static char QITEM_INDENTATION_BLOCK(Code)



QITEM_INDENTATION_CURRENT
final static char QITEM_INDENTATION_CURRENT(Code)



QITEM_INDENTATION_KIND
final static int QITEM_INDENTATION_KIND(Code)



QITEM_INDENTATION_SIZE
final static int QITEM_INDENTATION_SIZE(Code)



QITEM_INDENTATION_TYPE
final static int QITEM_INDENTATION_TYPE(Code)



QITEM_NEWLINE_KIND
final static int QITEM_NEWLINE_KIND(Code)



QITEM_NEWLINE_SIZE
final static int QITEM_NEWLINE_SIZE(Code)



QITEM_NEWLINE_TYPE
final static int QITEM_NEWLINE_TYPE(Code)
A newline queue item.



QITEM_NOP_TYPE
final static int QITEM_NOP_TYPE(Code)
A dummy queue item used at the high end of the queue buffer when there isn't enough space for the needed queue item.



QITEM_POSN
final static int QITEM_POSN(Code)
Relative offset of POSN field of a QITEM>



QITEM_SECTION_START_DEPTH
final static int QITEM_SECTION_START_DEPTH(Code)



QITEM_SECTION_START_SECTION_END
final static int QITEM_SECTION_START_SECTION_END(Code)



QITEM_SECTION_START_SIZE
final static int QITEM_SECTION_START_SIZE(Code)
"Abstract" type for beginning of section. A section is from a block-start to a newline, from a newline to the next newline (in the same block?), or from a newline to the block end (?).



QITEM_TAB_COLINC
final static int QITEM_TAB_COLINC(Code)



QITEM_TAB_COLNUM
final static int QITEM_TAB_COLNUM(Code)



QITEM_TAB_FLAGS
final static int QITEM_TAB_FLAGS(Code)



QITEM_TAB_IS_RELATIVE
final static int QITEM_TAB_IS_RELATIVE(Code)



QITEM_TAB_IS_SECTION
final static int QITEM_TAB_IS_SECTION(Code)



QITEM_TAB_SIZE
final static int QITEM_TAB_SIZE(Code)



QITEM_TAB_TYPE
final static int QITEM_TAB_TYPE(Code)



QITEM_TYPE_AND_SIZE
final static int QITEM_TYPE_AND_SIZE(Code)
The first it QITEM contains it type code and size. The type code is one of the QITEM_XXX_TYPE values below. The size is the corresponding QITEM_XXX_SIZE value below, except for the case of QITEM_NOP_TYPE (which is used as a filler).



QUEUE_INIT_ALLOC_SIZE
final static int QUEUE_INIT_ALLOC_SIZE(Code)



blockDepth
int blockDepth(Code)
The "stack pointer" in the blocks array.



blocks
int[] blocks(Code)
Stack of logical blocks in effect at the buffer start. I.e. blocks for which reallyStartLogicalBlock has been called. Each block uses LOGICAL_BLOCK_LENGTH int in this array.



buffer
public char[] buffer(Code)
Holds all the text that has been output but not yet printed.



bufferFillPointer
public int bufferFillPointer(Code)
The index into BUFFER where more text should be put.



bufferOffset
int bufferOffset(Code)
Total amount of stuff that has been shifted out of the buffer. Whenever we output stuff from the buffer, we shift the remaining noise over. This makes it difficult to keep references to locations in the buffer.



bufferStartColumn
int bufferStartColumn(Code)
The column the first character in the buffer will appear in. Normally zero, but if we end up with a very long line with no breaks in it we might have to output part of it. Then this will no longer be zero. Ditto after emitting a prompt.



currentBlock
int currentBlock(Code)
If >= 0, index (into queueInts) of current unclosed begin-block node. This is a head of a linked linked of queued BLOCK_START for which we haven't seen the matching BLOCK_END



indentLoc
public static ThreadLocation indentLoc(Code)



initialBufferSize
public static int initialBufferSize(Code)



lineLength
int lineLength(Code)
Line length we should format to.



lineLengthLoc
public static ThreadLocation lineLengthLoc(Code)



lineNumber
int lineNumber(Code)
The line number we are currently on. Used for *print-lines* abrevs and to tell when sections have been split across multiple lines.



miserWidth
int miserWidth(Code)



miserWidthLoc
public static ThreadLocation miserWidthLoc(Code)



out
protected Writer out(Code)



pendingBlocksCount
public int pendingBlocksCount(Code)
Number of startLogicalBlock - number of endLogicalBlock.



prefix
char[] prefix(Code)
Buffer holding the per-line prefix active at the buffer start. Indentation is included in this. The length of this is stored in the logical block stack.



prettyPrintingMode
int prettyPrintingMode(Code)
The current pretty-printing mode. See setPrettyPrintingMode for valid values.



queueInts
int[] queueInts(Code)
A queue of pending operations. This is primarily stored in the circular buffer queueInts. There are different kinds of operation types, and each operation can require a variable number of elements in the buffer, depending on the operation type. Given an operation at 'index', the type operation type code is 'getQueueType(index)' (one of the QITEM_XXX_TYPE macros below), and the number of elements in the buffer is 'getQueueSize(index)' (one of the QITEM_XXX_SIZE values below). You can think of the various QITEM_XXX_TYPEs as "sub-classes" of queued operations, but instead of creating actual Java objects, we allocate the objects' fields in the queueInts and QueueStrings arrays, to avoid expensive object allocation. The special QITEM_NOP_TYPE is a used as a marker for when there isn't enough space in the rest of buffer, so we have to wrap around to the start. The other QITEM_XXX macros are the offsets of the various "fields" relative to the start index.



queueSize
int queueSize(Code)
Number of elements (in queueInts and queueStrings) in use.



queueStrings
String[] queueStrings(Code)
For simplicity, queueStrings is the same size as queueInts.



queueTail
int queueTail(Code)
Index in queueInts and queueStrings of oldest enqueued operation.



suffix
char[] suffix(Code)
Buffer holding the total remaining suffix active at the buffer start. The characters are right-justified in the buffer to make it easier to output the buffer. The length is stored in the logical block stack.



wordEndSeen
boolean wordEndSeen(Code)




Constructor Detail
PrettyWriter
public PrettyWriter(java.io.Writer out)(Code)



PrettyWriter
public PrettyWriter(java.io.Writer out, int lineLength)(Code)



PrettyWriter
public PrettyWriter(java.io.Writer out, boolean prettyPrintingMode)(Code)




Method Detail
addIndentation
public void addIndentation(int amount, boolean current)(Code)



clearBuffer
public void clearBuffer()(Code)



clearWordEnd
public void clearWordEnd()(Code)



close
public void close() throws IOException(Code)



computeTabSize
int computeTabSize(int tab, int sectionStart, int column)(Code)



endLogicalBlock
public void endLogicalBlock()(Code)



endLogicalBlock
public void endLogicalBlock(String suffix)(Code)



enqueue
public int enqueue(int kind, int size)(Code)



enqueueIndent
public int enqueueIndent(char kind, int amount)(Code)



enqueueNewline
public void enqueueNewline(int kind)(Code)



enqueueTab
int enqueueTab(int flags, int colnum, int colinc)(Code)



ensureSpaceInBuffer
int ensureSpaceInBuffer(int want)(Code)



expandTabs
void expandTabs(int through)(Code)



fitsOnLine
int fitsOnLine(int sectionEnd, boolean forceNewlines)(Code)
Return 1 if true; -1 if false; 0 if don't know.



flush
public void flush()(Code)



forcePrettyOutput
public void forcePrettyOutput() throws IOException(Code)



getColumnNumber
public int getColumnNumber()(Code)
Not meaningful if prettyPrintingMode > 0 .



getMaxLines
int getMaxLines()(Code)



getMiserWidth
protected int getMiserWidth()(Code)



getPrettyPrintingMode
public int getPrettyPrintingMode()(Code)
Return pretty-printing mode. 0, 1, 2, as described for PrettyWriter.setPrettyPrintingMode(int).



indexColumn
int indexColumn(int index)(Code)



isMisering
boolean isMisering()(Code)



isPrettyPrinting
public boolean isPrettyPrinting()(Code)
Is pretty printing enabled?



lineAbbreviationHappened
public void lineAbbreviationHappened()(Code)



maybeOutput
boolean maybeOutput(boolean forceNewlines, boolean flushing)(Code)



outputLine
void outputLine(int newline) throws IOException(Code)
Output a new line.
Parameters:
  newline - index of a newline queue item



outputPartialLine
void outputPartialLine()(Code)



printReadably
boolean printReadably()(Code)



reallyEndLogicalBlock
void reallyEndLogicalBlock()(Code)



reallyStartLogicalBlock
void reallyStartLogicalBlock(int column, String prefix, String suffix)(Code)



setColumnNumber
public void setColumnNumber(int column)(Code)



setIndentation
public void setIndentation(int column)(Code)



setPrettyPrinting
public void setPrettyPrinting(boolean mode)(Code)
Turn pretty printing on or off. Equivalent to setPrettyPrintingMode(mode?1:0) .



setPrettyPrintingMode
public void setPrettyPrintingMode(int mode)(Code)
Control pretty-printing mode.
Parameters:
  mode - the value 0 disables pretty-printing;the value 1 enables ecplicit pretty-printing;the value 2 enables pretty-printing with auto-fill, which means thatspaces are treated like enqueing NEWLINE_SPACE (essentiall a 'fill').



startLogicalBlock
public void startLogicalBlock(String prefix, boolean perLine, String suffix)(Code)



write
public void write(int ch)(Code)



write
public void write(String str)(Code)



write
public void write(String str, int start, int count)(Code)



write
public void write(char[] str)(Code)



write
public void write(char[] str, int start, int count)(Code)



writeBreak
final public void writeBreak(int kind)(Code)



writeWordEnd
public void writeWordEnd()(Code)
Note the end of a "word". See PrettyWriter.writeWordStart .



writeWordStart
public void writeWordStart()(Code)
Maybe write a word-separating space. Specifically, write a space if the previous output was PrettyWriter.writeWordEnd . Otherwise, do nothing.



Fields inherited from java.io.Writer
protected Object lock(Code)(Java Doc)

Methods inherited from java.io.Writer
public Writer append(CharSequence csq) throws IOException(Code)(Java Doc)
public Writer append(CharSequence csq, int start, int end) throws IOException(Code)(Java Doc)
public Writer append(char c) throws IOException(Code)(Java Doc)
abstract public void close() throws IOException(Code)(Java Doc)
abstract public void flush() throws IOException(Code)(Java Doc)
public void write(int c) throws IOException(Code)(Java Doc)
public void write(char cbuf) throws IOException(Code)(Java Doc)
abstract public void write(char cbuf, int off, int len) throws IOException(Code)(Java Doc)
public void write(String str) throws IOException(Code)(Java Doc)
public void write(String str, int off, int len) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.