001 /*
002 * Copyright 2006 Google Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package com.google.gwt.user.client;
017
018 import com.google.gwt.core.client.JavaScriptObject;
019
020 /**
021 * An opaque handle to a native DOM Element. An <code>Element</code> cannot be
022 * created directly. Instead, use the <code>Element</code> type when returning
023 * a native DOM element from JSNI methods. An <code>Element</code> passed back
024 * into JSNI becomes the original DOM element the <code>Element</code> was
025 * created from, and can be accessed in JavaScript code as expected. This is
026 * typically done by calling methods in the
027 * {@link com.google.gwt.user.client.DOM} class.
028 */
029 public final class Element extends JavaScriptObject {
030
031 /**
032 * Creates a new <code>Element</code>. This constructor is used internally
033 * and should never be called by a user.
034 *
035 * @param opaque the underlying DOM element
036 */
037 Element(int opaque) {
038 super(opaque);
039 }
040
041 /*
042 * (non-Javadoc)
043 *
044 * @see java.lang.Object#equals(java.lang.Object)
045 */
046 public boolean equals(Object other) {
047 if (other instanceof Element)
048 return DOM.compare(this, (Element) other);
049
050 return super.equals(other);
051 }
052
053 /*
054 * (non-Javadoc)
055 *
056 * @see java.lang.Object#hashCode()
057 */
058 public int hashCode() {
059 return super.hashCode();
060 }
061
062 /*
063 * (non-Javadoc)
064 *
065 * @see java.lang.Object#toString()
066 */
067 public String toString() {
068 return DOM.toString(this);
069 };
070 }