Java Code Examples for org.apache.commons.lang.ArrayUtils.EMPTY_STRING_ARRAY

The following are Jave code examples for showing how to use EMPTY_STRING_ARRAY of the org.apache.commons.lang.ArrayUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: ExceptionUtils.java   View Source Code Vote up 6 votes
/**
 * <p>Creates a compact stack trace for the root cause of the supplied
 * <code>Throwable</code>.</p>
 *
 * <p>The output of this method is consistent across JDK versions.
 * It consists of the root exception followed by each of its wrapping
 * exceptions separated by '[wrapped]'. Note that this is the opposite
 * order to the JDK1.4 display.</p>
 *
 * @param throwable  the throwable to examine, may be null
 * @return an array of stack trace frames, never null
 * @since 2.0
 */
public static String[] getRootCauseStackTrace(Throwable throwable) {
    if (throwable == null) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
    Throwable throwables[] = getThrowables(throwable);
    int count = throwables.length;
    ArrayList frames = new ArrayList();
    List nextTrace = getStackFrameList(throwables[count - 1]);
    for (int i = count; --i >= 0;) {
        List trace = nextTrace;
        if (i != 0) {
            nextTrace = getStackFrameList(throwables[i - 1]);
            removeCommonFrames(trace, nextTrace);
        }
        if (i == count - 1) {
            frames.add(throwables[i].toString());
        } else {
            frames.add(WRAPPED_MARKER + throwables[i].toString());
        }
        for (int j = 0; j < trace.size(); j++) {
            frames.add(trace.get(j));
        }
    }
    return (String[]) frames.toArray(new String[0]);
}
 
Example 2
Project: hadoop   File: SimulatedFSDataset.java   View Source Code Vote up 4 votes
@Override // FsDatasetSpi
public VolumeFailureSummary getVolumeFailureSummary() {
  return new VolumeFailureSummary(ArrayUtils.EMPTY_STRING_ARRAY, 0, 0);
}
 
Example 3
Project: lams   File: ExceptionUtils.java   View Source Code Vote up 3 votes
/**
 * <p>Captures the stack trace associated with the specified
 * <code>Throwable</code> object, decomposing it into a list of
 * stack frames.</p>
 *
 * <p>The result of this method vary by JDK version as this method
 * uses {@link Throwable#printStackTrace(java.io.PrintWriter)}.
 * On JDK1.3 and earlier, the cause exception will not be shown
 * unless the specified throwable alters printStackTrace.</p>
 *
 * @param throwable  the <code>Throwable</code> to examine, may be null
 * @return an array of strings describing each stack frame, never null
 */
public static String[] getStackFrames(Throwable throwable) {
    if (throwable == null) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
    return getStackFrames(getStackTrace(throwable));
}
 
Example 4
Project: lams   File: ReflectionToStringBuilder.java   View Source Code Vote up 3 votes
/**
 * Converts the given Collection into an array of Strings. The returned array does not contain <code>null</code>
 * entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element 
 * is <code>null</code>.
 * 
 * @param collection
 *            The collection to convert
 * @return A new array of Strings.
 */
static String[] toNoNullStringArray(Collection collection) {
    if (collection == null) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
    return toNoNullStringArray(collection.toArray());
}