FileDocCategorySizeDatePackage
AttrImpl.javaAPI DocAndroid 1.5 API5118Wed May 06 22:41:06 BST 2009org.apache.harmony.xml.dom

AttrImpl

public class AttrImpl extends NodeImpl implements Attr
Provides a straightforward implementation of the corresponding W3C DOM interface. The class is used internally only, thus only notable members that are not in the original interface are documented (the W3C docs are quite extensive). Hope that's ok.

Some of the fields may have package visibility, so other classes belonging to the DOM implementation can easily access them while maintaining the DOM tree structure.

Fields Summary
ElementImpl
ownerElement
private boolean
namespaceAware
private String
namespaceURI
private String
localName
private String
prefix
private String
value
Constructors Summary
AttrImpl(DocumentImpl document, String namespaceURI, String qualifiedName)

        super(document);

        namespaceAware = true;
        this.namespaceURI = namespaceURI;

        if (qualifiedName == null || "".equals(qualifiedName)) {
            throw new DOMException(DOMException.NAMESPACE_ERR, qualifiedName);
        }
        
        int prefixSeparator = qualifiedName.lastIndexOf(":");
        if (prefixSeparator != -1) {
            setPrefix(qualifiedName.substring(0, prefixSeparator));
            qualifiedName = qualifiedName.substring(prefixSeparator + 1);
        }

        localName = qualifiedName;
        
        if ("".equals(localName)) {
            throw new DOMException(DOMException.NAMESPACE_ERR, localName);
        }
        
        if ("xmlns".equals(localName) && !"http://www.w3.org/2000/xmlns/".equals(namespaceURI)) {
            throw new DOMException(DOMException.NAMESPACE_ERR, localName);
        }
            
        if (!document.isXMLIdentifier(localName)) {
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, localName);
        }
            
        value = "";
    
AttrImpl(DocumentImpl document, String name)

        super(document);

        this.namespaceAware = false;
        
        int prefixSeparator = name.lastIndexOf(":");
        if (prefixSeparator != -1) {
            String prefix = name.substring(0, prefixSeparator);
            String localName = name.substring(prefixSeparator + 1);
            
            if (!document.isXMLIdentifier(prefix) || !document.isXMLIdentifier(localName)) {
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, name);
            }
        } else {
            if (!document.isXMLIdentifier(name)) {
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, name);
            }
        }
        
        this.localName = name;
    
Methods Summary
public java.lang.StringgetLocalName()

        return namespaceAware ? localName : null;
    
public java.lang.StringgetName()

        return (prefix != null ? prefix + ":" : "") + localName;
    
public java.lang.StringgetNamespaceURI()

        return namespaceURI;
    
public java.lang.StringgetNodeName()

        return getName();
    
public shortgetNodeType()

        return Node.ATTRIBUTE_NODE;
    
public java.lang.StringgetNodeValue()

        return getValue();
    
public org.w3c.dom.ElementgetOwnerElement()

        return ownerElement;
    
public java.lang.StringgetPrefix()

        return prefix;
    
public booleangetSpecified()

        return value != null;
    
public java.lang.StringgetValue()

        return value;
    
public voidsetNodeValue(java.lang.String value)

        setValue(value);
    
public voidsetPrefix(java.lang.String prefix)

        if (!namespaceAware) {
            throw new DOMException(DOMException.NAMESPACE_ERR, prefix);
        }
        
        if (prefix != null) {
            if (namespaceURI == null || !document.isXMLIdentifier(prefix) || "xmlns".equals(prefix)) {
                throw new DOMException(DOMException.NAMESPACE_ERR, prefix);
            }

            if ("xml".equals(prefix) && !"http://www.w3.org/XML/1998/namespace".equals(namespaceURI)) {
                throw new DOMException(DOMException.NAMESPACE_ERR, prefix);
            }
        }

        this.prefix = prefix;
    
public voidsetValue(java.lang.String value)

        this.value = value;