1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.harmony.xml.dom; 18 19 import org.w3c.dom.DOMException; 20 import org.w3c.dom.Node; 21 import org.w3c.dom.ProcessingInstruction; 22 23 /** 24 * Provides a straightforward implementation of the corresponding W3C DOM 25 * interface. The class is used internally only, thus only notable members that 26 * are not in the original interface are documented (the W3C docs are quite 27 * extensive). Hope that's ok. 28 * <p> 29 * Some of the fields may have package visibility, so other classes belonging to 30 * the DOM implementation can easily access them while maintaining the DOM tree 31 * structure. 32 */ 33 public final class ProcessingInstructionImpl extends LeafNodeImpl implements 34 ProcessingInstruction { 35 36 private String target; 37 38 private String data; 39 ProcessingInstructionImpl(DocumentImpl document, String target, String data)40 ProcessingInstructionImpl(DocumentImpl document, String target, String data) { 41 super(document); 42 this.target = target; // TODO: validate that target is well-formed 43 this.data = data; 44 } 45 getData()46 public String getData() { 47 return data; 48 } 49 50 @Override getNodeName()51 public String getNodeName() { 52 return target; 53 } 54 55 @Override getNodeType()56 public short getNodeType() { 57 return Node.PROCESSING_INSTRUCTION_NODE; 58 } 59 60 @Override getNodeValue()61 public String getNodeValue() { 62 return data; 63 } 64 getTarget()65 public String getTarget() { 66 return target; 67 } 68 setData(String data)69 public void setData(String data) throws DOMException { 70 this.data = data; 71 } 72 73 } 74