FileDocCategorySizeDatePackage
HTMLElementImpl.javaAPI DocApache Xerces 3.0.19031Fri Sep 14 20:33:52 BST 2007org.apache.html.dom

HTMLElementImpl

public class HTMLElementImpl extends org.apache.xerces.dom.ElementImpl implements HTMLElement
Implements an HTML-specific element, an {@link org.w3c.dom.Element} that will only appear inside HTML documents. This element extends {@link org.apache.xerces.dom.ElementImpl} by adding methods for directly manipulating HTML-specific attributes. All HTML elements gain access to the id, title, lang, dir and class attributes. Other elements add their own specific attributes.
xerces.internal
version
$Revision: 449313 $ $Date: 2006-09-23 18:01:43 -0400 (Sat, 23 Sep 2006) $
author
Assaf Arkin
see
org.w3c.dom.html.HTMLElement

Fields Summary
private static final long
serialVersionUID
Constructors Summary
public HTMLElementImpl(HTMLDocumentImpl owner, String tagName)
Constructor required owner document and element tag name. Will be called by the constructor of specific element types but with a known tag name. Assures that the owner document is an HTML element.

param
owner The owner HTML document
param
tagName The element's tag name


                                                       
           
        super( owner, tagName.toUpperCase(Locale.ENGLISH) );
    
Methods Summary
java.lang.Stringcapitalize(java.lang.String value)
Convenience method used to capitalize a one-off attribute value before it is returned. For example, the align values "LEFT" and "left" will both return as "Left".

param
value The value of the attribute
return
The capitalized value

        
        char[]    chars;
        int        i;
        
        // Convert string to charactares. Convert the first one to upper case,
        // the other characters to lower case, and return the converted string.
        chars = value.toCharArray();
        if ( chars.length > 0 ) {
            chars[ 0 ] = Character.toUpperCase( chars[ 0 ] );
            for ( i = 1 ; i < chars.length ; ++i ) {
                chars[ i ] = Character.toLowerCase( chars[ i ] );
            }
            return String.valueOf( chars );
        }
        return value;
    
public java.lang.StringgetAttribute(java.lang.String attrName)

        return super.getAttribute( attrName.toLowerCase(Locale.ENGLISH) );
    
public java.lang.StringgetAttributeNS(java.lang.String namespaceURI, java.lang.String localName)

        if ( namespaceURI != null && namespaceURI.length() > 0 ) {
            return super.getAttributeNS( namespaceURI, localName );
        }
        return super.getAttribute( localName.toLowerCase(Locale.ENGLISH) );
    
public org.w3c.dom.AttrgetAttributeNode(java.lang.String attrName)

        return super.getAttributeNode( attrName.toLowerCase(Locale.ENGLISH) );
    
public org.w3c.dom.AttrgetAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)

        if ( namespaceURI != null && namespaceURI.length() > 0 ) {
            return super.getAttributeNodeNS( namespaceURI, localName );
        }
        return super.getAttributeNode( localName.toLowerCase(Locale.ENGLISH) );
    
booleangetBinary(java.lang.String name)
Convenience method used to translate an attribute value into a boolean value. If the attribute has an associated value (even an empty string), it is set and true is returned. If the attribute does not exist, false is returend.

param
value The value of the attribute
return
True or false depending on whether the attribute has been set

        return ( getAttributeNode( name ) != null );
    
java.lang.StringgetCapitalized(java.lang.String name)
Convenience method used to capitalize a one-off attribute value before it is returned. For example, the align values "LEFT" and "left" will both return as "Left".

param
name The name of the attribute
return
The capitalized value

        String    value;
        char[]    chars;
        int        i;
        
        value = getAttribute( name );
        if ( value != null ) {
            // Convert string to charactares. Convert the first one to upper case,
            // the other characters to lower case, and return the converted string.
            chars = value.toCharArray();
            if ( chars.length > 0 ) {
                chars[ 0 ] = Character.toUpperCase( chars[ 0 ] );
                for ( i = 1 ; i < chars.length ; ++i ) {
                    chars[ i ] = Character.toLowerCase( chars[ i ] );
                }
                return String.valueOf( chars );
            }
        }
        return value;
    
public java.lang.StringgetClassName()

        return getAttribute( "class" );
    
public java.lang.StringgetDir()

        return getAttribute( "dir" );
    
public final org.w3c.dom.NodeListgetElementsByTagName(java.lang.String tagName)

        return super.getElementsByTagName( tagName.toUpperCase(Locale.ENGLISH) );
    
public final org.w3c.dom.NodeListgetElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)

        if ( namespaceURI != null && namespaceURI.length() > 0 ) {
            return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
        }
        return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
    
public org.w3c.dom.html.HTMLFormElementgetForm()
Convenience method returns the form in which this form element is contained. This method is exposed for form elements through the DOM API, but other elements have no access to it through the API.

        Node parent = getParentNode(); 
        while ( parent != null ) {
            if ( parent instanceof HTMLFormElement ) {
                return (HTMLFormElement) parent;
            }
            parent = parent.getParentNode();
        }
        return null;
    
public java.lang.StringgetId()

        return getAttribute( "id" );
    
intgetInteger(java.lang.String value)
Convenience method used to translate an attribute value into an integer value. Returns the integer value or zero if the attribute is not a valid numeric string.

param
value The value of the attribute
return
The integer value, or zero if not a valid numeric string

        try {
            return Integer.parseInt( value );
        }
        catch ( NumberFormatException except ) {
            return 0;
        }
    
public java.lang.StringgetLang()

        return getAttribute( "lang" );
    
public java.lang.StringgetTitle()

        return getAttribute( "title" );
    
voidsetAttribute(java.lang.String name, boolean value)
Convenience method used to set a boolean attribute. If the value is true, the attribute is set to an empty string. If the value is false, the attribute is removed. HTML 4.0 understands empty strings as set attributes.

param
name The name of the attribute
param
value The value of the attribute

        if ( value ) {
            setAttribute( name, name );
        }
        else {
            removeAttribute( name );
        }
    
public voidsetClassName(java.lang.String className)

        setAttribute( "class", className );
    
public voidsetDir(java.lang.String dir)

        setAttribute( "dir", dir );
    
public voidsetId(java.lang.String id)

        setAttribute( "id", id );
    
public voidsetLang(java.lang.String lang)

        setAttribute( "lang", lang );
    
public voidsetTitle(java.lang.String title)

        setAttribute( "title", title );