Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0f3d552f61cd35b0bf97de52087b7c50d888da32 (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
/*******************************************************************************
 * Copyright (c) 2010, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ua.tests.help.search;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.help.search.SearchParticipantXML;
import org.xml.sax.Attributes;

public class MockSearchParticipantXML extends SearchParticipantXML {

	public static final String DOC_1 = "/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml";
	public static final String DOC_2 = "/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml";
	
	@Override
	public Set<String> getAllDocuments(String locale) {
		HashSet<String> set = new HashSet<String>();
		set.add(DOC_1 + "?id=xml1" + "?id=xml2");
		set.add(DOC_2);
		return set;
	}
	
	@Override
	public Set<String> getContributingPlugins() {
		Set<String> result = new HashSet<String>();
		result.add("org.eclipse.ua.tests");
		return result;
	}

	@Override
	protected void handleStartElement(String name, Attributes attributes,
			IParsedXMLContent data) {
		if ("participant".equalsIgnoreCase(name)) {
			data.setTitle(attributes.getValue("title"));			
		}
		String summary = attributes.getValue("summary");
		if (summary != null) {
		    data.addToSummary(summary);
		}
	}

	@Override
	protected void handleEndElement(String name, IParsedXMLContent data) {
	}

	@Override
	protected void handleText(String text, IParsedXMLContent data) {
		String top = getTopElement();
		if ("text".equalsIgnoreCase(top)) {
			data.addText(text);
		}
	}
	
	@Override
	public boolean open(String id) {
		System.out.println("Open " + id);
		return true;
	}

}

Back to the top