public class ClassUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Class |
forName(String className)
Similar to
Class.forName(java.lang.String), but attempts to load
through the thread context class loader. |
static String |
getFTLTypeDescription(TemplateModel tm)
Returns the type description of a value with FTL terms (not plain class name), as it should be used in
type-related error messages and for debugging purposes.
|
static String |
getShortClassName(Class pClass)
Same as
getShortClassName(pClass, false). |
static String |
getShortClassName(Class pClass,
boolean shortenFreeMarkerClasses)
Returns a class name without "java.lang." and "java.util." prefix; useful for printing class names in error
messages.
|
static String |
getShortClassNameOfObject(Object obj)
|
static String |
getShortClassNameOfObject(Object obj,
boolean shortenFreeMarkerClasses)
getShortClassName(Class, boolean) called with object.getClass(), but returns the fictional
class name Null for a null value. |
public static Class forName(String className) throws ClassNotFoundException
Class.forName(java.lang.String), but attempts to load
through the thread context class loader. Only if thread context class
loader is inaccessible, or it can't find the class will it attempt to
fall back to the class loader that loads the FreeMarker classes.ClassNotFoundExceptionpublic static String getShortClassName(Class pClass)
getShortClassName(pClass, false).public static String getShortClassName(Class pClass, boolean shortenFreeMarkerClasses)
pClass - can be null, in which case the method returns null.shortenFreeMarkerClasses - if true, it will also shorten FreeMarker class names. The exact rules
aren't specified and might change over time, but right now, freemarker.ext.beans.NumberModel for
example becomes to f.e.b.NumberModel.public static String getShortClassNameOfObject(Object obj, boolean shortenFreeMarkerClasses)
getShortClassName(Class, boolean) called with object.getClass(), but returns the fictional
class name Null for a null value.public static String getFTLTypeDescription(TemplateModel tm)
"string (wrapper: f.t.SimpleScalar)" or
"sequence+hash+string (ArrayList wrapped into f.e.b.CollectionModel)".