|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DefaultProcessingInstruction.java | - | 21,4% | 27,3% | 24% |
|
1 | /* | |
2 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
3 | * | |
4 | * This software is open source. | |
5 | * See the bottom of this file for the licence. | |
6 | * | |
7 | * $Id: DefaultProcessingInstruction.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $ | |
8 | */ | |
9 | ||
10 | package org.dom4j.tree; | |
11 | ||
12 | import java.util.Map; | |
13 | ||
14 | import org.dom4j.Element; | |
15 | ||
16 | /** <p><code>DefaultProcessingInstruction</code> is the default | |
17 | * Processing Instruction implementation. | |
18 | * It is a doubly linked node which supports the parent relationship | |
19 | * and can be modified in place.</p> | |
20 | * | |
21 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> | |
22 | * @version $Revision: 1.11 $ | |
23 | */ | |
24 | public class DefaultProcessingInstruction extends FlyweightProcessingInstruction { | |
25 | ||
26 | /** The parent of this node */ | |
27 | private Element parent; | |
28 | ||
29 | /** <p>This will create a new PI with the given target and values</p> | |
30 | * | |
31 | * @param target is the name of the PI | |
32 | * @param values is the <code>Map</code> values for the PI | |
33 | */ | |
34 | 0 | public DefaultProcessingInstruction(String target,Map values) { |
35 | 0 | super(target, values); |
36 | } | |
37 | ||
38 | /** <p>This will create a new PI with the given target and values</p> | |
39 | * | |
40 | * @param target is the name of the PI | |
41 | * @param values is the values for the PI | |
42 | */ | |
43 | 48 | public DefaultProcessingInstruction(String target,String values) { |
44 | 48 | super(target, values); |
45 | } | |
46 | ||
47 | /** <p>This will create a new PI with the given target and values</p> | |
48 | * | |
49 | * @param parent is the parent element | |
50 | * @param target is the name of the PI | |
51 | * @param values is the values for the PI | |
52 | */ | |
53 | 0 | public DefaultProcessingInstruction(Element parent,String target,String values) { |
54 | 0 | super(target, values); |
55 | 0 | this.parent = parent; |
56 | } | |
57 | ||
58 | 0 | public void setTarget(String target) { |
59 | 0 | this.target = target; |
60 | } | |
61 | ||
62 | 0 | public void setText(String text) { |
63 | 0 | this.text = text; |
64 | 0 | this.values = parseValues(text); |
65 | } | |
66 | ||
67 | 0 | public void setValues(Map values) { |
68 | 0 | this.values = values; |
69 | 0 | this.text = toString(values); |
70 | } | |
71 | ||
72 | 0 | public void setValue(String name, String value) { |
73 | 0 | values.put(name, value); |
74 | } | |
75 | ||
76 | ||
77 | 42 | public Element getParent() { |
78 | 42 | return parent; |
79 | } | |
80 | ||
81 | 2 | public void setParent(Element parent) { |
82 | 2 | this.parent = parent; |
83 | } | |
84 | ||
85 | 0 | public boolean supportsParent() { |
86 | 0 | return true; |
87 | } | |
88 | ||
89 | 0 | public boolean isReadOnly() { |
90 | 0 | return false; |
91 | } | |
92 | } | |
93 | ||
94 | ||
95 | ||
96 | ||
97 | /* | |
98 | * Redistribution and use of this software and associated documentation | |
99 | * ("Software"), with or without modification, are permitted provided | |
100 | * that the following conditions are met: | |
101 | * | |
102 | * 1. Redistributions of source code must retain copyright | |
103 | * statements and notices. Redistributions must also contain a | |
104 | * copy of this document. | |
105 | * | |
106 | * 2. Redistributions in binary form must reproduce the | |
107 | * above copyright notice, this list of conditions and the | |
108 | * following disclaimer in the documentation and/or other | |
109 | * materials provided with the distribution. | |
110 | * | |
111 | * 3. The name "DOM4J" must not be used to endorse or promote | |
112 | * products derived from this Software without prior written | |
113 | * permission of MetaStuff, Ltd. For written permission, | |
114 | * please contact dom4j-info@metastuff.com. | |
115 | * | |
116 | * 4. Products derived from this Software may not be called "DOM4J" | |
117 | * nor may "DOM4J" appear in their names without prior written | |
118 | * permission of MetaStuff, Ltd. DOM4J is a registered | |
119 | * trademark of MetaStuff, Ltd. | |
120 | * | |
121 | * 5. Due credit should be given to the DOM4J Project - | |
122 | * http://www.dom4j.org | |
123 | * | |
124 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS | |
125 | * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT | |
126 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
127 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
128 | * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
129 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
130 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
131 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
132 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
133 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
134 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
135 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
136 | * | |
137 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
138 | * | |
139 | * $Id: DefaultProcessingInstruction.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $ | |
140 | */ |
|