1 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 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 getPublicId() { 43 String doctype = first.getImage(); 44 if (doctype.indexOf("PUBLIC") != -1) { TokenItem next = first.getNext(); 46 if (next != null && next.getTokenID() == VALUE) { 47 String publicId = next.getImage(); 48 return publicId.substring(1, publicId.length() - 1); 49 } 50 } 51 return null; 52 } 53 54 public org.w3c.dom.NamedNodeMap getNotations() { 55 return NamedNodeMapImpl.EMPTY; 56 } 57 58 public String getName() { 59 String 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 getEntities() { 72 return NamedNodeMapImpl.EMPTY; 73 } 74 75 public String getSystemId() { 76 String doctype = first.getImage(); 77 if (doctype.indexOf("PUBLIC") != -1) { 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 system = next.getImage(); 85 return system.substring(1, system.length() -1); 86 } 87 } 88 } else if (doctype.indexOf("SYSTEM") != -1) { TokenItem next = first.getNext(); 90 if (next != null && next.getTokenID() == VALUE) { 91 String system = next.getImage(); 92 return system.substring(1, system.length() - 1); 93 } 94 } 95 return null; 96 } 97 98 public String getInternalSubset() { 99 return null; 100 } 101 102 } 103 104 | Popular Tags |