KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > xml > client > impl > DOMItem


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.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   public boolean equals(final Object JavaDoc o) {
40     /*
41      * This method uses the DOM equals method because it happens to work
42      * perfectly for all the browsers we support, and that method is different
43      * for each browser.
44      */

45     if (o instanceof DOMItem) {
46       return DOM.compare(castToElement(this.getJsObject()),
47           castToElement(((DOMItem) o).getJsObject()));
48     }
49     return false;
50   }
51
52   JavaScriptObject getJsObject() {
53     return jsObject;
54   }
55
56   private native com.google.gwt.user.client.Element castToElement(
57       JavaScriptObject toBeCast) /*-{
58     return toBeCast;
59   }-*/
;
60 }
61
Popular Tags