View Javadoc
1 /* 2 * Copyright (C) 2002 Carsten Krebs (Team-Konzept GmbH & Co.KG) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 package com.teamkonzept.dom4jb.dom; 19 20 21 public abstract class NamedNode extends Node { 22 23 private NodeName name; 24 25 /*** Creates new NamedNode */ 26 public NamedNode( final Document document, final NodeName name ) { 27 this( document, null, name ); 28 } 29 30 /*** Creates new NamedNode */ 31 public NamedNode( final Document document, final Node parent, 32 final NodeName name ) { 33 super( document, parent ); 34 this.name = name; 35 } 36 37 /*** 38 * The name of this node, depending on its type; see the table above. 39 */ 40 public String getNodeName() { 41 return name.getQualifiedName(); 42 } 43 44 /*** 45 * The namespace prefix of this node, or <code>null</code> if it is 46 * unspecified. 47 * <br>Note that setting this attribute, when permitted, changes the 48 * <code>nodeName</code> attribute, which holds the qualified name, as 49 * well as the <code>tagName</code> and <code>name</code> attributes of 50 * the <code>Element</code> and <code>Attr</code> interfaces, when 51 * applicable. 52 * <br>Note also that changing the prefix of an attribute that is known to 53 * have a default value, does not make a new attribute with the default 54 * value and the original prefix appear, since the 55 * <code>namespaceURI</code> and <code>localName</code> do not change. 56 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 57 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 58 * method, such as <code>createElement</code> from the 59 * <code>Document</code> interface, this is always <code>null</code>. 60 * @since DOM Level 2 61 */ 62 public void setPrefix( final String prefix ) { 63 name = name.setPrefix( prefix ); 64 } 65 66 /*** 67 * The namespace prefix of this node, or <code>null</code> if it is 68 * unspecified. 69 * <br>Note that setting this attribute, when permitted, changes the 70 * <code>nodeName</code> attribute, which holds the qualified name, as 71 * well as the <code>tagName</code> and <code>name</code> attributes of 72 * the <code>Element</code> and <code>Attr</code> interfaces, when 73 * applicable. 74 * <br>Note also that changing the prefix of an attribute that is known to 75 * have a default value, does not make a new attribute with the default 76 * value and the original prefix appear, since the 77 * <code>namespaceURI</code> and <code>localName</code> do not change. 78 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 79 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 80 * method, such as <code>createElement</code> from the 81 * <code>Document</code> interface, this is always <code>null</code>. 82 * @since DOM Level 2 83 */ 84 public String getPrefix() { 85 return name.getPrefix(); 86 } 87 88 /*** 89 * Returns the local part of the qualified name of this node. 90 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 91 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 92 * method, such as <code>createElement</code> from the 93 * <code>Document</code> interface, this is always <code>null</code>. 94 * @since DOM Level 2 95 */ 96 public String getLocalName() { 97 return name.getLocalName(); 98 } 99 100 /*** 101 * The namespace URI of this node, or <code>null</code> if it is 102 * unspecified. 103 * <br>This is not a computed value that is the result of a namespace 104 * lookup based on an examination of the namespace declarations in 105 * scope. It is merely the namespace URI given at creation time. 106 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 107 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 108 * method, such as <code>createElement</code> from the 109 * <code>Document</code> interface, this is always <code>null</code>.Per 110 * the Namespaces in XML Specification an attribute does not inherit 111 * its namespace from the element it is attached to. If an attribute is 112 * not explicitly given a namespace, it simply has no namespace. 113 * @since DOM Level 2 114 */ 115 public String getNamespaceURI() { 116 return name.getNamespaceURI(); 117 } 118 119 public NodeName getNamingItem() { 120 return this.name; 121 } 122 }

This page was automatically generated by Maven