Java Doc for PrettyWriter.java in  » Scripting » Nice » 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 » Nice » 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 static  intQUEUED_OP_BLOCK_END_SIZE
    
final static  intQUEUED_OP_BLOCK_END_TYPE
    
final static  intQUEUED_OP_BLOCK_PREFIX
    
final static  intQUEUED_OP_BLOCK_START_BLOCK_END
     If the QUEUED_OP_SECTION_START_SECTION_END < 0, it points to the previous (outer) un-closed block-start. If QUEUED_OP_SECTION_START_SECTION_END > 0, it points to the corresponding block-end node. In both cases the pointers are relative to the current BLOCK_START.
final static  intQUEUED_OP_BLOCK_START_SIZE
    
final static  intQUEUED_OP_BLOCK_START_SUFFIX
    
final static  intQUEUED_OP_BLOCK_START_TYPE
     A "block-start" queue item.
final static  intQUEUED_OP_DUMMY_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  intQUEUED_OP_INDENTATION_AMOUNT
    
final static  intQUEUED_OP_INDENTATION_BLOCK
    
final static  intQUEUED_OP_INDENTATION_CURRENT
    
final static  intQUEUED_OP_INDENTATION_KIND
    
final static  intQUEUED_OP_INDENTATION_SIZE
    
final static  intQUEUED_OP_INDENTATION_TYPE
    
final static  intQUEUED_OP_NEWLINE_KIND
    
final static  intQUEUED_OP_NEWLINE_SIZE
    
final static  intQUEUED_OP_NEWLINE_TYPE
     A newline queue item.
final static  intQUEUED_OP_POSN
    
final static  intQUEUED_OP_SECTION_START_DEPTH
    
final static  intQUEUED_OP_SECTION_START_SECTION_END
    
final static  intQUEUED_OP_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  intQUEUED_OP_SIZE
     Size of "base part" of a QUEUED_OP.
final static  intQUEUED_OP_TAB_COLINC
    
final static  intQUEUED_OP_TAB_COLNUM
    
final static  intQUEUED_OP_TAB_FLAGS
    
final static  intQUEUED_OP_TAB_IS_RELATIVE
    
final static  intQUEUED_OP_TAB_IS_SECTION
    
final static  intQUEUED_OP_TAB_SIZE
    
final static  intQUEUED_OP_TAB_TYPE
    
final static  intQUEUED_OP_TYPE
    
final static  intQUEUE_INIT_ALLOC_SIZE
    
 intblockDepth
    
 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
     Index (into queueInts) of current unclosed begin-block node.
public static  intinitialBufferSize
    
public  booleanisPrettyPrinting
    
 intlineLength
     Line length we should format to.
 intlineNumber
     The line number we are currently on.
 intmiserWidth
    
protected  Writerout
    
public  intpendingBlocksCount
    
 char[]prefix
     Buffer holding the per-line prefix active at the buffer start. Indentation is included in this.
 int[]queueInts
    
 intqueueSize
     Number of elements (in queueInts and queueStrings) in use.
 String[]queueStrings
     For simplicity, queueStrings is the same size as queueInts.
 intqueueTail
    
 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.

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

Method Summary
public  voidaddIndentation(int amount, boolean current)
    
public  voidclearBuffer()
    
public  voidclose()
    
 intcomputeTabSize(int tab, int sectionStart, int column)
    
 voiddumpQueue()
    
 voiddumpQueue(int start, int todo, PrintWriter out)
    
public  voidendLogicalBlock()
    
public  voidendLogicalBlock(String suffix)
    
public  intenqueue(int kind, int size)
    
public  intenqueueIndent(int 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 isPrettyPrinting.
 intgetMaxLines()
    
protected  intgetMiserWidth()
    
 intindexColumn(int index)
    
 booleanisMisering()
    
public  voidlineAbbreviationHappened()
    
 booleanmaybeOutput(boolean forceNewlines)
    
 voidoutputLine(int newline)
     Output a newline.
 voidoutputPartialLine()
    
 booleanprintReadably()
    
 voidreallyEndLogicalBlock()
    
 voidreallyStartLogicalBlock(int column, String prefix, String suffix)
    
public  voidsetColumnNumber(int column)
    
public  voidsetIndentation(int column)
    
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)
    

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)



QUEUED_OP_BLOCK_END_SIZE
final static int QUEUED_OP_BLOCK_END_SIZE(Code)



QUEUED_OP_BLOCK_END_TYPE
final static int QUEUED_OP_BLOCK_END_TYPE(Code)



QUEUED_OP_BLOCK_PREFIX
final static int QUEUED_OP_BLOCK_PREFIX(Code)



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



QUEUED_OP_BLOCK_START_SIZE
final static int QUEUED_OP_BLOCK_START_SIZE(Code)



QUEUED_OP_BLOCK_START_SUFFIX
final static int QUEUED_OP_BLOCK_START_SUFFIX(Code)



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



QUEUED_OP_DUMMY_TYPE
final static int QUEUED_OP_DUMMY_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.



QUEUED_OP_INDENTATION_AMOUNT
final static int QUEUED_OP_INDENTATION_AMOUNT(Code)



QUEUED_OP_INDENTATION_BLOCK
final static int QUEUED_OP_INDENTATION_BLOCK(Code)



QUEUED_OP_INDENTATION_CURRENT
final static int QUEUED_OP_INDENTATION_CURRENT(Code)



QUEUED_OP_INDENTATION_KIND
final static int QUEUED_OP_INDENTATION_KIND(Code)



QUEUED_OP_INDENTATION_SIZE
final static int QUEUED_OP_INDENTATION_SIZE(Code)



QUEUED_OP_INDENTATION_TYPE
final static int QUEUED_OP_INDENTATION_TYPE(Code)



QUEUED_OP_NEWLINE_KIND
final static int QUEUED_OP_NEWLINE_KIND(Code)



QUEUED_OP_NEWLINE_SIZE
final static int QUEUED_OP_NEWLINE_SIZE(Code)



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



QUEUED_OP_POSN
final static int QUEUED_OP_POSN(Code)
Relative offset of POSN field of a QUEUED_OP>



QUEUED_OP_SECTION_START_DEPTH
final static int QUEUED_OP_SECTION_START_DEPTH(Code)



QUEUED_OP_SECTION_START_SECTION_END
final static int QUEUED_OP_SECTION_START_SECTION_END(Code)



QUEUED_OP_SECTION_START_SIZE
final static int QUEUED_OP_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 (?).



QUEUED_OP_SIZE
final static int QUEUED_OP_SIZE(Code)
Size of "base part" of a QUEUED_OP.



QUEUED_OP_TAB_COLINC
final static int QUEUED_OP_TAB_COLINC(Code)



QUEUED_OP_TAB_COLNUM
final static int QUEUED_OP_TAB_COLNUM(Code)



QUEUED_OP_TAB_FLAGS
final static int QUEUED_OP_TAB_FLAGS(Code)



QUEUED_OP_TAB_IS_RELATIVE
final static int QUEUED_OP_TAB_IS_RELATIVE(Code)



QUEUED_OP_TAB_IS_SECTION
final static int QUEUED_OP_TAB_IS_SECTION(Code)



QUEUED_OP_TAB_SIZE
final static int QUEUED_OP_TAB_SIZE(Code)



QUEUED_OP_TAB_TYPE
final static int QUEUED_OP_TAB_TYPE(Code)



QUEUED_OP_TYPE
final static int QUEUED_OP_TYPE(Code)



QUEUE_INIT_ALLOC_SIZE
final static int QUEUE_INIT_ALLOC_SIZE(Code)



blockDepth
int blockDepth(Code)



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



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.



currentBlock
int currentBlock(Code)
Index (into queueInts) of current unclosed begin-block node.



initialBufferSize
public static int initialBufferSize(Code)



isPrettyPrinting
public boolean isPrettyPrinting(Code)



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



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)



out
protected Writer out(Code)



pendingBlocksCount
public int pendingBlocksCount(Code)



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.



queueInts
int[] queueInts(Code)



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)



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.




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



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



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




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



clearBuffer
public void clearBuffer()(Code)



close
public void close() throws IOException(Code)



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



dumpQueue
void dumpQueue()(Code)



dumpQueue
void dumpQueue(int start, int todo, PrintWriter out)(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(int 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 isPrettyPrinting.



getMaxLines
int getMaxLines()(Code)



getMiserWidth
protected int getMiserWidth()(Code)



indexColumn
int indexColumn(int index)(Code)



isMisering
boolean isMisering()(Code)



lineAbbreviationHappened
public void lineAbbreviationHappened()(Code)



maybeOutput
boolean maybeOutput(boolean forceNewlines)(Code)



outputLine
void outputLine(int newline) throws IOException(Code)
Output a newline.
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)



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)



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.