1. /* ====================================================================
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if
  20. * any, must include the following acknowledgement:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowledgement may appear in the software itself,
  24. * if and wherever such third-party acknowledgements normally appear.
  25. *
  26. * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  27. * Foundation" must not be used to endorse or promote products derived
  28. * from this software without prior written permission. For written
  29. * permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache"
  32. * nor may "Apache" appear in their names without prior written
  33. * permission of the Apache Software Foundation.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation. For more
  51. * information on the Apache Software Foundation, please see
  52. * <http://www.apache.org/>.
  53. */
  54. package org.apache.commons.lang.builder;
  55. /**
  56. * <p>Works with {@link ToStringBuilder} to create a <code>toString</code>.</p>
  57. *
  58. * <p>This class is intended to be used as a singleton.
  59. * There is no need to instantiate a new style each time.
  60. * Simply instantiate the class once, customize the values as required, and
  61. * store the result in a public static final variable for the rest of the
  62. * program to access.</p>
  63. *
  64. * @author Stephen Colebourne
  65. * @author Pete Gieser
  66. * @author Gary Gregory
  67. * @since 1.0
  68. * @version $Id: StandardToStringStyle.java,v 1.16 2003/08/23 00:22:53 ggregory Exp $
  69. */
  70. public class StandardToStringStyle extends ToStringStyle {
  71. /**
  72. * <p>Constructor.</p>
  73. */
  74. public StandardToStringStyle() {
  75. super();
  76. }
  77. //---------------------------------------------------------------------
  78. /**
  79. * <p>Gets whether to use the class name.</p>
  80. *
  81. * @return the current useClassName flag
  82. */
  83. public boolean isUseClassName() {
  84. return super.isUseClassName();
  85. }
  86. /**
  87. * <p>Sets whether to use the class name.</p>
  88. *
  89. * @param useClassName the new useClassName flag
  90. */
  91. public void setUseClassName(boolean useClassName) {
  92. super.setUseClassName(useClassName);
  93. }
  94. //---------------------------------------------------------------------
  95. /**
  96. * <p>Gets whether to output short or long class names.</p>
  97. *
  98. * @return the current useShortClassName flag
  99. * @since 2.0
  100. */
  101. public boolean isUseShortClassName() {
  102. return super.isUseShortClassName();
  103. }
  104. /**
  105. * <p>Gets whether to output short or long class names.</p>
  106. *
  107. * @return the current shortClassName flag
  108. * @deprecated Use {@link #isUseShortClassName()}
  109. * Method will be removed in Commons Lang 3.0.
  110. */
  111. public boolean isShortClassName() {
  112. return super.isUseShortClassName();
  113. }
  114. /**
  115. * <p>Sets whether to output short or long class names.</p>
  116. *
  117. * @param useShortClassName the new useShortClassName flag
  118. * @since 2.0
  119. */
  120. public void setUseShortClassName(boolean useShortClassName) {
  121. super.setUseShortClassName(useShortClassName);
  122. }
  123. /**
  124. * <p>Sets whether to output short or long class names.</p>
  125. *
  126. * @param shortClassName the new shortClassName flag
  127. * @deprecated Use {@link #setUseShortClassName(boolean)}
  128. * Method will be removed in Commons Lang 3.0.
  129. */
  130. public void setShortClassName(boolean shortClassName) {
  131. super.setUseShortClassName(shortClassName);
  132. }
  133. //---------------------------------------------------------------------
  134. /**
  135. * <p>Gets whether to use the identity hash code.</p>
  136. * @return the current useIdentityHashCode flag
  137. */
  138. public boolean isUseIdentityHashCode() {
  139. return super.isUseIdentityHashCode();
  140. }
  141. /**
  142. * <p>Sets whether to use the identity hash code.</p>
  143. *
  144. * @param useIdentityHashCode the new useIdentityHashCode flag
  145. */
  146. public void setUseIdentityHashCode(boolean useIdentityHashCode) {
  147. super.setUseIdentityHashCode(useIdentityHashCode);
  148. }
  149. //---------------------------------------------------------------------
  150. /**
  151. * <p>Gets whether to use the field names passed in.</p>
  152. *
  153. * @return the current useFieldNames flag
  154. */
  155. public boolean isUseFieldNames() {
  156. return super.isUseFieldNames();
  157. }
  158. /**
  159. * <p>Sets whether to use the field names passed in.</p>
  160. *
  161. * @param useFieldNames the new useFieldNames flag
  162. */
  163. public void setUseFieldNames(boolean useFieldNames) {
  164. super.setUseFieldNames(useFieldNames);
  165. }
  166. //---------------------------------------------------------------------
  167. /**
  168. * <p>Gets whether to use full detail when the caller doesn't
  169. * specify.</p>
  170. *
  171. * @return the current defaultFullDetail flag
  172. */
  173. public boolean isDefaultFullDetail() {
  174. return super.isDefaultFullDetail();
  175. }
  176. /**
  177. * <p>Sets whether to use full detail when the caller doesn't
  178. * specify.</p>
  179. *
  180. * @param defaultFullDetail the new defaultFullDetail flag
  181. */
  182. public void setDefaultFullDetail(boolean defaultFullDetail) {
  183. super.setDefaultFullDetail(defaultFullDetail);
  184. }
  185. //---------------------------------------------------------------------
  186. /**
  187. * <p>Gets whether to output array content detail.</p>
  188. *
  189. * @return the current array content detail setting
  190. */
  191. public boolean isArrayContentDetail() {
  192. return super.isArrayContentDetail();
  193. }
  194. /**
  195. * <p>Sets whether to output array content detail.</p>
  196. *
  197. * @param arrayContentDetail the new arrayContentDetail flag
  198. */
  199. public void setArrayContentDetail(boolean arrayContentDetail) {
  200. super.setArrayContentDetail(arrayContentDetail);
  201. }
  202. //---------------------------------------------------------------------
  203. /**
  204. * <p>Gets the array start text.</p>
  205. *
  206. * @return the current array start text
  207. */
  208. public String getArrayStart() {
  209. return super.getArrayStart();
  210. }
  211. /**
  212. * <p>Sets the array start text.</p>
  213. *
  214. * <p><code>null</code> is accepted, but will be converted
  215. * to an empty String.</p>
  216. *
  217. * @param arrayStart the new array start text
  218. */
  219. public void setArrayStart(String arrayStart) {
  220. super.setArrayStart(arrayStart);
  221. }
  222. //---------------------------------------------------------------------
  223. /**
  224. * <p>Gets the array end text.</p>
  225. *
  226. * @return the current array end text
  227. */
  228. public String getArrayEnd() {
  229. return super.getArrayEnd();
  230. }
  231. /**
  232. * <p>Sets the array end text.</p>
  233. *
  234. * <p><code>null</code> is accepted, but will be converted
  235. * to an empty String.</p>
  236. *
  237. * @param arrayEnd the new array end text
  238. */
  239. public void setArrayEnd(String arrayEnd) {
  240. super.setArrayEnd(arrayEnd);
  241. }
  242. //---------------------------------------------------------------------
  243. /**
  244. * <p>Gets the array separator text.</p>
  245. *
  246. * @return the current array separator text
  247. */
  248. public String getArraySeparator() {
  249. return super.getArraySeparator();
  250. }
  251. /**
  252. * <p>Sets the array separator text.</p>
  253. *
  254. * <p><code>null</code> is accepted, but will be converted
  255. * to an empty String.</p>
  256. *
  257. * @param arraySeparator the new array separator text
  258. */
  259. public void setArraySeparator(String arraySeparator) {
  260. super.setArraySeparator(arraySeparator);
  261. }
  262. //---------------------------------------------------------------------
  263. /**
  264. * <p>Gets the content start text.</p>
  265. *
  266. * @return the current content start text
  267. */
  268. public String getContentStart() {
  269. return super.getContentStart();
  270. }
  271. /**
  272. * <p>Sets the content start text.</p>
  273. *
  274. * <p><code>null</code> is accepted, but will be converted
  275. * to an empty String.</p>
  276. *
  277. * @param contentStart the new content start text
  278. */
  279. public void setContentStart(String contentStart) {
  280. super.setContentStart(contentStart);
  281. }
  282. //---------------------------------------------------------------------
  283. /**
  284. * <p>Gets the content end text.</p>
  285. *
  286. * @return the current content end text
  287. */
  288. public String getContentEnd() {
  289. return super.getContentEnd();
  290. }
  291. /**
  292. * <p>Sets the content end text.</p>
  293. *
  294. * <p><code>null</code> is accepted, but will be converted
  295. * to an empty String.</p>
  296. *
  297. * @param contentEnd the new content end text
  298. */
  299. public void setContentEnd(String contentEnd) {
  300. super.setContentEnd(contentEnd);
  301. }
  302. //---------------------------------------------------------------------
  303. /**
  304. * <p>Gets the field name value separator text.</p>
  305. *
  306. * @return the current field name value separator text
  307. */
  308. public String getFieldNameValueSeparator() {
  309. return super.getFieldNameValueSeparator();
  310. }
  311. /**
  312. * <p>Sets the field name value separator text.</p>
  313. *
  314. * <p><code>null</code> is accepted, but will be converted
  315. * to an empty String.</p>
  316. *
  317. * @param fieldNameValueSeparator the new field name value separator text
  318. */
  319. public void setFieldNameValueSeparator(String fieldNameValueSeparator) {
  320. super.setFieldNameValueSeparator(fieldNameValueSeparator);
  321. }
  322. //---------------------------------------------------------------------
  323. /**
  324. * <p>Gets the field separator text.</p>
  325. *
  326. * @return the current field separator text
  327. */
  328. public String getFieldSeparator() {
  329. return super.getFieldSeparator();
  330. }
  331. /**
  332. * <p>Sets the field separator text.</p>
  333. *
  334. * <p><code>null</code> is accepted, but will be converted
  335. * to an empty String.</p>
  336. *
  337. * @param fieldSeparator the new field separator text
  338. */
  339. public void setFieldSeparator(String fieldSeparator) {
  340. super.setFieldSeparator(fieldSeparator);
  341. }
  342. //---------------------------------------------------------------------
  343. /**
  344. * <p>Gets whether the field separator should be added at the start
  345. * of each buffer.</p>
  346. *
  347. * @return the fieldSeparatorAtStart flag
  348. * @since 2.0
  349. */
  350. public boolean isFieldSeparatorAtStart() {
  351. return super.isFieldSeparatorAtStart();
  352. }
  353. /**
  354. * <p>Sets whether the field separator should be added at the start
  355. * of each buffer.</p>
  356. *
  357. * @param fieldSeparatorAtStart the fieldSeparatorAtStart flag
  358. * @since 2.0
  359. */
  360. public void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
  361. super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
  362. }
  363. //---------------------------------------------------------------------
  364. /**
  365. * <p>Gets whether the field separator should be added at the end
  366. * of each buffer.</p>
  367. *
  368. * @return fieldSeparatorAtEnd flag
  369. * @since 2.0
  370. */
  371. public boolean isFieldSeparatorAtEnd() {
  372. return super.isFieldSeparatorAtEnd();
  373. }
  374. /**
  375. * <p>Sets whether the field separator should be added at the end
  376. * of each buffer.</p>
  377. *
  378. * @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag
  379. * @since 2.0
  380. */
  381. public void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
  382. super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
  383. }
  384. //---------------------------------------------------------------------
  385. /**
  386. * <p>Gets the text to output when <code>null</code> found.</p>
  387. *
  388. * @return the current text to output when <code>null</code> found
  389. */
  390. public String getNullText() {
  391. return super.getNullText();
  392. }
  393. /**
  394. * <p>Sets the text to output when <code>null</code> found.</p>
  395. *
  396. * <p><code>null</code> is accepted, but will be converted
  397. * to an empty String.</p>
  398. *
  399. * @param nullText the new text to output when <code>null</code> found
  400. */
  401. public void setNullText(String nullText) {
  402. super.setNullText(nullText);
  403. }
  404. //---------------------------------------------------------------------
  405. /**
  406. * <p>Gets the text to output when a <code>Collection</code>,
  407. * <code>Map</code> or <code>Array</code> size is output.</p>
  408. *
  409. * <p>This is output before the size value.</p>
  410. *
  411. * @return the current start of size text
  412. */
  413. public String getSizeStartText() {
  414. return super.getSizeStartText();
  415. }
  416. /**
  417. * <p>Sets the start text to output when a <code>Collection</code>,
  418. * <code>Map</code> or <code>Array</code> size is output.</p>
  419. *
  420. * <p>This is output before the size value.</p>
  421. *
  422. * <p><code>null</code> is accepted, but will be converted to
  423. * an empty String.</p>
  424. *
  425. * @param sizeStartText the new start of size text
  426. */
  427. public void setSizeStartText(String sizeStartText) {
  428. super.setSizeStartText(sizeStartText);
  429. }
  430. //---------------------------------------------------------------------
  431. /**
  432. * Gets the end text to output when a <code>Collection</code>,
  433. * <code>Map</code> or <code>Array</code> size is output.</p>
  434. *
  435. * <p>This is output after the size value.</p>
  436. *
  437. * @return the current end of size text
  438. */
  439. public String getSizeEndText() {
  440. return super.getSizeEndText();
  441. }
  442. /**
  443. * <p>Sets the end text to output when a <code>Collection</code>,
  444. * <code>Map</code> or <code>Array</code> size is output.</p>
  445. *
  446. * <p>This is output after the size value.</p>
  447. *
  448. * <p><code>null</code> is accepted, but will be converted
  449. * to an empty String.</p>
  450. *
  451. * @param sizeEndText the new end of size text
  452. */
  453. public void setSizeEndText(String sizeEndText) {
  454. super.setSizeEndText(sizeEndText);
  455. }
  456. //---------------------------------------------------------------------
  457. /**
  458. * <p>Gets the start text to output when an <code>Object</code> is
  459. * output in summary mode.</p>
  460. *
  461. * <P>This is output before the size value.</p>
  462. *
  463. * @return the current start of summary text
  464. */
  465. public String getSummaryObjectStartText() {
  466. return super.getSummaryObjectStartText();
  467. }
  468. /**
  469. * <p>Sets the start text to output when an <code>Object</code> is
  470. * output in summary mode.</p>
  471. *
  472. * <p>This is output before the size value.</p>
  473. *
  474. * <p><code>null</code> is accepted, but will be converted to
  475. * an empty String.</p>
  476. *
  477. * @param summaryObjectStartText the new start of summary text
  478. */
  479. public void setSummaryObjectStartText(String summaryObjectStartText) {
  480. super.setSummaryObjectStartText(summaryObjectStartText);
  481. }
  482. //---------------------------------------------------------------------
  483. /**
  484. * <p>Gets the end text to output when an <code>Object</code> is
  485. * output in summary mode.</p>
  486. *
  487. * <p>This is output after the size value.</p>
  488. *
  489. * @return the current end of summary text
  490. */
  491. public String getSummaryObjectEndText() {
  492. return super.getSummaryObjectEndText();
  493. }
  494. /**
  495. * <p>Sets the end text to output when an <code>Object</code> is
  496. * output in summary mode.</p>
  497. *
  498. * <p>This is output after the size value.</p>
  499. *
  500. * <p><code>null</code> is accepted, but will be converted to
  501. * an empty String.</p>
  502. *
  503. * @param summaryObjectEndText the new end of summary text
  504. */
  505. public void setSummaryObjectEndText(String summaryObjectEndText) {
  506. super.setSummaryObjectEndText(summaryObjectEndText);
  507. }
  508. //---------------------------------------------------------------------
  509. }