1 12 13 package org.eclipse.team.internal.ccvs.ui.repo; 14 15 import java.util.Vector ; 16 17 import org.xml.sax.SAXException ; 18 import org.xml.sax.helpers.DefaultHandler ; 19 import org.xml.sax.Attributes ; 20 21 class CommentHistoryContentHandler extends DefaultHandler { 22 23 private StringBuffer buffer; 24 private Vector comments; 25 public CommentHistoryContentHandler() { 26 } 27 28 31 public void characters(char[] chars, int startIndex, int length) throws SAXException { 32 if (buffer == null) return; 33 buffer.append(chars, startIndex, length); 34 } 35 36 39 public void startElement( 40 String namespaceURI, 41 String localName, 42 String qName, 43 Attributes atts) 44 throws SAXException { 45 46 String elementName = getElementName(namespaceURI, localName, qName); 47 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { 48 buffer = new StringBuffer (); 49 return; 50 } 51 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_HISTORY)) { 52 comments = new Vector (RepositoryManager.DEFAULT_MAX_COMMENTS); 53 return; 54 } 55 } 56 57 60 public void endElement(String namespaceURI, String localName, String qName) { 61 String elementName = getElementName(namespaceURI, localName, qName); 62 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_COMMENT)) { 63 comments.add(buffer.toString()); 64 buffer = null; 65 return; 66 } 67 if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_HISTORY)) { 68 RepositoryManager.previousComments = new String [comments.size()]; 69 comments.copyInto(RepositoryManager.previousComments); 70 return; 71 } 72 } 73 74 79 private String getElementName(String namespaceURI, String localName, String qName) { 80 if (localName != null && localName.length() > 0) { 81 return localName; 82 } else { 83 return qName; 84 } 85 } 86 } 87 | Popular Tags |