1 42 43 package org.jfree.xml; 44 45 import java.util.ArrayList ; 46 47 import org.xml.sax.SAXException ; 48 import org.xml.sax.ext.LexicalHandler ; 49 50 57 public class CommentHandler implements LexicalHandler { 58 59 60 public static final String OPEN_TAG_COMMENT = "parser.comment.open"; 61 62 63 public static final String CLOSE_TAG_COMMENT = "parser.comment.close"; 64 65 66 private final ArrayList comment; 67 68 69 private boolean inDTD; 70 71 74 public CommentHandler() { 75 this.comment = new ArrayList (); 76 } 77 78 93 public void startDTD(final String name, final String publicId, 94 final String systemId) throws SAXException { 95 this.inDTD = true; 96 } 97 98 105 public void endDTD() 106 throws SAXException { 107 this.inDTD = false; 108 } 109 110 123 public void startEntity(final String name) 124 throws SAXException { 125 } 127 128 137 public void endEntity(final String name) throws SAXException { 138 } 140 141 149 public void startCDATA() throws SAXException { 150 } 152 153 161 public void endCDATA() throws SAXException { 162 } 164 165 179 public void comment(final char[] ch, final int start, final int length) throws SAXException { 180 if (!this.inDTD) { 181 this.comment.add(new String (ch, start, length)); 182 } 183 } 184 185 189 public String [] getComments() { 190 if (this.comment.isEmpty()) { 191 return null; 192 } 193 return (String []) this.comment.toArray(new String [this.comment.size()]); 194 } 195 196 199 public void clearComments() { 200 this.comment.clear(); 201 } 202 } 203
| Popular Tags
|