KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > o3impl > AbstractComment


1 /*
2  * Copyright 2001 (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.2 2003/06/10 16:18:35 per_nyfelt Exp $
8  */

9
10 package org.ozoneDB.xml.dom4j.o3impl;
11
12 import org.dom4j.Comment;
13 import org.dom4j.Element;
14 import org.dom4j.Visitor;
15
16 import java.io.IOException JavaDoc;
17 import java.io.Writer JavaDoc;
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.2 $
24  */

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

113
Popular Tags