001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: DOMProcessingInstruction.java,v 1.4 2001/06/20 18:59:23 jstrachan Exp $ 008 */ 009 010package org.dom4j.dom; 011 012import java.util.Map; 013 014import org.dom4j.Element; 015import org.dom4j.ProcessingInstruction; 016import org.dom4j.QName; 017import org.dom4j.tree.DefaultProcessingInstruction; 018 019import org.w3c.dom.Document; 020import org.w3c.dom.DOMException; 021import org.w3c.dom.NamedNodeMap; 022import org.w3c.dom.NodeList; 023 024/** <p><code>DOMText</code> implements a Text node which 025 * supports the W3C DOM API.</p> 026 * 027 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 028 * @version $Revision: 1.4 $ 029 */ 030public class DOMProcessingInstruction extends DefaultProcessingInstruction implements org.w3c.dom.ProcessingInstruction { 031 032 public DOMProcessingInstruction(String target, Map values) { 033 super(target, values); 034 } 035 036 public DOMProcessingInstruction(String target, String values) { 037 super(target, values); 038 } 039 040 public DOMProcessingInstruction(Element parent, String target, String values) { 041 super(parent, target, values); 042 } 043 044 045 // org.w3c.dom.Node interface 046 //------------------------------------------------------------------------- 047 public String getNamespaceURI() { 048 return DOMNodeHelper.getNamespaceURI(this); 049 } 050 051 public String getPrefix() { 052 return DOMNodeHelper.getPrefix(this); 053 } 054 055 public void setPrefix(String prefix) throws DOMException { 056 DOMNodeHelper.setPrefix(this, prefix); 057 } 058 059 public String getLocalName() { 060 return DOMNodeHelper.getLocalName(this); 061 } 062 063 public String getNodeName() { 064 return getName(); 065 } 066 067 //already part of API 068 // 069 //public short getNodeType(); 070 071 072 073 public String getNodeValue() throws DOMException { 074 return DOMNodeHelper.getNodeValue(this); 075 } 076 077 public void setNodeValue(String nodeValue) throws DOMException { 078 DOMNodeHelper.setNodeValue(this, nodeValue); 079 } 080 081 082 public org.w3c.dom.Node getParentNode() { 083 return DOMNodeHelper.getParentNode(this); 084 } 085 086 public NodeList getChildNodes() { 087 return DOMNodeHelper.getChildNodes(this); 088 } 089 090 public org.w3c.dom.Node getFirstChild() { 091 return DOMNodeHelper.getFirstChild(this); 092 } 093 094 public org.w3c.dom.Node getLastChild() { 095 return DOMNodeHelper.getLastChild(this); 096 } 097 098 public org.w3c.dom.Node getPreviousSibling() { 099 return DOMNodeHelper.getPreviousSibling(this); 100 } 101 102 public org.w3c.dom.Node getNextSibling() { 103 return DOMNodeHelper.getNextSibling(this); 104 } 105 106 public NamedNodeMap getAttributes() { 107 return DOMNodeHelper.getAttributes(this); 108 } 109 110 public Document getOwnerDocument() { 111 return DOMNodeHelper.getOwnerDocument(this); 112 } 113 114 public org.w3c.dom.Node insertBefore( 115 org.w3c.dom.Node newChild, 116 org.w3c.dom.Node refChild 117 ) throws DOMException { 118 return DOMNodeHelper.insertBefore(this, newChild, refChild); 119 } 120 121 public org.w3c.dom.Node replaceChild( 122 org.w3c.dom.Node newChild, 123 org.w3c.dom.Node oldChild 124 ) throws DOMException { 125 return DOMNodeHelper.replaceChild(this, newChild, oldChild); 126 } 127 128 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException { 129 return DOMNodeHelper.removeChild(this, oldChild); 130 } 131 132 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException { 133 return DOMNodeHelper.appendChild(this, newChild); 134 } 135 136 public boolean hasChildNodes() { 137 return DOMNodeHelper.hasChildNodes(this); 138 } 139 140 public org.w3c.dom.Node cloneNode(boolean deep) { 141 return DOMNodeHelper.cloneNode(this, deep); 142 } 143 144 public void normalize() { 145 DOMNodeHelper.normalize(this); 146 } 147 148 public boolean isSupported(String feature, String version) { 149 return DOMNodeHelper.isSupported(this, feature, version); 150 } 151 152 public boolean hasAttributes() { 153 return DOMNodeHelper.hasAttributes(this); 154 } 155 156 // org.w3c.dom.ProcessingInstruction interface 157 //------------------------------------------------------------------------- 158 159 //public String getTarget(); 160 161 public String getData() { 162 return getText(); 163 } 164 165 public void setData(String data) throws DOMException { 166 if ( isReadOnly() ) { 167 throw new DOMException( 168 DOMException.NO_MODIFICATION_ALLOWED_ERR, 169 "This ProcessingInstruction is read only" 170 ); 171 } 172 else { 173 setText(data); 174 } 175 } 176 177 // Implementation methods 178 //------------------------------------------------------------------------- 179} 180 181 182 183 184/* 185 * Redistribution and use of this software and associated documentation 186 * ("Software"), with or without modification, are permitted provided 187 * that the following conditions are met: 188 * 189 * 1. Redistributions of source code must retain copyright 190 * statements and notices. Redistributions must also contain a 191 * copy of this document. 192 * 193 * 2. Redistributions in binary form must reproduce the 194 * above copyright notice, this list of conditions and the 195 * following disclaimer in the documentation and/or other 196 * materials provided with the distribution. 197 * 198 * 3. The name "DOM4J" must not be used to endorse or promote 199 * products derived from this Software without prior written 200 * permission of MetaStuff, Ltd. For written permission, 201 * please contact dom4j-info@metastuff.com. 202 * 203 * 4. Products derived from this Software may not be called "DOM4J" 204 * nor may "DOM4J" appear in their names without prior written 205 * permission of MetaStuff, Ltd. DOM4J is a registered 206 * trademark of MetaStuff, Ltd. 207 * 208 * 5. Due credit should be given to the DOM4J Project 209 * (http://dom4j.org/). 210 * 211 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 212 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 213 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 214 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 215 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 216 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 217 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 218 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 219 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 220 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 221 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 222 * OF THE POSSIBILITY OF SUCH DAMAGE. 223 * 224 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 225 * 226 * $Id: DOMProcessingInstruction.java,v 1.4 2001/06/20 18:59:23 jstrachan Exp $ 227 */