⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attrimpl.java

📁 数据仓库工具
💻 JAVA
字号:
/*
    Copyright (C) 2003  Together

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package org.enhydra.xml;

import org.w3c.dom.Attr;
import org.w3c.dom.Element;


/**
 * @author Tweety
 *
 * A class representing a node in a meta-data tree, which implements
 * the <a href="../../../../api/org/w3c/dom/Attr.html">
 *
 * <p> Namespaces are ignored in this implementation.  The terms "tag
 * name" and "node name" are always considered to be synonymous.
 *
 * @version 1.0
 */
public class AttrImpl extends NodeImpl implements Attr {

	/**
	 * If this attribute was explicitly given a value in the original
     * document, this is <code>true</code>; otherwise, it is
     * <code>false</code>.
	 */
	boolean specified = true;

	/**
	 * Document owner.
	 */
	Element owner;

	/**
	 * Attribute name.
	 */
	String name;

	/**
	 * Attribute value.
	 */
	String value;



	/**
	 * Constructs an empty <code>AttrImpl</code>.
	 *
	 * @param owner document owner.
	 * @param name node name.
	 * @param value node value.
	 */
	public AttrImpl(Element owner, String name, String value) {
		this.owner = owner;
		this.name = name;
		this.value = value;
	}

	/**
	 * Constructs a <code>AttrImpl</code> from the given node.
	 *
	 * @param attr , as a <code>AttrImpl</code>.
	 */
	public AttrImpl(Attr attr) {
		this.owner = attr.getOwnerElement();
		this.name = attr.getName();
		this.value = attr.getValue();
	}

	/**
	 * Returns the attribute name associated with this node.
	 *
	 * @return the attribute name, as a <code>String</code>.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the name associated with this node.
	 *
	 * @return the name, as a <code>String</code>.
	 */
	public String getNodeName() {
		return name;
	}

	/**
	 * Returns the node type.
	 *
	 * @return the <code>ATTRIBUTE_NODE</code> node type.
	 */
	public short getNodeType() {
		return ATTRIBUTE_NODE;
	}


	/**
     * If this attribute was explicitly given a value in the original
     * document, this is <code>true</code>; otherwise, it is
     * <code>false</code>. 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 <code>specified</code> flag is automatically flipped
     * to <code>true</code>. 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
     * <code>specified</code> set to <code>false</code> and the default
     * value (if one exists).
     * <br>In summary: If the attribute has an assigned value in the document
     * then <code>specified</code> is <code>true</code>, 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
     * <code>specified</code> is <code>false</code>, 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 <code>ownerElement</code> attribute is <code>null</code> (i.e.
     * because it was just created or was set to <code>null</code> by the
     * various removal and cloning operations) <code>specified</code> is
     * <code>true</code>.
     *
     * @return always <code>true</code>.
     */
	public boolean getSpecified() {
		return specified;
	}

	/**
	 * Returns the value associated with this attributes.
	 *
	 * @return the node attributes, as a <code>String</code>.
	 */
	public String getValue() {
		return value;
	}

	/**
	 * Returns the value associated with this node.
	 *
	 * @return the node value, as a <code>String</code>.
	 */
	public String getNodeValue() {
		return value;
	}

	/**
	 * Sets the value of this attribute to the given one.
	 *
	 * @param value the new attribute value, as a <code>String</code>.
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * Sets the value of this node to the given one.
	 *
         * @param value is value of the node
	 */
	public void setNodeValue(String value) {
		this.value = value;
	}

	/**
	 * Returns the owner of this attribute.
	 *
	 * @return the attribute owner node.
	 */
	public Element getOwnerElement() {
		return owner;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -