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