KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > index > IndexFileParser


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 Intel 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  * Intel Corporation - initial API and implementation
10  * IBM Corporation - 122967 [Help] Remote help system
11  *******************************************************************************/

12 package org.eclipse.help.internal.index;
13
14 import java.io.FileNotFoundException JavaDoc;
15 import java.io.IOException JavaDoc;
16 import java.io.InputStream JavaDoc;
17
18 import javax.xml.parsers.ParserConfigurationException JavaDoc;
19
20 import org.eclipse.help.internal.dynamic.DocumentReader;
21 import org.xml.sax.SAXException JavaDoc;
22 import org.xml.sax.helpers.DefaultHandler JavaDoc;
23
24 public class IndexFileParser extends DefaultHandler JavaDoc {
25
26     private DocumentReader reader;
27     
28     public IndexContribution parse(IndexFile indexFile) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
29         if (reader == null) {
30             reader = new DocumentReader();
31         }
32         InputStream JavaDoc in = indexFile.getInputStream();
33         if (in != null) {
34             Index index = (Index)reader.read(in);
35             IndexContribution contrib = new IndexContribution();
36             contrib.setId('/' + indexFile.getPluginId() + '/' + indexFile.getFile());
37             contrib.setIndex(index);
38             contrib.setLocale(indexFile.getLocale());
39             return contrib;
40         }
41         else {
42             throw new FileNotFoundException JavaDoc();
43         }
44     }
45 }
46
Popular Tags