01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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[] 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 className;
46:
47: /**
48: * Corresponds to {@link StackTraceElement#getFileName()}.
49: */
50: public String 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 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 ste) {
75: className = ste.getClassName();
76: fileName = ste.getFileName();
77: lineNumber = ste.getLineNumber();
78: methodName = ste.getMethodName();
79: }
80: }
|