KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > junit > client > impl > StackTraceWrapper


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.junit.client.impl;
17
18 import com.google.gwt.user.client.rpc.IsSerializable;
19
20 /**
21  * A helper class for converting a generic {@link StackTraceElement} into an
22  * Object that can be serialized for RPC.
23  */

24 public final class StackTraceWrapper implements IsSerializable {
25
26   /**
27    * Creates a {@link StackTraceWrapper} array around an existing
28    * {@link StackTraceElement} array.
29    *
30    * @param stackTrace the {@link StackTraceElement} array to wrap.
31    */

32   public static StackTraceWrapper[] wrapStackTrace(
33       StackTraceElement JavaDoc[] stackTrace) {
34     int len = stackTrace.length;
35     StackTraceWrapper[] result = new StackTraceWrapper[len];
36     for (int i = 0; i < len; ++i) {
37       result[i] = new StackTraceWrapper(stackTrace[i]);
38     }
39     return result;
40   }
41
42   /**
43    * Corresponds to {@link StackTraceElement#getClassName()}.
44    */

45   public String JavaDoc className;
46
47   /**
48    * Corresponds to {@link StackTraceElement#getFileName()}.
49    */

50   public String JavaDoc fileName;
51
52   /**
53    * Corresponds to {@link StackTraceElement#getLineNumber()}.
54    */

55   public int lineNumber;
56
57   /**
58    * Corresponds to {@link StackTraceElement#getMethodName()}.
59    */

60   public String JavaDoc methodName;
61
62   /**
63    * Creates an empty {@link StackTraceWrapper}.
64    */

65   public StackTraceWrapper() {
66   }
67
68   /**
69    * Creates a {@link StackTraceWrapper} around an existing
70    * {@link StackTraceElement}.
71    *
72    * @param ste the {@link StackTraceElement} to wrap.
73    */

74   public StackTraceWrapper(StackTraceElement JavaDoc ste) {
75     className = ste.getClassName();
76     fileName = ste.getFileName();
77     lineNumber = ste.getLineNumber();
78     methodName = ste.getMethodName();
79   }
80 }
81
Popular Tags