Remove convenience toStringWithStatics APIs.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c8f84f3a22
commit
7f13c39483
|
@ -104,7 +104,7 @@ import org.apache.commons.lang.ClassUtils;
|
|||
* @author Stephen Colebourne
|
||||
* @author Pete Gieser
|
||||
* @since 2.0
|
||||
* @version $Id: ReflectionToStringBuilder.java,v 1.13 2003/10/23 22:27:45 ggregory Exp $
|
||||
* @version $Id: ReflectionToStringBuilder.java,v 1.14 2003/11/03 00:21:19 ggregory Exp $
|
||||
*/
|
||||
public class ReflectionToStringBuilder extends ToStringBuilder {
|
||||
|
||||
|
@ -335,91 +335,6 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
|
|||
return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Is this convenience API really needed?
|
||||
*
|
||||
* <p>This method uses reflection to build a suitable
|
||||
* <code>toString</code> value which includes static fields.</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 fields are not output.</p>
|
||||
*
|
||||
* <p>Superclass fields will be appended up to and including
|
||||
* <code>java.lang.Object</code>.</p>
|
||||
*
|
||||
* <p>The default <code>ToStringStyle</code> is used.</p>
|
||||
*
|
||||
* @param object the Object to be output
|
||||
* @return the String result
|
||||
* @throws IllegalArgumentException if the Object is <code>null</code>
|
||||
*/
|
||||
public static Object toStringWithStatics(Object object) {
|
||||
return toString(object, null, false, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Is this convenience API really needed?
|
||||
*
|
||||
* <p>This method uses reflection to build a suitable
|
||||
* <code>toString</code> value which includes static fields.</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 fields are not output.</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>The default <code>ToStringStyle</code> is used.</p>
|
||||
*
|
||||
* @param object the Object to be output
|
||||
* @param reflectUpToClass the superclass to reflect up to (inclusive),
|
||||
* may be <code>null</code>
|
||||
* @return the String result
|
||||
* @throws IllegalArgumentException if the Object is <code>null</code>
|
||||
*/
|
||||
public static Object toStringWithStatics(Object object, Class reflectUpToClass) {
|
||||
return toString(object, null, false, true, reflectUpToClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Is this convenience API really needed?
|
||||
*
|
||||
* <p>This method uses reflection to build a suitable
|
||||
* <code>toString</code> value which includes static fields.</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 fields are not output.</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 object the Object to be output
|
||||
* @param style the style of the <code>toString</code> to create,
|
||||
* may be <code>null</code>
|
||||
* @param reflectUpToClass the superclass to reflect up to (inclusive),
|
||||
* may be <code>null</code>
|
||||
* @return the String result
|
||||
* @throws IllegalArgumentException if the Object is <code>null</code>
|
||||
*/
|
||||
public static Object toStringWithStatics(Object object, ToStringStyle style, Class reflectUpToClass) {
|
||||
return toString(object, style, false, true, reflectUpToClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Unregisters the given object.</p>
|
||||
*
|
||||
|
|
|
@ -68,7 +68,7 @@ import junit.textui.TestRunner;
|
|||
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||
* @author <a href="mailto:alex@apache.org">Alex Chaffee</a>
|
||||
* @version $Id: ToStringBuilderTest.java,v 1.11 2003/10/23 22:26:00 ggregory Exp $
|
||||
* @version $Id: ToStringBuilderTest.java,v 1.12 2003/11/03 00:20:55 ggregory Exp $
|
||||
*/
|
||||
public class ToStringBuilderTest extends TestCase {
|
||||
|
||||
|
@ -850,10 +850,10 @@ public class ToStringBuilderTest extends TestCase {
|
|||
ReflectionToStringBuilder.toString(instance1, null, true, true, SimpleReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, SimpleReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -869,10 +869,10 @@ public class ToStringBuilderTest extends TestCase {
|
|||
ReflectionToStringBuilder.toString(instance1, null, true, true, ReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345,instanceString=instanceString,instanceInt=67890]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, null, ReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, ReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345,instanceString=instanceString,instanceInt=67890]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, ReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, ReflectionStaticFieldsFixture.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -888,10 +888,39 @@ public class ToStringBuilderTest extends TestCase {
|
|||
ReflectionToStringBuilder.toString(instance1, null, false, true, SimpleReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString2=staticString2,staticInt2=67890,staticString=staticString,staticInt=12345]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
assertEquals(
|
||||
this.toBaseString(instance1) + "[staticString2=staticString2,staticInt2=67890,staticString=staticString,staticInt=12345]",
|
||||
ReflectionToStringBuilder.toStringWithStatics(instance1, SimpleReflectionStaticFieldsFixture.class));
|
||||
this.toStringWithStatics(instance1, null, SimpleReflectionStaticFieldsFixture.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>This method uses reflection to build a suitable
|
||||
* <code>toString</code> value which includes static fields.</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 fields are not output.</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 object the Object to be output
|
||||
* @param style the style of the <code>toString</code> to create,
|
||||
* may be <code>null</code>
|
||||
* @param reflectUpToClass the superclass to reflect up to (inclusive),
|
||||
* may be <code>null</code>
|
||||
* @return the String result
|
||||
* @throws IllegalArgumentException if the Object is <code>null</code>
|
||||
*/
|
||||
public Object toStringWithStatics(Object object, ToStringStyle style, Class reflectUpToClass) {
|
||||
return ReflectionToStringBuilder.toString(object, style, false, true, reflectUpToClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue