KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > plugin > PluginDocumentHandler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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     /* (non-Javadoc)
26      * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
27      */

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 JavaDoc buffer = new StringBuffer JavaDoc();
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     /* (non-Javadoc)
47      * @see org.eclipse.pde.internal.ui.model.plugin.DocumentHandler#getDocumentNode(java.lang.String, org.eclipse.pde.internal.ui.model.IDocumentNode)
48      */

49     protected IDocumentNode getDocumentNode(String JavaDoc name, IDocumentNode parent) {
50         return fFactory.createDocumentNode(name, parent);
51     }
52     
53     /* (non-Javadoc)
54      * @see org.eclipse.pde.internal.ui.model.plugin.DocumentHandler#getDocumentAttribute(java.lang.String, java.lang.String, org.eclipse.pde.internal.ui.model.IDocumentNode)
55      */

56     protected IDocumentAttribute getDocumentAttribute(String JavaDoc name,
57             String JavaDoc value, IDocumentNode parent) {
58         return fFactory.createAttribute(name, value, parent);
59     }
60 }
61
Popular Tags