1 11 package org.eclipse.pde.internal.ui.model.plugin; 12 13 import org.eclipse.pde.internal.ui.model.*; 14 import org.xml.sax.*; 15 16 public class PluginDocumentHandler extends AbstractPluginDocumentHandler { 17 18 private PluginDocumentNodeFactory fFactory; 19 20 public PluginDocumentHandler(PluginModelBase model) { 21 super(model); 22 fFactory = (PluginDocumentNodeFactory)getModel().getPluginFactory(); 23 } 24 25 28 public void characters(char[] ch, int start, int length) throws SAXException { 29 IDocumentNode parent = (IDocumentNode)fDocumentNodeStack.peek(); 30 if (parent == null) 31 return; 32 33 StringBuffer buffer = new StringBuffer (); 34 buffer.append(ch, start, length); 35 IDocumentTextNode textNode = parent.getTextNode(); 36 if (textNode == null) { 37 if (buffer.toString().trim().length() > 0) { 38 textNode = new DocumentTextNode(); 39 textNode.setEnclosingElement(parent); 40 parent.addTextNode(textNode); 41 textNode.setText(buffer.toString().trim()); 42 } 43 } 44 } 45 46 49 protected IDocumentNode getDocumentNode(String name, IDocumentNode parent) { 50 return fFactory.createDocumentNode(name, parent); 51 } 52 53 56 protected IDocumentAttribute getDocumentAttribute(String name, 57 String value, IDocumentNode parent) { 58 return fFactory.createAttribute(name, value, parent); 59 } 60 } 61 | Popular Tags |