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: DefaultProcessingInstruction.java,v 1.7 2001/06/20 18:59:23 jstrachan Exp $ 008 */ 009 010package org.dom4j.tree; 011 012import java.util.Map; 013 014import org.dom4j.Node; 015import org.dom4j.Element; 016 017/** <p><code>DefaultProcessingInstruction</code> is the default 018 * Processing Instruction implementation. 019 * It is a doubly linked node which supports the parent relationship 020 * and can be modified in place.</p> 021 * 022 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 023 * @version $Revision: 1.7 $ 024 */ 025public class DefaultProcessingInstruction extends FlyweightProcessingInstruction { 026 027 /** The parent of this node */ 028 private Element parent; 029 030 /** <p>This will create a new PI with the given target and values</p> 031 * 032 * @param target is the name of the PI 033 * @param values is the <code>Map</code> values for the PI 034 */ 035 public DefaultProcessingInstruction(String target,Map values) { 036 super(target, values); 037 } 038 039 /** <p>This will create a new PI with the given target and values</p> 040 * 041 * @param target is the name of the PI 042 * @param values is the values for the PI 043 */ 044 public DefaultProcessingInstruction(String target,String values) { 045 super(target, values); 046 } 047 048 /** <p>This will create a new PI with the given target and values</p> 049 * 050 * @param parent is the parent element 051 * @param target is the name of the PI 052 * @param values is the values for the PI 053 */ 054 public DefaultProcessingInstruction(Element parent,String target,String values) { 055 super(target, values); 056 this.parent = parent; 057 } 058 059 public void setTarget(String target) { 060 this.target = target; 061 } 062 063 public void setText(String text) { 064 this.text = text; 065 this.values = parseValues(text); 066 } 067 068 public void setValues(Map values) { 069 this.values = values; 070 this.text = toString(values); 071 } 072 073 public void setValue(String name, String value) { 074 values.put(name, value); 075 } 076 077 078 public Element getParent() { 079 return parent; 080 } 081 082 public void setParent(Element parent) { 083 this.parent = parent; 084 } 085 086 public boolean supportsParent() { 087 return true; 088 } 089 090 public boolean isReadOnly() { 091 return false; 092 } 093} 094 095 096 097 098/* 099 * Redistribution and use of this software and associated documentation 100 * ("Software"), with or without modification, are permitted provided 101 * that the following conditions are met: 102 * 103 * 1. Redistributions of source code must retain copyright 104 * statements and notices. Redistributions must also contain a 105 * copy of this document. 106 * 107 * 2. Redistributions in binary form must reproduce the 108 * above copyright notice, this list of conditions and the 109 * following disclaimer in the documentation and/or other 110 * materials provided with the distribution. 111 * 112 * 3. The name "DOM4J" must not be used to endorse or promote 113 * products derived from this Software without prior written 114 * permission of MetaStuff, Ltd. For written permission, 115 * please contact dom4j-info@metastuff.com. 116 * 117 * 4. Products derived from this Software may not be called "DOM4J" 118 * nor may "DOM4J" appear in their names without prior written 119 * permission of MetaStuff, Ltd. DOM4J is a registered 120 * trademark of MetaStuff, Ltd. 121 * 122 * 5. Due credit should be given to the DOM4J Project 123 * (http://dom4j.org/). 124 * 125 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 126 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 127 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 128 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 129 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 130 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 131 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 132 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 133 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 134 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 135 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 136 * OF THE POSSIBILITY OF SUCH DAMAGE. 137 * 138 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 139 * 140 * $Id: DefaultProcessingInstruction.java,v 1.7 2001/06/20 18:59:23 jstrachan Exp $ 141 */