Checkstyle and trailing spaces.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1083218 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oliver Heger 2011-03-19 16:42:55 +00:00
parent 57706fae97
commit b78378ca53
1 changed files with 76 additions and 72 deletions

View File

@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -32,34 +32,34 @@
* <p>
* Assists in implementing {@link Object#toString()} methods using reflection.
* </p>
*
*
* <p>
* This class uses reflection to determine the fields to append. Because these fields are usually private, the class
* uses {@link java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean)} to
* change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are
* set up correctly.
* </p>
*
*
* <p>
* A typical invocation for this method would look like:
* </p>
*
*
* <pre>
* public String toString() {
* return ReflectionToStringBuilder.toString(this);
* }</pre>
*
*
*
*
*
*
* <p>
* You can also use the builder to debug 3rd party objects:
* </p>
*
*
* <pre>
* System.out.println("An object: " + ReflectionToStringBuilder.toString(anObject));</pre>
*
*
*
*
*
*
* <p>
* A subclass can control field output by overriding the methods:
* <ul>
@ -71,7 +71,7 @@
* For example, this method does <i>not</i> include the <code>password</code> field in the returned
* <code>String</code>:
* </p>
*
*
* <pre>
* public String toString() {
* return (new ReflectionToStringBuilder(this) {
@ -80,14 +80,14 @@
* }
* }).toString();
* }</pre>
*
*
*
*
*
*
* <p>
* The exact format of the <code>toString</code> is determined by the {@link ToStringStyle} passed into the
* constructor.
* </p>
*
*
* @author Apache Software Foundation
* @author Gary Gregory
* @author Pete Gieser
@ -100,18 +100,18 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* <p>
* Builds a <code>toString</code> value using the default <code>ToStringStyle</code> through reflection.
* </p>
*
*
* <p>
* It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
* </p>
*
*
* <p>
* Transient members will be not be included, as they are likely derived. Static fields will not be included.
* Superclass fields will be appended.
* </p>
*
*
* @param object
* the Object to be output
* @return the String result
@ -126,22 +126,22 @@ public static String toString(Object object) {
* <p>
* Builds a <code>toString</code> value through reflection.
* </p>
*
*
* <p>
* It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
* </p>
*
*
* <p>
* Transient members will be not be included, as they are likely derived. Static fields will not be included.
* Superclass fields will be appended.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
* </p>
*
*
* @param object
* the Object to be output
* @param style
@ -158,26 +158,26 @@ public static String toString(Object object, ToStringStyle style) {
* <p>
* Builds a <code>toString</code> value through reflection.
* </p>
*
*
* <p>
* It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
* </p>
*
*
* <p>
* If the <code>outputTransients</code> is <code>true</code>, transient members will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
* </p>
*
*
* <p>
* Static fields will not be included. Superclass fields will be appended.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
* </p>
*
*
* @param object
* the Object to be output
* @param style
@ -196,31 +196,31 @@ public static String toString(Object object, ToStringStyle style, boolean output
* <p>
* Builds a <code>toString</code> value through reflection.
* </p>
*
*
* <p>
* It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
* </p>
*
*
* <p>
* If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
* </p>
*
*
* <p>
* If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
* ignored.
* </p>
*
*
* <p>
* Static fields will not be included. Superclass fields will be appended.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
* </p>
*
*
* @param object
* the Object to be output
* @param style
@ -242,32 +242,34 @@ public static String toString(Object object, ToStringStyle style, boolean output
* <p>
* Builds a <code>toString</code> value through reflection.
* </p>
*
*
* <p>
* It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
* </p>
*
*
* <p>
* If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
* </p>
*
*
* <p>
* If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
* ignored.
* </p>
*
*
* <p>
* Superclass fields will be appended up to and including the specified superclass. A null superclass is treated as
* <code>java.lang.Object</code>.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
* </p>
*
*
* @param <T>
* the type of the object
* @param object
* the Object to be output
* @param style
@ -292,7 +294,7 @@ public static <T> String toString(
/**
* Builds a String for a toString method excluding the given field name.
*
*
* @param object
* The object to "toString".
* @param excludeFieldName
@ -305,7 +307,7 @@ public static String toStringExclude(Object object, final String excludeFieldNam
/**
* Builds a String for a toString method excluding the given field names.
*
*
* @param object
* The object to "toString".
* @param excludeFieldNames
@ -318,9 +320,9 @@ public static String toStringExclude(Object object, Collection<String> excludeFi
/**
* Converts the given Collection into an array of Strings. The returned array does not contain <code>null</code>
* entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element
* entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element
* is <code>null</code>.
*
*
* @param collection
* The collection to convert
* @return A new array of Strings.
@ -334,9 +336,9 @@ static String[] toNoNullStringArray(Collection<String> collection) {
/**
* Returns a new array of Strings without null elements. Internal method used to normalize exclude lists
* (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}
* (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}
* if an array element is <code>null</code>.
*
*
* @param array
* The array to check
* @return The given array or a new array without null.
@ -350,11 +352,11 @@ static String[] toNoNullStringArray(Object[] array) {
}
return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
/**
* Builds a String for a toString method excluding the given field names.
*
*
* @param object
* The object to "toString".
* @param excludeFieldNames
@ -391,11 +393,11 @@ public static String toStringExclude(Object object, String[] excludeFieldNames)
* <p>
* Constructor.
* </p>
*
*
* <p>
* This constructor outputs using the default style set with <code>setDefaultStyle</code>.
* </p>
*
*
* @param object
* the Object to build a <code>toString</code> for, must not be <code>null</code>
* @throws IllegalArgumentException
@ -409,11 +411,11 @@ public ReflectionToStringBuilder(Object object) {
* <p>
* Constructor.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default style is used.
* </p>
*
*
* @param object
* the Object to build a <code>toString</code> for, must not be <code>null</code>
* @param style
@ -429,15 +431,15 @@ public ReflectionToStringBuilder(Object object, ToStringStyle style) {
* <p>
* Constructor.
* </p>
*
*
* <p>
* If the style is <code>null</code>, the default style is used.
* </p>
*
*
* <p>
* If the buffer is <code>null</code>, a new one is created.
* </p>
*
*
* @param object
* the Object to build a <code>toString</code> for
* @param style
@ -453,7 +455,9 @@ public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffe
/**
* Constructor.
*
*
* @param <T>
* the type of the object
* @param object
* the Object to build a <code>toString</code> for
* @param style
@ -484,7 +488,7 @@ public <T> ReflectionToStringBuilder(
* <li>Static fields are appended only if {@link #isAppendStatics()} returns <code>true</code>.
* <li>Inner class fields are not appened.</li>
* </ul>
*
*
* @param field
* The Field to test.
* @return Whether or not to append the given <code>Field</code>.
@ -514,12 +518,12 @@ protected boolean accept(Field field) {
* <p>
* Appends the fields and values defined by the given object of the given Class.
* </p>
*
*
* <p>
* If a cycle is detected as an object is &quot;toString()'ed&quot;, such an object is rendered as if
* <code>Object.toString()</code> had been called and not implemented by the object.
* </p>
*
*
* @param clazz
* The class of object parameter
*/
@ -560,7 +564,7 @@ public String[] getExcludeFieldNames() {
* <p>
* Gets the last super class to stop appending fields for.
* </p>
*
*
* @return The last super class to stop appending fields for.
*/
public Class<?> getUpToClass() {
@ -571,16 +575,16 @@ public Class<?> getUpToClass() {
* <p>
* Calls <code>java.lang.reflect.Field.get(Object)</code>.
* </p>
*
*
* @param field
* The Field to query.
* @return The Object from the given Field.
*
*
* @throws IllegalArgumentException
* see {@link java.lang.reflect.Field#get(Object)}
* @throws IllegalAccessException
* see {@link java.lang.reflect.Field#get(Object)}
*
*
* @see java.lang.reflect.Field#get(Object)
*/
protected Object getValue(Field field) throws IllegalArgumentException, IllegalAccessException {
@ -591,7 +595,7 @@ protected Object getValue(Field field) throws IllegalArgumentException, IllegalA
* <p>
* Gets whether or not to append static fields.
* </p>
*
*
* @return Whether or not to append static fields.
* @since 2.1
*/
@ -603,7 +607,7 @@ public boolean isAppendStatics() {
* <p>
* Gets whether or not to append transient fields.
* </p>
*
*
* @return Whether or not to append transient fields.
*/
public boolean isAppendTransients() {
@ -614,7 +618,7 @@ public boolean isAppendTransients() {
* <p>
* Append to the <code>toString</code> an <code>Object</code> array.
* </p>
*
*
* @param array
* the array to add to the <code>toString</code>
* @return this
@ -628,7 +632,7 @@ public ReflectionToStringBuilder reflectionAppendArray(Object array) {
* <p>
* Sets whether or not to append static fields.
* </p>
*
*
* @param appendStatics
* Whether or not to append static fields.
* @since 2.1
@ -641,7 +645,7 @@ public void setAppendStatics(boolean appendStatics) {
* <p>
* Sets whether or not to append transient fields.
* </p>
*
*
* @param appendTransients
* Whether or not to append transient fields.
*/
@ -651,7 +655,7 @@ public void setAppendTransients(boolean appendTransients) {
/**
* Sets the field names to exclude.
*
*
* @param excludeFieldNamesParam
* The excludeFieldNames to excluding from toString or <code>null</code>.
* @return <code>this</code>
@ -670,7 +674,7 @@ public ReflectionToStringBuilder setExcludeFieldNames(String[] excludeFieldNames
* <p>
* Sets the last super class to stop appending fields for.
* </p>
*
*
* @param clazz
* The last super class to stop appending fields for.
*/
@ -688,7 +692,7 @@ public void setUpToClass(Class<?> clazz) {
* <p>
* Gets the String built by this builder.
* </p>
*
*
* @return the built string
*/
@Override