alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.tax.dom;

import org.w3c.dom.*;
import org.netbeans.tax.*;

/**
 *
 * @author  Petr Kuzel
 */
class AttrImpl extends NodeImpl implements Attr {
    
    private final TreeAttribute peer;
    
    /** Creates a new instance of AttrImpl */
    public AttrImpl(TreeAttribute peer) {
        this.peer = peer;
    }
    
    /** The name of this node, depending on its type; see the table above.
     *
     */
    public String getNodeName() {
        return getName();
    }    
    
    /** A code representing the type of the underlying object, as defined above.
     *
     */
    public short getNodeType() {
        return Node.ATTRIBUTE_NODE;
    }
    
    /** The value of this node, depending on its type; see the table above.
     * When it is defined to be null, setting it has no effect.
     * @exception DOMException
     *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
     * @exception DOMException
     *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
     *   fit in a DOMString variable on the implementation
     *   platform.
     *
     */
    public String getNodeValue() throws DOMException {
        return getValue();        
    }
    
    /** The parent of this node. All nodes, except Attr,
     * Document, DocumentFragment,
     * Entity, and Notation may have a parent.
     * However, if a node has just been created and not yet added to the
     * tree, or if it has been removed from the tree, this is
     * null.
     *
     */
    public Node getParentNode() {
        return null;
    }
    
    /** Returns the name of this attribute.
     *
     */
    public String getName() {
        return peer.getQName();
    }
    
    /** The Element node this attribute is attached to or
     * null if this attribute is not in use.
     * @since DOM Level 2
     *
     */
    public Element getOwnerElement() {
        return Wrapper.wrap(peer.getOwnerElement());
    }
    
    /** If this attribute was explicitly given a value in the original
     * document, this is true; otherwise, it is
     * false. Note that the implementation is in charge of this
     * attribute, not the user. If the user changes the value of the
     * attribute (even if it ends up having the same value as the default
     * value) then the specified flag is automatically flipped
     * to true. To re-specify the attribute as the default
     * value from the DTD, the user must delete the attribute. The
     * implementation will then make a new attribute available with
     * specified set to false and the default
     * value (if one exists).
     * 
In summary: If the attribute has an assigned value in the document * then specified is true, and the value is * the assigned value.If the attribute has no assigned value in the * document and has a default value in the DTD, then * specified is false, and the value is the * default value in the DTD.If the attribute has no assigned value in * the document and has a value of #IMPLIED in the DTD, then the * attribute does not appear in the structure model of the document.If * the ownerElement attribute is null (i.e. * because it was just created or was set to null by the * various removal and cloning operations) specified is * true. * */ public boolean getSpecified() { return peer.isSpecified(); } /** On retrieval, the value of the attribute is returned as a string. * Character and general entity references are replaced with their * values. See also the method getAttribute on the * Element interface. *
On setting, this creates a Text node with the unparsed * contents of the string. I.e. any characters that an XML processor * would recognize as markup are instead treated as literal text. See * also the method setAttribute on the Element * interface. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * */ public String getValue() { return peer.getValue(); } /** On retrieval, the value of the attribute is returned as a string. * Character and general entity references are replaced with their * values. See also the method getAttribute on the * Element interface. *
On setting, this creates a Text node with the unparsed * contents of the string. I.e. any characters that an XML processor * would recognize as markup are instead treated as literal text. See * also the method setAttribute on the Element * interface. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * */ public void setValue(String value) throws DOMException { throw new ROException(); } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.