org.chromium.sdk/src/org/chromium/sdk/internal/ExceptionDataImpl.java
changeset 2 e4420d2515f1
child 52 f577ea64429e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.chromium.sdk/src/org/chromium/sdk/internal/ExceptionDataImpl.java	Wed Dec 23 17:13:18 2009 -0800
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.sdk.internal;
+
+import org.chromium.sdk.ExceptionData;
+import org.chromium.sdk.JsObject;
+
+/**
+ * An immutable implementation of the ExceptionData interface.
+ */
+public class ExceptionDataImpl implements ExceptionData {
+
+  private final InternalContext context;
+  private final String sourceText;
+  private final ValueMirror mirror;
+  private final String name;
+  private final boolean isUncaught;
+  private final String exceptionText;
+  private JsObject cachedException;
+
+  public ExceptionDataImpl(InternalContext context, ValueMirror mirror, String name,
+      boolean isUncaught, String sourceText, String exceptionText) {
+    this.context = context;
+    this.mirror = mirror;
+    this.name = name;
+    this.isUncaught = isUncaught;
+    this.sourceText = sourceText;
+    this.exceptionText = exceptionText;
+  }
+
+  public JsObject getExceptionObject() {
+    if (cachedException == null) {
+      cachedException = new JsObjectImpl(context.getTopFrameImpl(), name, mirror);
+    }
+    return cachedException;
+  }
+
+  public String getSourceText() {
+    return sourceText;
+  }
+
+  public boolean isUncaught() {
+    return isUncaught;
+  }
+
+  public String getExceptionMessage() {
+    return exceptionText;
+  }
+
+}