1 11 12 package org.eclipse.team.internal.ccvs.ui.repo; 13 14 import java.util.Vector ; 15 16 import org.xml.sax.Attributes ; 17 import org.xml.sax.helpers.DefaultHandler ; 18 19 class CommentTemplatesContentHandler extends DefaultHandler { 20 21 private StringBuffer buffer; 22 private Vector comments; 23 public CommentTemplatesContentHandler() { 24 } 25 26 29 public void characters(char[] chars, int startIndex, int length) { 30 if (buffer == null) return; 31 buffer.append(chars, startIndex, length); 32 } 33 34 37 public void startElement( 38 String namespaceURI, 39 String localName, 40 String qName, 41 Attributes atts) { 42 43 String elementName = getElementName(localName, qName); 44 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { 45 buffer = new StringBuffer (); 46 return; 47 } 48 if (elementName.equals(RepositoryManager.ELEMENT_COMMENT_TEMPLATES)) { 49 comments = new Vector (); 50 return; 51 } 52 } 53 54 57 public void endElement(String namespaceURI, String localName, String qName) { 58 String elementName = getElementName(localName, qName); 59 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { 60 comments.add(buffer.toString()); 61 buffer = null; 62 return; 63 } 64 if (elementName.equals(RepositoryManager.ELEMENT_COMMENT_TEMPLATES)) { 65 RepositoryManager.commentTemplates = new String [comments.size()]; 66 comments.copyInto(RepositoryManager.commentTemplates); 67 return; 68 } 69 } 70 71 76 private String getElementName(String localName, String qName) { 77 if (localName != null && localName.length() > 0) { 78 return localName; 79 } 80 return qName; 81 } 82 } 83 | Popular Tags |