| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html lang="en"> |
| <head> |
| <meta name="copyright" content="Copyright (c) 2008, 2011 Mateusz Matela and others. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <title> |
| Generate toString() dialog |
| </title> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| </head> |
| <body> |
| <h1> |
| Generate toString() dialog |
| </h1> |
| <p> |
| The Generate toString() dialog provides means to include specific member fields and methods in generated toString() method. |
| </p> |
| <p> |
| Use <strong>Generate toString()...</strong> from the <a href="ref-menu-source.htm">Source menu</a> or the context menu on a selected type or on a text selection in a type. |
| </p> |
| <p> |
| The members to be considered for inclusion in the toString() output are: |
| </p> |
| <ul><li>fields (non-static)</li> |
| <li>argument-less methods (non-static, non-void)</li> |
| <li>inherited fields and methods (fulfilling adequate conditions)</li></ul> |
| <p> |
| When pressing <strong>OK</strong>, the toString() method printing out all selected members and eventually helper methods are created. |
| </p> |
| <table border="1" cellspacing="0" cellpadding="5" width="100%" summary="Override methods settings"> |
| <tr> |
| <th> |
| <p> |
| Option |
| </p> |
| </th> |
| <th> |
| <p> |
| Description |
| </p> |
| </th> |
| <th> |
| <p> |
| Default |
| </p> |
| </th> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Select fields and methods to include in the toString() method |
| </p> |
| </td> |
| <td valign="top"> |
| For convenience, members are divided into up to four groups: Fields, Inherited fields, Methods and Inherited methods. Checking or unchecking a group affects the state of all its members. |
| </td> |
| <td valign="top"> |
| Only fields which are non-transient and not inherited. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Select All |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Select all fields and methods. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Deselect All |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Deselect all fields and methods. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Up |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Move the element with focus up the list. A member can be moved only within its group. Groups can also be moved. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Down |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Move the element with focus down the list. A member can be moved only within its group. Groups can also be moved. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Sort |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Sort elements in every group in lexicographical order. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Insertion point |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Defines where in the type body the generated methods are inserted. If a method already exists in a class and is overwritten, its position will not be changed (this option will have no effect). |
| </p> |
| </td> |
| <td valign="top"> |
| <p>Last member or location of the cursor position if invoked from editor</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Generate method comments |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Controls whether a comment is added to the created toString() method. Generated comment just points to a javadoc comment for <code>java.lang.Object#toString()</code>. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>off</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| String format |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Defines which template is used to format the toString() output. A template determines what information about a class is added, how the fields are separated, and so on. For more information about templates, see <a href="ref-tostring-templates.htm">toString() generator: format templates</a> topic. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>Default template</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Edit... |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Opens a dialog that lets you add, remove or change string format templates (see above). |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Code style |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Defines the method code style, that is what libraries/mechanisms it uses to create output. For more information, see <a href="ref-tostring-styles.htm">toString() generator: code styles</a> topic. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>String concatenation</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Configure... |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Opens a dialog that lets you configure more options related to selected code style. Currently this button is only active for <a href="ref-tostring-styles.htm#custombuilder">Custom toString() builder</a> code style. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>n/a</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Skip null values |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Controls whether the toString() method skips members that have no value (nulls). How it is accomplished depends on selected code style (see above). |
| </p> |
| </td> |
| <td valign="top"> |
| <p>off</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| List contents of arrays instead of using native toString() |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Controls whether the toString() method lists items contained by arrays instead of using their default toString(). See <a href="ref-tostring-listcontent.htm">toString() generator: listing content</a> for details. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>off</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| Limit number of items in arrays/collections/maps |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Controls whether the toString() method limits the number of elements printed for arrays, <code>Collection</code>s and <code>Map</code>s, and what the limit is. It doesn't work for arrays if "Ignore arrays' default toString()" option is off. See <a href="ref-tostring-listcontent.htm">toString() generator: listing content</a> for details. |
| </p> |
| </td> |
| <td valign="top"> |
| <p>off</p> |
| </td> |
| </tr> |
| </table> |
| <h3 class="related">Related references</h3> |
| <a href="../reference/ref-menu-source.htm">Source actions</a><br> |
| <a href="ref-tostring-templates.htm">toString() generator: format templates</a><br> |
| <a href="ref-tostring-styles.htm">toString() generator: code styles</a><br> |
| <a href="ref-tostring-listcontent.htm">toString() generator: content listing</a> |
| |
| </body> |
| </html> |
| |