/** * <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(Class cls) { return ClassUtils.getShortClassName(cls); }
/** * <p>Gets the class name minus the package name from a <code>Class</code>.</p> * * @param cls the class to get the short name for. * @return the class name without the package name or an empty string */ public static String getShortClassName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getShortClassName(cls.getName()); }
/** * <p>Gets the class name minus the package name for an <code>Object</code>.</p> * * @param object the class to get the short name for, may be null * @param valueIfNull the value to return if null * @return the class name of the object without the package name, or the null value */ public static String getShortClassName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getShortClassName(object.getClass()); }
/** * 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(Throwable th) { if (th == null) { return ""; } String clsName = ClassUtils.getShortClassName(th, null); String msg = th.getMessage(); return clsName + ": " + StringUtils.defaultString(msg); }
/** * <p>Gets the canonical name minus the package name from a String.</p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * * @param canonicalName the class name to get the short name for * @return the canonical name of the class without the package name or an empty string * @since 2.4 */ public static String getShortCanonicalName(String canonicalName) { return ClassUtils.getShortClassName(getCanonicalName(canonicalName)); }
/** * Get the method invoker's class name * * @param depth * @return */ private String getInvoker(int depth) { Exception e = new Exception(); StackTraceElement[] stes = e.getStackTrace(); if (stes.length > depth) { return ClassUtils.getShortClassName(stes[depth].getClassName()); } return getClass().getSimpleName(); }
/** * <p>Tests for order.</p> * * <p>The default ordering is alphabetic by name, but this * can be overridden by subclasses.</p> * * <p>If the parameter is in a different class loader than this instance, * reflection is used to compare the names.</p> * * @see java.lang.Comparable#compareTo(Object) * @param other the other object to compare to * @return -ve if this is less than the other object, +ve if greater * than, <code>0</code> of equal * @throws ClassCastException if other is not an Enum * @throws NullPointerException if other is <code>null</code> */ public int compareTo(Object other) { if (other == this) { return 0; } if (other.getClass() != this.getClass()) { if (other.getClass().getName().equals(this.getClass().getName())) { return iName.compareTo( getNameInOtherClassLoader(other) ); } throw new ClassCastException( "Different enum class '" + ClassUtils.getShortClassName(other.getClass()) + "'"); } return iName.compareTo(((Enum) other).iName); }
/** * <p>Tests for order.</p> * * <p>The default ordering is numeric by value, but this * can be overridden by subclasses.</p> * * <p>NOTE: From v2.2 the enums must be of the same type. * If the parameter is in a different class loader than this instance, * reflection is used to compare the values.</p> * * @see java.lang.Comparable#compareTo(Object) * @param other the other object to compare to * @return -ve if this is less than the other object, +ve if greater than, * <code>0</code> of equal * @throws ClassCastException if other is not an <code>Enum</code> * @throws NullPointerException if other is <code>null</code> */ public int compareTo(Object other) { if (other == this) { return 0; } if (other.getClass() != this.getClass()) { if (other.getClass().getName().equals(this.getClass().getName())) { return iValue - getValueInOtherClassLoader(other); } throw new ClassCastException( "Different enum class '" + ClassUtils.getShortClassName(other.getClass()) + "'"); } return iValue - ((ValuedEnum) other).iValue; }
/** * <p>Human readable description of this Enum item.</p> * * @return String in the form <code>type[name]</code>, for example: * <code>Color[Red]</code>. Note that the package name is stripped from * the type name. */ public String toString() { if (iToString == null) { String shortName = ClassUtils.getShortClassName(getEnumClass()); iToString = shortName + "[" + getName() + "]"; } return iToString; }
/** * <p>Human readable description of this <code>Enum</code> item.</p> * * @return String in the form <code>type[name=value]</code>, for example: * <code>JavaVersion[Java 1.0=100]</code>. Note that the package name is * stripped from the type name. */ public String toString() { if (iToString == null) { String shortName = ClassUtils.getShortClassName(getEnumClass()); iToString = shortName + "[" + getName() + "=" + getValue() + "]"; } return iToString; } }
private DocumentContainer getLatest(IndexDao indexDao, String guid, String sensorType) { DocumentContainer container; try { Document document = indexDao.getLatest(guid, sensorType); container = new DocumentContainer(document); LOG.debug("Found latest document; indexDao={}, guid={}, sensorType={}, document={}", ClassUtils.getShortClassName(indexDao.getClass()), guid, sensorType, document); } catch (Throwable e) { container = new DocumentContainer(e); LOG.error("Unable to find latest document; indexDao={}, error={}", ClassUtils.getShortClassName(indexDao.getClass()), ExceptionUtils.getRootCauseMessage(e)); } return container; }
/** * Execute a Stellar expression and return the result. The internal state of the executor * is not modified. * * @param expression The expression to execute. * @param state Additional state available to the expression. This most often represents * the values available to the expression from an individual message. The state * maps a variable name to a variable's value. * @param clazz The expected type of the expression's result. * @param <T> The expected type of the expression's result. */ @Override public <T> T execute(String expression, Map<String, Object> state, Class<T> clazz) { Object resultObject = execute(expression, state); // perform type conversion, if necessary T result = ConversionUtils.convert(resultObject, clazz); if (result == null) { throw new IllegalArgumentException(String.format("Unexpected type: expected=%s, actual=%s, expression=%s", clazz.getSimpleName(), ClassUtils.getShortClassName(resultObject,"null"), expression)); } return result; }
private DocumentContainer removeCommentFromAlert(IndexDao indexDao, CommentAddRemoveRequest request, Document latest) { DocumentContainer container; try { Document document = indexDao.removeCommentFromAlert(request, latest); container = new DocumentContainer(document); LOG.debug("Removed comment from alert; indexDao={}, guid={}, sensorType={}, document={}", ClassUtils.getShortClassName(indexDao.getClass()), document.getGuid(), document.getSensorType(), document); } catch (Throwable e) { container = new DocumentContainer(e); LOG.error("Unable to remove comment from alert; indexDao={}, error={}", ClassUtils.getShortClassName(indexDao.getClass()), ExceptionUtils.getRootCauseMessage(e)); } return container; }
private DocumentContainer addCommentToAlert(IndexDao indexDao, CommentAddRemoveRequest request, Document latest) { DocumentContainer container; try { Document document = indexDao.addCommentToAlert(request, latest); container = new DocumentContainer(document); LOG.debug("Added comment to alert; indexDao={}, guid={}, sensorType={}, document={}", ClassUtils.getShortClassName(indexDao.getClass()), document.getGuid(), document.getSensorType(), document); } catch (Throwable e) { container = new DocumentContainer(e); LOG.error("Unable to add comment to alert; indexDao={}, error={}", ClassUtils.getShortClassName(indexDao.getClass()), ExceptionUtils.getRootCauseMessage(e)); } return container; }
sensorType, converterName, ClassUtils.getShortClassName(result, "null"));
/** * <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(Class cls) { return ClassUtils.getShortClassName(cls); }
/** * <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(Class cls) { return ClassUtils.getShortClassName(cls); }
/** * <p>Gets the canonical name minus the package name from a String.</p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * * @param canonicalName the class name to get the short name for * @return the canonical name of the class without the package name or an empty string * @since 2.4 */ public static String getShortCanonicalName(String canonicalName) { return ClassUtils.getShortClassName(getCanonicalName(canonicalName)); }
public void removeListener(StageListener listener) { if (logger.isDebugEnabled()) { logger.debug("## pipeline[{}] remove listener [{}]", getPipelineId(), ClassUtils.getShortClassName(listener.getClass())); } this.listeners.remove(listener); }
public GlobalTask(Long pipelineId){ this.pipelineId = pipelineId; setName(createTaskName(pipelineId, ClassUtils.getShortClassName(this.getClass()))); pendingFuture = new HashMap<Long, Future>(); }