| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2007, 2008 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 | |
| 12 | package org.eclipse.pde.api.tools.internal.util; |
| 13 | |
| 14 | import org.xml.sax.Attributes; |
| 15 | import org.xml.sax.SAXException; |
| 16 | import org.xml.sax.SAXParseException; |
| 17 | import org.xml.sax.helpers.DefaultHandler; |
| 18 | |
| 19 | public class SourceDefaultHandler extends DefaultHandler { |
| 20 | private static final String ORG_ECLIPSE_PDE_CORE_SOURCE_EXTENSION_POINT_NAME = "org.eclipse.pde.core.source"; //$NON-NLS-1$ |
| 21 | private static final String EXTENSION_NAME = "extension"; //$NON-NLS-1$ |
| 22 | private static final String ECLIPSE_POINT_ATTRIBUTE_NAME = "point"; //$NON-NLS-1$ |
| 23 | boolean isSource = false; |
| 24 | public void error(SAXParseException e) throws SAXException { |
| 25 | e.printStackTrace(); |
| 26 | } |
| 27 | public void startElement(String uri, String localName, String name, Attributes attributes) |
| 28 | throws SAXException { |
| 29 | if (this.isSource) return; |
| 30 | this.isSource = EXTENSION_NAME.equals(name) |
| 31 | && attributes.getLength() == 1 |
| 32 | && (ECLIPSE_POINT_ATTRIBUTE_NAME.equals(attributes.getQName(0)) |
| 33 | || ECLIPSE_POINT_ATTRIBUTE_NAME.equals(attributes.getLocalName(0))) |
| 34 | && ORG_ECLIPSE_PDE_CORE_SOURCE_EXTENSION_POINT_NAME.equals(attributes.getValue(0)); |
| 35 | } |
| 36 | public boolean isSource() { |
| 37 | return this.isSource; |
| 38 | } |
| 39 | } |