KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > syntax > dom > DocumentTypeImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.text.syntax.dom;
21
22 import org.w3c.dom.*;
23 import org.netbeans.modules.xml.text.syntax.*;
24 import org.netbeans.modules.xml.spi.dom.*;
25 import org.netbeans.editor.*;
26
27 /**
28  * It should envolve in DocumentType implementation.
29  *
30  * @author Petr Kuzel
31  */

32 public class DocumentTypeImpl extends SyntaxNode implements DocumentType, XMLTokenIDs {
33
34     public DocumentTypeImpl(XMLSyntaxSupport syntax, TokenItem first, int to) {
35         super (syntax, first, to);
36     }
37
38     public short getNodeType() {
39         return Node.DOCUMENT_TYPE_NODE;
40     }
41         
42     public String JavaDoc getPublicId() {
43         String JavaDoc doctype = first.getImage();
44         if (doctype.indexOf("PUBLIC") != -1) { // NOI18N
45
TokenItem next = first.getNext();
46             if (next != null && next.getTokenID() == VALUE) {
47                 String JavaDoc publicId = next.getImage();
48                 return publicId.substring(1, publicId.length() - 1);
49             }
50         }
51         return null;
52     }
53     
54     public org.w3c.dom.NamedNodeMap JavaDoc getNotations() {
55         return NamedNodeMapImpl.EMPTY;
56     }
57     
58     public String JavaDoc getName() {
59         //<!DOCTYPE id ...
60
String JavaDoc docType = first.getImage();
61         int idIndex = docType.indexOf(' ');
62         if(idIndex > 0) {
63             int idEndIndex = docType.indexOf(' ', idIndex + 1);
64             if(idEndIndex > 0 && idEndIndex > idIndex) {
65                 return docType.substring(idIndex + 1, idEndIndex);
66             }
67         }
68         return null;
69     }
70     
71     public org.w3c.dom.NamedNodeMap JavaDoc getEntities() {
72         return NamedNodeMapImpl.EMPTY;
73     }
74     
75     public String JavaDoc getSystemId() {
76         String JavaDoc doctype = first.getImage();
77         if (doctype.indexOf("PUBLIC") != -1) { // NOI18N
78
TokenItem next = first.getNext();
79             if (next != null && next.getTokenID() == VALUE) {
80                 next = next.getNext();
81                 if (next == null) return null;
82                 next = next.getNext();
83                 if (next != null && next.getTokenID() == VALUE) {
84                     String JavaDoc system = next.getImage();
85                     return system.substring(1, system.length() -1);
86                 }
87             }
88         } else if (doctype.indexOf("SYSTEM") != -1) { // NOI18N
89
TokenItem next = first.getNext();
90             if (next != null && next.getTokenID() == VALUE) {
91                 String JavaDoc system = next.getImage();
92                 return system.substring(1, system.length() - 1);
93             }
94         }
95         return null;
96     }
97     
98     public String JavaDoc getInternalSubset() {
99         return null;
100     }
101     
102 }
103
104
Popular Tags