Package org.springframework.core.style
Class DefaultValueStyler
java.lang.Object
org.springframework.core.style.DefaultValueStyler
- All Implemented Interfaces:
ValueStyler
- Direct Known Subclasses:
SimpleValueStyler
Converts objects to String form, generally for debugging purposes,
using Spring's
toString styling conventions.
Uses the reflective visitor pattern underneath the hood to nicely encapsulate styling algorithms for each type of styled object.
- Since:
- 1.2.2
- Author:
- Keith Donald, Juergen Hoeller, Sam Brannen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionStyle the given value, returning a String representation.protected StringstyleArray(Object[] array) Generate a styled version of the supplied array.protected StringstyleClass(Class<?> clazz) Generate a styled version of the suppliedClass.protected StringstyleCollection(Collection<?> collection) Generate a styled version of the suppliedCollection.protected <K,V> String Generate a styled version of the suppliedMap.protected StringstyleMapEntry(Map.Entry<?, ?> entry) Generate a styled version of the suppliedMap.Entry.protected StringstyleMethod(Method method) Generate a styled version of the suppliedMethod.protected StringGenerate a styled version ofnull.protected StringstyleObject(Object obj) Generate a styled version of the suppliedObject.protected StringstyleString(String str) Generate a styled version of the suppliedString.
-
Constructor Details
-
DefaultValueStyler
public DefaultValueStyler()
-
-
Method Details
-
style
Description copied from interface:ValueStylerStyle the given value, returning a String representation.- Specified by:
stylein interfaceValueStyler- Parameters:
value- the Object value to style- Returns:
- the styled String
-
styleNull
Generate a styled version ofnull.The default implementation returns
"[null]".- Returns:
- a styled version of
null - Since:
- 6.0
-
styleString
Generate a styled version of the suppliedString.The default implementation returns the supplied string wrapped in single quotes.
- Returns:
- a styled version of the supplied string
- Since:
- 6.0
-
styleClass
Generate a styled version of the suppliedClass.The default implementation delegates to
ClassUtils.getShortName(Class).- Returns:
- a styled version of the supplied class
- Since:
- 6.0
-
styleMethod
Generate a styled version of the suppliedMethod.The default implementation returns the method's name and the short name of the method's declaring class, separated by the
"@"symbol.- Returns:
- a styled version of the supplied method
- Since:
- 6.0
-
styleMap
Generate a styled version of the suppliedMap.- Returns:
- a styled version of the supplied map
- Since:
- 6.0
-
styleMapEntry
Generate a styled version of the suppliedMap.Entry.- Returns:
- a styled version of the supplied map entry
- Since:
- 6.0
-
styleCollection
Generate a styled version of the suppliedCollection.- Returns:
- a styled version of the supplied collection
- Since:
- 6.0
-
styleArray
Generate a styled version of the supplied array.- Returns:
- a styled version of the supplied array
- Since:
- 6.0
-
styleObject
Generate a styled version of the suppliedObject.This method is only invoked by
style(Object)as a fallback, if none of the otherstyle*()methods is suitable for the object's type.The default implementation delegates to
String.valueOf(Object).- Returns:
- a styled version of the supplied object
- Since:
- 6.0
-