public class Element extends Node
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DRAGGABLE_AUTO
Constant returned from
getDraggable() . |
static java.lang.String |
DRAGGABLE_FALSE
Constant returned from
getDraggable() . |
static java.lang.String |
DRAGGABLE_TRUE
Constant returned from
getDraggable() . |
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE
Modifier | Constructor and Description |
---|---|
protected |
Element() |
Modifier and Type | Method and Description |
---|---|
boolean |
addClassName(java.lang.String className)
Adds a name to this element's class property.
|
static Element |
as(JavaScriptObject o)
|
static Element |
as(Node node)
|
void |
blur()
Removes keyboard focus from this element.
|
void |
dispatchEvent(NativeEvent evt)
Dispatched the given event with this element as its target.
|
void |
focus()
Gives keyboard focus to this element.
|
int |
getAbsoluteBottom()
Gets an element's absolute bottom coordinate in the document's coordinate
system.
|
int |
getAbsoluteLeft()
Gets an element's absolute left coordinate in the document's coordinate
system.
|
int |
getAbsoluteRight()
Gets an element's absolute right coordinate in the document's coordinate
system.
|
int |
getAbsoluteTop()
Gets an element's absolute top coordinate in the document's coordinate
system.
|
java.lang.String |
getAttribute(java.lang.String name)
Retrieves an attribute value by name.
|
java.lang.String |
getClassName()
The class attribute of the element.
|
int |
getClientHeight()
Returns the inner height of an element in pixels, including padding but not
the horizontal scrollbar height, border, or margin.
|
int |
getClientWidth()
Returns the inner width of an element in pixels, including padding but not
the vertical scrollbar width, border, or margin.
|
java.lang.String |
getDir()
Specifies the base direction of directionally neutral text and the
directionality of tables.
|
java.lang.String |
getDraggable()
Returns the draggable attribute of this element.
|
NodeList<Element> |
getElementsByTagName(java.lang.String name)
Returns a NodeList of all descendant Elements with a given tag name, in the
order in which they are encountered in a preorder traversal of this Element
tree.
|
Element |
getFirstChildElement()
The first child of element this element.
|
java.lang.String |
getId()
The element's identifier.
|
java.lang.String |
getInnerHTML()
All of the markup and content within a given element.
|
java.lang.String |
getInnerText()
The text between the start and end tags of the object.
|
java.lang.String |
getLang()
Language code defined in RFC 1766.
|
Element |
getNextSiblingElement()
The element immediately following this element.
|
int |
getOffsetHeight()
The height of an element relative to the layout.
|
int |
getOffsetLeft()
The number of pixels that the upper left corner of the current element is
offset to the left within the offsetParent node.
|
Element |
getOffsetParent()
Returns a reference to the object which is the closest (nearest in the
containment hierarchy) positioned containing element.
|
int |
getOffsetTop()
The number of pixels that the upper top corner of the current element is
offset to the top within the offsetParent node.
|
int |
getOffsetWidth()
The width of an element relative to the layout.
|
Element |
getPreviousSiblingElement()
The element immediately preceding this element.
|
boolean |
getPropertyBoolean(java.lang.String name)
Gets a boolean property from this element.
|
double |
getPropertyDouble(java.lang.String name)
Gets a double property from this element.
|
int |
getPropertyInt(java.lang.String name)
Gets an integer property from this element.
|
JavaScriptObject |
getPropertyJSO(java.lang.String name)
Gets a JSO property from this element.
|
java.lang.Object |
getPropertyObject(java.lang.String name)
Gets an object property from this element.
|
java.lang.String |
getPropertyString(java.lang.String name)
Gets a property from this element.
|
int |
getScrollHeight()
The height of the scroll view of an element.
|
int |
getScrollLeft()
The number of pixels that an element's content is scrolled from the left.
|
int |
getScrollTop()
The number of pixels that an element's content is scrolled from the top.
|
int |
getScrollWidth()
The width of the scroll view of an element.
|
java.lang.String |
getString()
Gets a string representation of this element (as outer HTML).
|
Style |
getStyle()
Gets this element's
Style object. |
int |
getTabIndex()
The index that represents the element's position in the tabbing order.
|
java.lang.String |
getTagName()
Gets the element's full tag name, including the namespace-prefix if
present.
|
java.lang.String |
getTitle()
The element's advisory title.
|
boolean |
hasAttribute(java.lang.String name)
Determines whether an element has an attribute with a given name.
|
boolean |
hasClassName(java.lang.String className)
Checks if this element's class property contains specified class name.
|
boolean |
hasTagName(java.lang.String tagName)
Determines whether this element has the given tag name.
|
(package private) static int |
indexOfName(java.lang.String nameList,
java.lang.String name)
Returns the index of the first occurrence of name in a space-separated list of names,
or -1 if not found.
|
static boolean |
is(JavaScriptObject o)
Determines whether the given
JavaScriptObject can be cast to an
Element . |
static boolean |
is(Node node)
|
void |
removeAttribute(java.lang.String name)
Removes an attribute by name.
|
boolean |
removeClassName(java.lang.String className)
Removes a name from this element's class property.
|
void |
replaceClassName(java.lang.String oldClassName,
java.lang.String newClassName)
Replace one class name with another.
|
void |
scrollIntoView()
Scrolls this element into view.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Adds a new attribute.
|
void |
setClassName(java.lang.String className)
The class attribute of the element.
|
void |
setDir(java.lang.String dir)
Specifies the base direction of directionally neutral text and the
directionality of tables.
|
void |
setDraggable(java.lang.String draggable)
|
void |
setId(java.lang.String id)
The element's identifier.
|
void |
setInnerHTML(java.lang.String html)
All of the markup and content within a given element.
|
void |
setInnerSafeHtml(SafeHtml html)
All of the markup and content within a given element.
|
void |
setInnerText(java.lang.String text)
The text between the start and end tags of the object.
|
void |
setLang(java.lang.String lang)
Language code defined in RFC 1766.
|
void |
setPropertyBoolean(java.lang.String name,
boolean value)
Sets a boolean property on this element.
|
void |
setPropertyDouble(java.lang.String name,
double value)
Sets a double property on this element.
|
void |
setPropertyInt(java.lang.String name,
int value)
Sets an integer property on this element.
|
void |
setPropertyJSO(java.lang.String name,
JavaScriptObject value)
Sets a JSO property on this element.
|
void |
setPropertyObject(java.lang.String name,
java.lang.Object value)
Sets an object property on this element.
|
void |
setPropertyString(java.lang.String name,
java.lang.String value)
Sets a property on this element.
|
void |
setScrollLeft(int scrollLeft)
The number of pixels that an element's content is scrolled to the left.
|
void |
setScrollTop(int scrollTop)
The number of pixels that an element's content is scrolled to the top.
|
void |
setTabIndex(int tabIndex)
The index that represents the element's position in the tabbing order.
|
void |
setTitle(java.lang.String title)
The element's advisory title.
|
void |
toggleClassName(java.lang.String className)
Add the class name if it doesn't exist or removes it if does.
|
appendChild, cloneNode, getChild, getChildCount, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, hasChildNodes, hasParentElement, insertAfter, insertBefore, insertFirst, isOrHasChild, removeAllChildren, removeChild, removeFromParent, replaceChild, setNodeValue
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
public static final java.lang.String DRAGGABLE_AUTO
getDraggable()
.public static final java.lang.String DRAGGABLE_FALSE
getDraggable()
.public static final java.lang.String DRAGGABLE_TRUE
getDraggable()
.public static Element as(JavaScriptObject o)
public static boolean is(JavaScriptObject o)
JavaScriptObject
can be cast to an
Element
. A null
object will cause this method to
return false
.public static boolean is(Node node)
public final boolean addClassName(java.lang.String className)
className
- the class name to be addedtrue
if this element did not already have the specified class namesetClassName(String)
public final void blur()
public final void dispatchEvent(NativeEvent evt)
uncaught exception handler
as usual.evt
- the event to be dispatchedpublic final void focus()
public final int getAbsoluteBottom()
public final int getAbsoluteLeft()
public final int getAbsoluteRight()
public final int getAbsoluteTop()
public final java.lang.String getAttribute(java.lang.String name)
Element
and its specific subclasses to retrieve attributes and
properties.name
- The name of the attribute to retrievepublic final java.lang.String getClassName()
public final int getClientHeight()
public final int getClientWidth()
public final java.lang.String getDir()
public final java.lang.String getDraggable()
DRAGGABLE_AUTO
, DRAGGABLE_FALSE
, or
DRAGGABLE_TRUE
public final NodeList<Element> getElementsByTagName(java.lang.String name)
name
- The name of the tag to match on. The special value "*" matches
all tagspublic final Element getFirstChildElement()
public final java.lang.String getId()
public final java.lang.String getInnerHTML()
public final java.lang.String getInnerText()
public final java.lang.String getLang()
public final Element getNextSiblingElement()
public final int getOffsetHeight()
public final int getOffsetLeft()
public final Element getOffsetParent()
public final int getOffsetTop()
public final int getOffsetWidth()
public final Element getPreviousSiblingElement()
public final boolean getPropertyBoolean(java.lang.String name)
name
- the name of the property to be retrievedpublic final double getPropertyDouble(java.lang.String name)
name
- the name of the property to be retrievedpublic final int getPropertyInt(java.lang.String name)
name
- the name of the property to be retrievedpublic final JavaScriptObject getPropertyJSO(java.lang.String name)
name
- the name of the property to be retrievedpublic final java.lang.Object getPropertyObject(java.lang.String name)
name
- the name of the property to be retrievedpublic final java.lang.String getPropertyString(java.lang.String name)
name
- the name of the property to be retrievedpublic final int getScrollHeight()
public final int getScrollLeft()
If the element is in RTL mode, this method will return a negative value of the number of pixels scrolled from the right.
public final int getScrollTop()
public final int getScrollWidth()
public final java.lang.String getString()
JavaScriptObject.toString()
because it is final in
JavaScriptObject
.public final int getTabIndex()
public final java.lang.String getTagName()
public final java.lang.String getTitle()
public final boolean hasAttribute(java.lang.String name)
Note that IE, prior to version 8, will return false-positives for names that collide with element properties (e.g., style, width, and so forth).
name
- the name of the attributetrue
if this element has the specified attributepublic final boolean hasClassName(java.lang.String className)
className
- the class name to be addedtrue
if this element has the specified class namepublic final boolean hasTagName(java.lang.String tagName)
tagName
- the tag name, including namespace-prefix (if present)true
if the element has the given tag namepublic final void removeAttribute(java.lang.String name)
public final boolean removeClassName(java.lang.String className)
className
- the class name to be removedtrue
if this element had the specified class namesetClassName(String)
static int indexOfName(java.lang.String nameList, java.lang.String name)
nameList
- list of space delimited namesname
- a non-empty string. Should be already trimmed.public final void toggleClassName(java.lang.String className)
className
- the class name to be toggledpublic final void replaceClassName(java.lang.String oldClassName, java.lang.String newClassName)
oldClassName
- the class name to be replacednewClassName
- the class name to replace itpublic final void scrollIntoView()
This method crawls up the DOM hierarchy, adjusting the scrollLeft and scrollTop properties of each scrollable element to ensure that the specified element is completely in view. It adjusts each scroll position by the minimum amount necessary.
public final void setAttribute(java.lang.String name, java.lang.String value)
name
- The name of the attribute to create or altervalue
- Value to set in string formpublic final void setClassName(java.lang.String className)
public final void setDir(java.lang.String dir)
public final void setDraggable(java.lang.String draggable)
draggable
- a String constantspublic final void setId(java.lang.String id)
public final void setInnerHTML(java.lang.String html)
public final void setInnerSafeHtml(SafeHtml html)
public final void setInnerText(java.lang.String text)
public final void setLang(java.lang.String lang)
public final void setPropertyBoolean(java.lang.String name, boolean value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyDouble(java.lang.String name, double value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyInt(java.lang.String name, int value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyJSO(java.lang.String name, JavaScriptObject value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyObject(java.lang.String name, java.lang.Object value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyString(java.lang.String name, java.lang.String value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setScrollLeft(int scrollLeft)
public final void setScrollTop(int scrollTop)
public final void setTabIndex(int tabIndex)
public final void setTitle(java.lang.String title)