KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > AbstractDocumentFragment


1 /*
2
3    Copyright 2000,2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom;
19
20 import org.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.DocumentFragment JavaDoc;
22 import org.w3c.dom.Node JavaDoc;
23
24 /**
25  * This class implements {@link org.w3c.dom.DocumentFragment} interface.
26  *
27  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
28  * @version $Id: AbstractDocumentFragment.java,v 1.6 2005/02/22 09:12:57 cam Exp $
29  */

30
31 public abstract class AbstractDocumentFragment
32     extends AbstractParentNode
33     implements DocumentFragment JavaDoc {
34     /**
35      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeName()}.
36      * @return "#document-fragment".
37      */

38     public String JavaDoc getNodeName() {
39     return "#document-fragment";
40     }
41
42     /**
43      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeType()}.
44      * @return {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE}
45      */

46     public short getNodeType() {
47     return DOCUMENT_FRAGMENT_NODE;
48     }
49
50     /**
51      * Checks the validity of a node to be inserted.
52      */

53     protected void checkChildType(Node JavaDoc n, boolean replace) {
54     switch (n.getNodeType()) {
55     case ELEMENT_NODE:
56     case PROCESSING_INSTRUCTION_NODE:
57     case COMMENT_NODE:
58     case TEXT_NODE:
59     case CDATA_SECTION_NODE:
60     case ENTITY_REFERENCE_NODE:
61     case DOCUMENT_FRAGMENT_NODE:
62         break;
63     default:
64         throw createDOMException
65                 (DOMException.HIERARCHY_REQUEST_ERR,
66                  "child.type",
67                  new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
68                                 getNodeName(),
69                                 new Integer JavaDoc(n.getNodeType()),
70                                 n.getNodeName() });
71     }
72     }
73 }
74
Popular Tags