|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractComment.java | 0% | 18,2% | 37,5% | 21,7% |
|
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: AbstractComment.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $ | |
8 | */ | |
9 | ||
10 | package org.dom4j.tree; | |
11 | ||
12 | import java.io.IOException; | |
13 | import java.io.Writer; | |
14 | ||
15 | import org.dom4j.Comment; | |
16 | import org.dom4j.Element; | |
17 | import org.dom4j.Visitor; | |
18 | ||
19 | /** <p><code>AbstractComment</code> is an abstract base class for | |
20 | * tree implementors to use for implementation inheritence.</p> | |
21 | * | |
22 | * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> | |
23 | * @version $Revision: 1.11 $ | |
24 | */ | |
25 | public abstract class AbstractComment extends AbstractCharacterData implements Comment { | |
26 | ||
27 | 962 | public AbstractComment() { |
28 | } | |
29 | ||
30 | 3826 | public short getNodeType() { |
31 | 3826 | return COMMENT_NODE; |
32 | } | |
33 | ||
34 | 0 | public String getPath(Element context) { |
35 | 0 | Element parent = getParent(); |
36 | 0 | return ( parent != null && parent != context ) |
37 | ? parent.getPath( context ) + "/comment()" | |
38 | : "comment()"; | |
39 | } | |
40 | ||
41 | 0 | public String getUniquePath(Element context) { |
42 | 0 | Element parent = getParent(); |
43 | 0 | return ( parent != null && parent != context ) |
44 | ? parent.getUniquePath( context ) + "/comment()" | |
45 | : "comment()"; | |
46 | } | |
47 | ||
48 | ||
49 | 1496 | public String toString() { |
50 | 1496 | return super.toString() + " [Comment: \"" + getText() + "\"]"; |
51 | } | |
52 | ||
53 | 0 | public String asXML() { |
54 | 0 | return "<!--" + getText() + "-->"; |
55 | } | |
56 | ||
57 | 0 | public void write(Writer writer) throws IOException { |
58 | 0 | writer.write( "<!--" ); |
59 | 0 | writer.write( getText() ); |
60 | 0 | writer.write( "-->" ); |
61 | } | |
62 | ||
63 | 0 | public void accept(Visitor visitor) { |
64 | 0 | visitor.visit(this); |
65 | } | |
66 | } | |
67 | ||
68 | ||
69 | ||
70 | ||
71 | /* | |
72 | * Redistribution and use of this software and associated documentation | |
73 | * ("Software"), with or without modification, are permitted provided | |
74 | * that the following conditions are met: | |
75 | * | |
76 | * 1. Redistributions of source code must retain copyright | |
77 | * statements and notices. Redistributions must also contain a | |
78 | * copy of this document. | |
79 | * | |
80 | * 2. Redistributions in binary form must reproduce the | |
81 | * above copyright notice, this list of conditions and the | |
82 | * following disclaimer in the documentation and/or other | |
83 | * materials provided with the distribution. | |
84 | * | |
85 | * 3. The name "DOM4J" must not be used to endorse or promote | |
86 | * products derived from this Software without prior written | |
87 | * permission of MetaStuff, Ltd. For written permission, | |
88 | * please contact dom4j-info@metastuff.com. | |
89 | * | |
90 | * 4. Products derived from this Software may not be called "DOM4J" | |
91 | * nor may "DOM4J" appear in their names without prior written | |
92 | * permission of MetaStuff, Ltd. DOM4J is a registered | |
93 | * trademark of MetaStuff, Ltd. | |
94 | * | |
95 | * 5. Due credit should be given to the DOM4J Project - | |
96 | * http://www.dom4j.org | |
97 | * | |
98 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS | |
99 | * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT | |
100 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
101 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
102 | * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
103 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
104 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
105 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
106 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
107 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
108 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
109 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
110 | * | |
111 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
112 | * | |
113 | * $Id: AbstractComment.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $ | |
114 | */ |
|