KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > text > plugin > AbstractPluginDocumentHandler


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.core.text.plugin;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.pde.core.plugin.IPluginBase;
16 import org.eclipse.pde.internal.core.text.DocumentHandler;
17 import org.xml.sax.SAXException JavaDoc;
18
19 public abstract class AbstractPluginDocumentHandler extends DocumentHandler {
20     
21     private PluginModelBase fModel;
22     private String JavaDoc fSchemaVersion;
23
24     /**
25      * @param model
26      */

27     public AbstractPluginDocumentHandler(PluginModelBase model) {
28         fModel = model;
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.pde.internal.ui.model.plugin.DocumentHandler#getDocument()
33      */

34     protected IDocument getDocument() {
35         return fModel.getDocument();
36     }
37     
38     /* (non-Javadoc)
39      * @see org.xml.sax.helpers.DefaultHandler#endDocument()
40      */

41     public void endDocument() throws SAXException JavaDoc {
42         IPluginBase pluginBase = fModel.getPluginBase();
43         try {
44             if (pluginBase != null)
45                 pluginBase.setSchemaVersion(fSchemaVersion);
46         } catch (CoreException e) {
47         }
48     }
49     
50
51     /* (non-Javadoc)
52      * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
53      */

54     public void processingInstruction(String JavaDoc target, String JavaDoc data) throws SAXException JavaDoc {
55         if ("eclipse".equals(target)) { //$NON-NLS-1$
56
fSchemaVersion = "version=\"3.0\"".equals(data) ? "3.0" : "3.2"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
57
}
58     }
59     
60     /* (non-Javadoc)
61      * @see org.eclipse.pde.internal.ui.model.DocumentHandler#startDocument()
62      */

63     public void startDocument() throws SAXException JavaDoc {
64         super.startDocument();
65         fSchemaVersion = null;
66     }
67     protected PluginModelBase getModel() {
68         return fModel;
69     }
70 }
71
Popular Tags