1 11 package org.eclipse.help.internal.base.remote; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 16 import javax.xml.parsers.ParserConfigurationException ; 17 18 import org.eclipse.help.IUAElement; 19 import org.eclipse.help.internal.UAElement; 20 import org.eclipse.help.internal.dynamic.DocumentReader; 21 import org.eclipse.help.internal.index.Index; 22 import org.eclipse.help.internal.index.IndexContribution; 23 import org.xml.sax.SAXException ; 24 import org.xml.sax.helpers.DefaultHandler ; 25 26 31 public class RemoteIndexParser extends DefaultHandler { 32 33 private DocumentReader reader; 34 35 38 public IndexContribution[] parse(InputStream in) throws ParserConfigurationException , SAXException , IOException { 39 if (reader == null) { 40 reader = new DocumentReader(); 41 } 42 UAElement root = reader.read(in); 43 IUAElement[] children = root.getChildren(); 44 IndexContribution[] contributions = new IndexContribution[children.length]; 45 for (int i=0;i<children.length;++i) { 46 UAElement child = (UAElement)children[i]; 47 IndexContribution contribution = new IndexContribution(); 48 contribution.setId(child.getAttribute("id")); contribution.setLocale(child.getAttribute("locale")); contribution.setIndex((Index)child.getChildren()[0]); 51 contributions[i] = contribution; 52 } 53 return contributions; 54 } 55 } 56 | Popular Tags |