KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > core > model > DefaultFeatureParser


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.update.core.model;
12
13
14 import java.io.IOException JavaDoc;
15 import java.io.InputStream JavaDoc;
16
17 import org.eclipse.core.runtime.MultiStatus;
18 import org.eclipse.update.internal.core.InternalFeatureParser;
19 import org.xml.sax.Attributes JavaDoc;
20 import org.xml.sax.SAXException JavaDoc;
21 import org.xml.sax.SAXParseException JavaDoc;
22 import org.xml.sax.helpers.DefaultHandler JavaDoc;
23
24 /**
25  * Default feature parser.
26  * Parses the feature manifest file as defined by the platform. Defers
27  * to a model factory to create the actual concrete model objects. The
28  * update framework supplies two factory implementations:
29  * <ul>
30  * <p>
31  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
32  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
33  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
34  * (repeatedly) as the API evolves.
35  * </p>
36  * <li>@see org.eclipse.update.core.model.FeatureModelFactory
37  * <li>@see org.eclipse.update.core.BaseFeatureFactory
38  * </ul>
39  *
40  * @since 2.0
41  */

42 public class DefaultFeatureParser extends DefaultHandler JavaDoc {
43     
44     private InternalFeatureParser featureParser;
45
46
47     // Current State Information
48
//Stack stateStack = new Stack();
49

50     // Current object stack (used to hold the current object we are
51
// populating in this plugin descriptor
52
//Stack objectStack = new Stack();
53

54     /**
55      * Constructs a feature parser.
56      *
57      * @since 2.0
58      */

59     public DefaultFeatureParser() {
60         super();
61         featureParser = new InternalFeatureParser();
62     }
63
64     public void init(FeatureModelFactory factory) {
65         init(factory, null);
66     }
67     
68     /**
69      * @param factory
70      * @param location
71      * @since 3.1
72      */

73     public void init(FeatureModelFactory factory, String JavaDoc location) {
74         
75         this.featureParser.init(factory, location);
76     }
77
78     /**
79      * Parses the specified input steam and constructs a feature model.
80      * The input stream is not closed as part of this operation.
81      *
82      * @param in input stream
83      * @return feature model
84      * @exception SAXException
85      * @exception IOException
86      * @since 2.0
87      */

88     public FeatureModel parse(InputStream JavaDoc in) throws SAXException JavaDoc, IOException JavaDoc {
89         return featureParser.parse(in);
90     }
91
92     /**
93      * Returns all status objects accumulated by the parser.
94      *
95      * @return multi-status containing accumulated status, or <code>null</code>.
96      * @since 2.0
97      */

98     public MultiStatus getStatus() {
99         return featureParser.getStatus();
100     }
101
102     /**
103      * Handle start of element tags
104      * @see DefaultHandler#startElement(String, String, String, Attributes)
105      * @since 2.0
106      */

107     public void startElement(String JavaDoc uri, String JavaDoc localName, String JavaDoc qName, Attributes JavaDoc attributes) throws SAXException JavaDoc {
108         featureParser.startElement(uri, localName, qName, attributes);
109         
110
111     }
112
113     /**
114      * Handle end of element tags
115      * @see DefaultHandler#endElement(String, String, String)
116      * @since 2.0
117      */

118     public void endElement(String JavaDoc uri, String JavaDoc localName, String JavaDoc qName) {
119         featureParser.endElement(uri, localName, qName);
120     }
121     
122
123     /**
124      * Handle character text
125      * @see DefaultHandler#characters(char[], int, int)
126      * @since 2.0
127      */

128     public void characters(char[] ch, int start, int length) {
129         featureParser.characters(ch, start, length);
130     }
131
132     /**
133      * Handle errors
134      * @see DefaultHandler#error(SAXParseException)
135      * @since 2.0
136      */

137     public void error(SAXParseException JavaDoc ex) {
138         featureParser.error(ex);
139     }
140
141     /**
142      * Handle fatal errors
143      * @see DefaultHandler#fatalError(SAXParseException)
144      * @exception SAXException
145      * @since 2.0
146      */

147     public void fatalError(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
148         featureParser.fatalError(ex);
149     }
150
151     /**
152      * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
153      */

154     public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException JavaDoc {
155         featureParser.ignorableWhitespace(arg0, arg1, arg2);
156     }
157 }
158
Popular Tags