Skip to main content
summaryrefslogtreecommitdiffstats
blob: 52a6c5b202aceaa60420bf1b06e3658f14643ba9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package org.eclipse.help.internal.search;

import java.io.*;
import org.xml.sax.*;
import org.eclipse.help.internal.contributors.*;
import org.eclipse.help.internal.contributions.*;
import org.eclipse.help.internal.contributions.xml.*;
import org.eclipse.help.internal.contributors.xml.*;
import org.eclipse.help.internal.util.Logger;

/**
 * Creates a search model for the search results
 * that were presented as XML
 */
public class XMLSearchContributor implements Contributor {
	private Contribution resultsNode = null;
	private String results;
	static class SearchContributionFactory extends ContributionFactory {
		// Override the super class static field
		protected static final SearchContributionFactory instance =
			new SearchContributionFactory();
		/**
		 * ContributionFactory constructor comment.
		 */
		public SearchContributionFactory() {
			super();
		}

		public Contribution createContribution(String name, Attributes atts) {
			Contribution e = null;
			if (name.equals(TopicContributor.TOPICS_ELEM))
				e = new HelpContribution(atts);
			else
				if (name.equals(TopicContributor.TOPIC_ELEM))
					e = new HelpTopic(atts);
				else
					return null;

			return e;
		}

		public static ContributionFactory instance() {
			return instance;
		}
	}

	/**
	 * XMLSearchContributor constructor comment.
	 */
	public XMLSearchContributor(String xmlResultsAsString) {
		super();
		this.results = xmlResultsAsString;
	}
	/**
	 */
	public Contribution getContribution() {
		if (resultsNode == null) {
			try {
				InputSource input = new InputSource(new StringReader(results));
				ContributionParser parser =
					new ContributionParser(SearchContributionFactory.instance());
				parser.parse(input);
				resultsNode = parser.getContribution();
			} catch (SAXException se) {
				Logger.logError(se.getMessage(), se);
			} catch (IOException ioe) {
				Logger.logError(ioe.getMessage(), ioe);
			}
		}
		return resultsNode;
	}
	/**
	 */
	public org.eclipse.core.runtime.IPluginDescriptor getPlugin() {
		return null;
	}
	/**
	 */
	public String getType() {
		return null;
	}
}

Back to the top