01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core;
11:
12: import org.xml.sax.SAXException;
13: import org.xml.sax.ext.LexicalHandler;
14:
15: public class XMLCopyrightHandler implements LexicalHandler {
16:
17: private String fCopyright = null;
18: private XMLDefaultHandler fHandler = null;
19:
20: public XMLCopyrightHandler(XMLDefaultHandler handler) {
21: fHandler = handler;
22: }
23:
24: public void comment(char[] ch, int start, int length)
25: throws SAXException {
26: // if we haven't parsed any elements, we assume it is a copyright
27: if (fHandler != null && fCopyright == null
28: && fHandler.fElementStack.isEmpty()) {
29: fCopyright = new String(ch, start, length);
30: }
31: }
32:
33: public void endCDATA() throws SAXException {
34: }
35:
36: public void endDTD() throws SAXException {
37: }
38:
39: public void endEntity(String name) throws SAXException {
40: }
41:
42: public void startCDATA() throws SAXException {
43: }
44:
45: public void startDTD(String name, String publicId, String systemId)
46: throws SAXException {
47: }
48:
49: public void startEntity(String name) throws SAXException {
50: }
51:
52: public String getCopyright() {
53: return fCopyright;
54: }
55:
56: }
|