blob: 3c6348a788b2afab693f1eb23df1b85b9f7ad3cd [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.update.core.model;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.update.internal.core.InternalFeatureParser;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
* Default feature parser.
* Parses the feature manifest file as defined by the platform. Defers
* to a model factory to create the actual concrete model objects. The
* update framework supplies two factory implementations:
* <ul>
* <p>
* <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
* (repeatedly) as the API evolves.
* </p>
* <li>@see org.eclipse.update.core.model.FeatureModelFactory
* <li>@see org.eclipse.update.core.BaseFeatureFactory
* </ul>
*
* @since 2.0
* @deprecated The org.eclipse.update component has been replaced by Equinox p2. This
* provisional API was never promoted to stable API, and may be removed from a future release of the platform.
*/
public class DefaultFeatureParser extends DefaultHandler {
private InternalFeatureParser featureParser;
// Current State Information
//Stack stateStack = new Stack();
// Current object stack (used to hold the current object we are
// populating in this plugin descriptor
//Stack objectStack = new Stack();
/**
* Constructs a feature parser.
*
* @since 2.0
*/
public DefaultFeatureParser() {
super();
featureParser = new InternalFeatureParser();
}
public void init(FeatureModelFactory factory) {
init(factory, null);
}
/**
* @param factory
* @param location
* @since 3.1
*/
public void init(FeatureModelFactory factory, String location) {
this.featureParser.init(factory, location);
}
/**
* Parses the specified input steam and constructs a feature model.
* The input stream is not closed as part of this operation.
*
* @param in input stream
* @return feature model
* @exception SAXException
* @exception IOException
* @since 2.0
*/
public FeatureModel parse(InputStream in) throws SAXException, IOException {
return featureParser.parse(in);
}
/**
* Returns all status objects accumulated by the parser.
*
* @return multi-status containing accumulated status, or <code>null</code>.
* @since 2.0
*/
public MultiStatus getStatus() {
return featureParser.getStatus();
}
/**
* Handle start of element tags
* @see DefaultHandler#startElement(String, String, String, Attributes)
* @since 2.0
*/
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
featureParser.startElement(uri, localName, qName, attributes);
}
/**
* Handle end of element tags
* @see DefaultHandler#endElement(String, String, String)
* @since 2.0
*/
public void endElement(String uri, String localName, String qName) {
featureParser.endElement(uri, localName, qName);
}
/**
* Handle character text
* @see DefaultHandler#characters(char[], int, int)
* @since 2.0
*/
public void characters(char[] ch, int start, int length) {
featureParser.characters(ch, start, length);
}
/**
* Handle errors
* @see DefaultHandler#error(SAXParseException)
* @since 2.0
*/
public void error(SAXParseException ex) {
featureParser.error(ex);
}
/**
* Handle fatal errors
* @see DefaultHandler#fatalError(SAXParseException)
* @exception SAXException
* @since 2.0
*/
public void fatalError(SAXParseException ex) throws SAXException {
featureParser.fatalError(ex);
}
/**
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
featureParser.ignorableWhitespace(arg0, arg1, arg2);
}
}