1 12 package org.eclipse.help.internal.index; 13 14 import java.io.FileNotFoundException ; 15 import java.io.IOException ; 16 import java.io.InputStream ; 17 18 import javax.xml.parsers.ParserConfigurationException ; 19 20 import org.eclipse.help.internal.dynamic.DocumentReader; 21 import org.xml.sax.SAXException ; 22 import org.xml.sax.helpers.DefaultHandler ; 23 24 public class IndexFileParser extends DefaultHandler { 25 26 private DocumentReader reader; 27 28 public IndexContribution parse(IndexFile indexFile) throws IOException , SAXException , ParserConfigurationException { 29 if (reader == null) { 30 reader = new DocumentReader(); 31 } 32 InputStream 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 (); 43 } 44 } 45 } 46 | Popular Tags |