spelling err
[jalview.git] / utils / jalopy / docs / printer.html
1
2     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3   <html><head>
4       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5    <title>4.3.&nbsp;Printer</title><link rel="stylesheet" href="site.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="manual.html" title="Jalopy User Manual"><link rel="up" href="settings.html" title="Chapter&nbsp;4.&nbsp;Settings"><link rel="previous" href="project.html" title="4.2.&nbsp;Projects"><link rel="next" href="whitespace.html" title="4.3.2.&nbsp;White Space"><link rel="preface" href="dedication.html" title="Dedication"><link rel="preface" href="acknowledge.html" title="Acknowledgements"><link rel="preface" href="introduction.html" title="Introduction"><link rel="part" href="part-core.html" title="Part&nbsp;I.&nbsp;Jalopy core"><link rel="chapter" href="installation.html" title="Chapter&nbsp;1.&nbsp;Installation"><link rel="chapter" href="build.html" title="Chapter&nbsp;2.&nbsp;Building"><link rel="chapter" href="usage.html" title="Chapter&nbsp;3.&nbsp;Usage"><link rel="chapter" href="settings.html" title="Chapter&nbsp;4.&nbsp;Settings"><link rel="part" href="part-plugins.html" title="Part&nbsp;II.&nbsp;Plug-ins"><link rel="chapter" href="plugin-ant.html" title="Chapter&nbsp;5.&nbsp;Ant Plug-in task"><link rel="chapter" href="plugin-console.html" title="Chapter&nbsp;6.&nbsp;Console Application"><link rel="chapter" href="plugin-eclipse.html" title="Chapter&nbsp;7.&nbsp;Eclipse Plug-in"><link rel="chapter" href="plugin-jbuilder.html" title="Chapter&nbsp;8.&nbsp;JBuilder OpenTool"><link rel="chapter" href="plugin-jdev.html" title="Chapter&nbsp;9.&nbsp;JDeveloper Extension"><link rel="chapter" href="plugin-jedit.html" title="Chapter&nbsp;10.&nbsp;jEdit Plug-in"><link rel="chapter" href="plugin-netbeans.html" title="Chapter&nbsp;11.&nbsp;NetBeans/Sun ONE Studio module"><link rel="appendix" href="dependencies.html" title="Appendix&nbsp;A.&nbsp;Library Dependencies"><link rel="appendix" href="license-bsd.html" title="Appendix&nbsp;B.&nbsp;The Jalopy BSD License"><link rel="appendix" href="license-antlr.html" title="Appendix&nbsp;C.&nbsp;ANTLR SOFTWARE RIGHTS"><link rel="appendix" href="license-apache.html" title="Appendix&nbsp;D.&nbsp;The Apache Software License, Version 1.1"><link rel="appendix" href="license-gnu.html" title="Appendix&nbsp;E.&nbsp;GNU GENERAL PUBLIC LICENSE Version 2, June 1991"><link rel="appendix" href="license-gnu-doc.html" title="Appendix&nbsp;F.&nbsp;GNU Free Documentation License Version 1.1, March 2000"><link rel="appendix" href="license-common-public.html" title="Appendix&nbsp;G.&nbsp;Common Public License Version 1.0"><link rel="appendix" href="license-sun-public.html" title="Appendix&nbsp;H.&nbsp;SUN PUBLIC LICENSE Version 1.0"><link rel="index" href="ix01.html" title="Index"><link rel="subsection" href="printer.html#braces" title="4.3.1.&nbsp;Braces"><link rel="subsection" href="whitespace.html" title="4.3.2.&nbsp;White Space"><link rel="subsection" href="indentation.html" title="4.3.3.&nbsp;Indentation"><link rel="subsection" href="wrapping.html" title="4.3.4.&nbsp;Wrapping"><link rel="subsection" href="separation.html" title="4.3.5.&nbsp;Blank Lines"><link rel="subsection" href="comments.html" title="4.3.6.&nbsp;Comments"><link rel="subsection" href="imports.html" title="4.3.7.&nbsp;Imports"><link rel="subsection" href="environment.html" title="4.3.8.&nbsp;Environment"><link rel="subsection" href="javadoc.html" title="4.3.9.&nbsp;Javadoc"><link rel="subsection" href="header.html" title="4.3.10.&nbsp;Header"><link rel="subsection" href="footer.html" title="4.3.11.&nbsp;Footer"><link rel="subsection" href="sorting.html" title="4.3.12.&nbsp;Sorting"><link rel="subsection" href="misc.html" title="4.3.13.&nbsp;Misc">
6       <meta name="description" content="Jalopy Java Source Code Formatter Beautifier Pretty Printer"> 
7       <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://jalopy.sf.net" r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://jalopy.sf.net" r (n 0 s 0 v 0 l 0))'> 
8     </head><body id="toppage" bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table width="700" border="0" cellpadding="0" cellspacing="0" align="left"><tbody><tr><td><table cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #336699"><tbody><tr><td height="16"></td></tr><tr><td bgcolor="#3399cc" height="1"></td></tr><tr style="border:none"><td style="border:none"><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td class="logo">JALOPY</td><td class="sublogo" valign="bottom">Java Source Code Formatter Beautifier Pretty Printer</td></tr></tbody></table></td></tr><tr><td bgcolor="#3399cc" height="1"></td></tr><tr><td height="10"></td></tr><tr><td bgcolor="#ff8000" height="4"></td></tr><tr><td height="20" bgcolor="#336699" style="color:#ffffff;padding-left:10px"><a href="./index.html" class="navlink">Overview</a> &#149;
9                     <a href="./download.html" class="navlink">Download</a> &#149;
10                     <a href="./docs.html" class="navlink">Documentation</a> &#149;
11                     <a href="./plugins.html" class="navlink">Plug-ins</a> &#149;
12                     <a href="./links.html" class="navlink">Links</a> &#149;
13                     <a href="./contact.html" class="navlink">Contact</a></td></tr><tr><td height="1" bgcolor="#ffffff"></td></tr></tbody></table></td></tr><tr valign="top"><td valign="top" bgcolor="#ffffff"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td height="20" bgcolor="#faebd7" style="padding-left:15px"><a href="./features.html" class="navlink2">Features</a> |
14                     <a href="./history.html" class="navlink2">History</a> |
15                     <a href="./manual.html" class="navlink2">Manual</a> |
16                     <a href="./faq.html" class="navlink2">FAQ</a> |
17                     <a href="./api/index.html" class="navlink2">Javadoc</a></td></tr><tr><td height="20" bgcolor="#ffffff"></td></tr><tr><td bgcolor="#eeeecc" height="17" align="right" style="font-size:10px;padding-right:3px">
18                     This page generated: <strong>June 8 2004</strong></td></tr></tbody></table><table border="0" width="100%" cellspacing="0" cellpadding="5"><tr><td><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.3.&nbsp;Printer</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="project.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;4.&nbsp;Settings</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="whitespace.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="printer"></a>4.3.&nbsp;Printer</h2></div></div><div></div></div><a class="indexterm" name="d0e1088"></a><p>
19 Lets you control all printer related settings.
20 </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="braces"></a>4.3.1.&nbsp;Braces</h3></div></div><div></div></div><a class="indexterm" name="d0e1097"></a><p>
21 Controls the handling of curly braces (the Java block delimeters).
22 </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="braces-style"></a>4.3.1.1.&nbsp;General</h4></div></div><div></div></div><a class="indexterm" name="d0e1105"></a><p>
23 Controls how the enclosing block delimeters - left and right curly
24 brace - are printed. You can either choose from a predefined set of common
25 styles or build one on your own.
26 </p><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-style-styles"></a>4.3.1.1.1.&nbsp;Styles</h5></div></div><div></div></div><p>
27 Controls which brace style will be used to lay out blocks.
28 </p><div class="itemizedlist"><ul type="disc"><li><p><a name="braces-style-c"></a>
29 C style
30 </p><a class="indexterm" name="d0e1121"></a><p>
31 Selects the C brace style. This style is sometimes called "Allman style" or "BSD style".
32 </p><div class="example"><a name="ex-brace-style-c"></a><p class="title"><b>Example&nbsp;4.1.&nbsp;C style</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
33 if (!isDone)
34 <span class="bold"><b>{</b></span>
35     doSomething();
36 <span class="bold"><b>}</b></span>
37 else
38 <span class="bold"><b>{</b></span>
39     System.err.println("Finished");
40 <span class="bold"><b>}</b></span>
41 </pre></td></tr></table></div><p></p></li><li><p><a name="braces-style-sun"></a>
42 Sun style
43 </p><a class="indexterm" name="d0e1151"></a><p>
44 Selects the Sun brace style. Sometimes called "K&amp;R style".
45 </p><div class="example"><a name="ex-brace-style-sun"></a><p class="title"><b>Example&nbsp;4.2.&nbsp;Sun style</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
46 if (!isDone) <span class="bold"><b>{</b></span>
47     doSomething();
48 <span class="bold"><b>}</b></span> else <span class="bold"><b>{</b></span>
49     System.err.println("Finished");
50 <span class="bold"><b>}</b></span>
51 </pre></td></tr></table></div><p></p></li><li><p><a name="braces-style-gnu"></a>
52 GNU style
53 </p><a class="indexterm" name="d0e1181"></a><p>
54 Selects the GNU brace style.
55 </p><div class="example"><a name="ex-brace-style-gnu"></a><p class="title"><b>Example&nbsp;4.3.&nbsp;GNU style</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
56 if (!isDone)
57   <span class="bold"><b>{</b></span>
58     doSomething();
59   <span class="bold"><b>}</b></span>
60 else
61   <span class="bold"><b>{</b></span>
62     System.err.println("Finished");
63   <span class="bold"><b>}</b></span>
64 </pre></td></tr></table></div><p></p></li><li><p><a name="braces-style-custom"></a>
65 Custom style
66 </p><a class="indexterm" name="d0e1211"></a><p>
67 Selecting this option will enable you to freely choose between the different brace
68 style options discussed below.
69 </p></li></ul></div></div><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-wrapping"></a>4.3.1.1.2.&nbsp;Wrapping</h5></div></div><div></div></div><a class="indexterm" name="d0e1223"></a><p>
70 Controls the brace wrapping options.
71 </p><div class="itemizedlist"><ul type="disc"><li><p>
72 Newline before left brace
73 </p><p>
74 If enabled, always prints a newline before the left curly brace.
75 </p></li><li><p>
76 Newline after right brace
77 </p><p>
78 If enabled, prints a newline after the left curly brace (when possible).
79 </p></li><li><p>
80 Treat class/method blocks different
81 </p><p>
82 It is common in the Java developer community to have the opening brace
83 at the end of the line of the keyword for all types of blocks (Sun brace style).
84 One may find the C++ convention of treating class/interface and method/constructor
85 blocks different from other blocks useful. With this switch you can achieve
86 exactly that: if enabled, class/interface and method/constructor blocks are
87 then always printed in C brace style (newline before left brace).
88 </p></li><li><p><a name="braces-different-wrapped"></a>
89 Treat class/method blocks different if wrapped
90 </p><p>
91 With this switch enabled, the opening brace for class/interface or
92 method/constructor blocks will always be printed on a new line (C style), if
93 either the parameter list spawns several lines and a <tt class="literal">throws</tt>
94 clause follows, or one of the possible clauses (<tt class="literal">extends</tt>,
95 <tt class="literal">implements</tt>, <tt class="literal">throws</tt>) was wrapped.
96 </p></li></ul></div></div><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-whitespace"></a>4.3.1.1.3.&nbsp;Whitespace</h5></div></div><div></div></div><a class="indexterm" name="d0e1266"></a><p>
97 Controls the indentation whitespace for the left and right curly brace.
98 </p><div class="itemizedlist"><ul type="disc"><li><p>
99 Before left brace
100 </p><p>
101 Number of spaces to print before the left curly brace.
102 </p></li><li><p>
103 After left brace
104 </p><p>
105 Number of spaces to print after the left curly brace.
106 </p></li><li><p>
107 After right brace
108 </p><p>
109 Number of spaces to print after the right curly brace.
110 </p></li></ul></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="braces-misc"></a>4.3.1.2.&nbsp;Misc</h4></div></div><div></div></div><p>
111 Controls miscellaneous brace options.
112 </p><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-insert"></a>4.3.1.2.1.&nbsp;Insert braces</h5></div></div><div></div></div><a class="indexterm" name="d0e1297"></a><p>
113 Per definition braces are superfluous on single statements, but it is
114 a common recommendation that braces should be always used in such cases.
115 With this option, you can specify whether missing braces for single
116 statements should be inserted for the control statements <tt class="function">if</tt>,
117 <tt class="function">for</tt>, <tt class="function">while</tt> and <tt class="function">do-while</tt>.
118 </p><p>
119 Enabling this option for <tt class="function">while</tt> statements would render
120 </p><div class="example"><a name="ex-brace-insertion"></a><p class="title"><b>Example&nbsp;4.4.&nbsp;Brace insertion</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
121 while (!isDone)
122     doSomething();
123 </pre></td></tr></table><p>
124 into
125 </p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
126 while (!isDone)
127 {
128     doSomething();
129 }
130 </pre></td></tr></table></div><p></p></div><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-remove"></a>4.3.1.2.2.&nbsp;Remove braces</h5></div></div><div></div></div><a class="indexterm" name="d0e1334"></a><p>
131 It is permittable to remove braces in case they are superfluous. This not only
132 applies to the control statements <tt class="function">if</tt>, <tt class="function">for</tt>,
133 <tt class="function">while</tt> and <tt class="function">do-while</tt>, but also to every
134 block in general (remember a block is just a sequence of statements,
135 local class declarations and local variable declaration statements within
136 braces).
137 </p><div class="example"><a name="ex-brace-removal"></a><p class="title"><b>Example&nbsp;4.5.&nbsp;Brace removal</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
138 for (int i = 0; i &lt; 100; i++)
139 {
140     sum += value[i];
141 }
142 </pre></td></tr></table><p>
143 would become
144 </p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
145 for (int i = 0; i &lt; 100; i++)
146     sum += value[i];
147 </pre></td></tr></table></div><p></p></div><div class="sect4" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="braces-empty"></a>4.3.1.2.3.&nbsp;Empty braces</h5></div></div><div></div></div><a class="indexterm" name="d0e1366"></a><a class="indexterm" name="d0e1369"></a><p>
148 Controls how empty braces should be handled. If no option is selected,
149 they are left untouched.
150 </p><div class="example"><a name="ex-brace-empty"></a><p class="title"><b>Example&nbsp;4.6.&nbsp;Empty braces</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
151 if (in != null)
152 {
153     try
154     {
155         in.close();
156     }
157     catch (IOException ignored)
158     {
159     }
160 }
161 </pre></td></tr></table></div><p>
162 All options don't apply to class/interface and method/constructor bodies but
163 are only used for control statements and blocks.
164 </p><div class="itemizedlist"><ul type="disc"><li><p><a name="braces-empty-statement"></a>
165 Insert empty statement
166 <a class="indexterm" name="d0e1387"></a>
167 <a class="indexterm" name="d0e1393"></a>
168
169 </p><p>
170 Inserts an empty statement to make it obvious for the reader that the empty braces
171 are intentional.
172 </p><div class="example"><a name="ex-braces-empty-statement"></a><p class="title"><b>Example&nbsp;4.7.&nbsp;Empty braces with empty statement</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
173 if (in != null)
174 {
175     try
176     {
177         in.close();
178     }
179     catch (IOException ignored)
180     {
181         <span class="bold"><b>;</b></span>
182     }
183 }
184 </pre></td></tr></table></div></li></ul></div><div class="itemizedlist"><ul type="disc"><li><p>
185 Cuddle braces
186 </p><p><a name="braces-empty-cuddle"></a>
187 Cuddles the braces. They will be printed right after the control statement.
188 <a class="indexterm" name="d0e1413"></a>
189 <a class="indexterm" name="d0e1419"></a>
190 </p><div class="example"><a name="ex-braces-empty-cuddle"></a><p class="title"><b>Example&nbsp;4.8.&nbsp;Cuddled empty braces</b></p><table border="0" bgcolor="#E0E0E0" class="shade"><tr><td><pre class="programlisting">
191 if (in != null)
192 {
193     try
194     {
195         in.close();
196     }
197     catch (IOException ignored) <span class="bold"><b>{}</b></span>
198 }
199 </pre></td></tr></table></div><p></p></li></ul></div></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="project.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="settings.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="whitespace.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.2.&nbsp;Projects&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.3.2.&nbsp;White Space</td></tr></table></div></td></tr></table></td></tr><tr><td bgcolor="#eeeecc" height="17" style="font-size:9px;padding-left:5px"><a href="#toppage">to top</a></td></tr><tr><td height="30"><br></td></tr><tr><td height="3"></td></tr><tr><td bgcolor="#336699" height="1"></td></tr><tr><td height="1"></td></tr><tr><td bgcolor="#336699" height="16"></td></tr><tr><td bgcolor="#ff9966" height="4"></td></tr><tr><td class="footer" align="center" height="15" valign="middle">
200             Copyright &copy; 2001-2004, <a class="footer" href="./contact.html">Marco Hunsicker</a>. All rights reserved. Hosted by <a href="http://sourceforge.net">SourceForge.net</a></td></tr></tbody></table><img src="http://sourceforge.net/sflogo.php?group_id=45216&amp;type=1" width="1" height="1" border="0" hspace="0" vspace="0" alt=""></body></html>