本文整理汇总了Java中org.apache.commons.lang3.ClassUtils.getShortClassName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassUtils.getShortClassName方法的具体用法?Java ClassUtils.getShortClassName怎么用?Java ClassUtils.getShortClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.ClassUtils
的用法示例。
在下文中一共展示了ClassUtils.getShortClassName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toStringWithRootCause
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* 拼装 短异常类名: 异常信息 <-- RootCause的短异常类名: 异常信息
*/
public static String toStringWithRootCause(@Nullable Throwable t) {
if (t == null) {
return StringUtils.EMPTY;
}
final String clsName = ClassUtils.getShortClassName(t, null);
final String message = StringUtils.defaultString(t.getMessage());
Throwable cause = getRootCause(t);
StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message);
if (cause != t) {
sb.append("; <---").append(toStringWithShortName(cause));
}
return sb.toString();
}
示例2: activate
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
public final void activate(OperatorContext ctx)
{
isActive = true;
if (this instanceof Runnable) {
ioThread = new Thread((Runnable)this, "io-" + ClassUtils.getShortClassName(this.getClass()));
ioThread.start();
}
}
示例3: getMessage
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* Gets a short message summarising the exception.
* <p>
* The message returned is of the form
* {ClassNameWithoutPackage}: {ThrowableMessage}
*
* @param th the throwable to get a message for, null returns empty string
* @return the message, non-null
* @since Commons Lang 2.2
*/
public static String getMessage(final Throwable th) {
if (th == null) {
return "";
}
final String clsName = ClassUtils.getShortClassName(th, null);
final String msg = th.getMessage();
return clsName + ": " + StringUtils.defaultString(msg);
}
示例4: getMessage
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* Gets a short message summarising the exception.
* <p>
* The message returned is of the form
* {ClassNameWithoutPackage}: {ThrowableMessage}
*
* @param th the throwable to get a message for, null returns empty string
* @return the message, non-null
* @since Commons Lang 2.2
*/
public static String getMessage(final Throwable th) {
if (th == null) {
return "";
}
final String clsName = ClassUtils.getShortClassName(th, null);
final String msg = th.getMessage();
return clsName + ": " + StringUtils.defaultString(msg);
}
示例5: getReturnType
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* <p>
* getReturnType
* </p>
*
* @param clazz
* a {@link java.lang.Class} object.
* @return a {@link java.lang.String} object.
*/
public static String getReturnType(Class<?> clazz) {
String retVal = ClassUtils.getShortClassName(clazz);
if (primitiveClasses.contains(retVal))
return clazz.getSimpleName();
return retVal;
}
示例6: getShortClassName
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* 返回Class名, 不包含PackageName.
*
* 内部类的话,返回"主类.内部类"
*/
public static String getShortClassName(final Class<?> cls) {
return ClassUtils.getShortClassName(cls);
}
示例7: getShortClassName
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* <p>Gets the short class name for a class.</p>
* <p>
* <p>The short class name is the classname excluding
* the package name.</p>
*
* @param cls the <code>Class</code> to get the short name of
* @return the short name
*/
protected String getShortClassName(final Class<?> cls) {
return ClassUtils.getShortClassName(cls);
}
示例8: getShortClassName
import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
* <p>Gets the short class name for a class.</p>
*
* <p>The short class name is the classname excluding
* the package name.</p>
*
* @param cls the <code>Class</code> to get the short name of
* @return the short name
*/
protected String getShortClassName(final Class<?> cls) {
return ClassUtils.getShortClassName(cls);
}