You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kalumet-commits@incubator.apache.org by jb...@apache.org on 2011/11/17 16:17:53 UTC

svn commit: r1203238 - in /incubator/kalumet/trunk/console/src/main/java: ./ org/ org/apache/ org/apache/kalumet/ org/apache/kalumet/console/ org/apache/kalumet/console/utils/ org/apache/kalumet/console/utils/StackTraceUtils.java

Author: jbonofre
Date: Thu Nov 17 16:17:52 2011
New Revision: 1203238

URL: http://svn.apache.org/viewvc?rev=1203238&view=rev
Log:
Add console StackTraceUtils to create a string representation of a stack trace

Added:
    incubator/kalumet/trunk/console/src/main/java/
    incubator/kalumet/trunk/console/src/main/java/org/
    incubator/kalumet/trunk/console/src/main/java/org/apache/
    incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/
    incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/
    incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/
    incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/StackTraceUtils.java

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/StackTraceUtils.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/StackTraceUtils.java?rev=1203238&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/StackTraceUtils.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/utils/StackTraceUtils.java Thu Nov 17 16:17:52 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.console.utils;
+
+/**
+ * Util class to manipulate exception stack trace.
+ */
+public class StackTraceUtils {
+
+    /**
+     * Convert a stack trace elements into a string.
+     * WARNING: depending of the exception chain, this method call consume heap memory.
+     *
+     * @param elements the stack trace elements.
+     * @return the string representation of the stack trace.
+     */
+    public static String toString(StackTraceElement[] elements) {
+        String trace = "";
+        for (int i = 0; i < elements.length; i++) {
+            trace += elements[i].toString() + "\n";
+        }
+        return trace;
+    }
+
+}