01: /*
02: * Copyright 2007 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.xml.client.impl;
17:
18: import com.google.gwt.core.client.JavaScriptObject;
19: import com.google.gwt.user.client.DOM;
20:
21: /**
22: * This class is the base class for all DOM object wrappers.
23: */
24: class DOMItem {
25:
26: private JavaScriptObject jsObject;
27:
28: protected DOMItem(JavaScriptObject jso) {
29: this .jsObject = jso;
30: }
31:
32: /**
33: * This method determines equality for DOMItems.
34: *
35: * @param o - the other object being tested for equality
36: * @return true iff the two objects are equal.
37: * @see java.lang.Object#equals(java.lang.Object)
38: */
39: @Override
40: public boolean equals(final Object o) {
41: /*
42: * This method uses the DOM equals method because it happens to work
43: * perfectly for all the browsers we support, and that method is different
44: * for each browser.
45: */
46: if (o instanceof DOMItem) {
47: return DOM.compare(castToElement(this .getJsObject()),
48: castToElement(((DOMItem) o).getJsObject()));
49: }
50: return false;
51: }
52:
53: JavaScriptObject getJsObject() {
54: return jsObject;
55: }
56:
57: private native com.google.gwt.user.client.Element castToElement(
58: JavaScriptObject toBeCast) /*-{
59: return toBeCast;
60: }-*/;
61: }
|