Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e5ec1ad46cdf12fe9c08e8e34a7f3962c0fa65eb (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
/*******************************************************************************
 * Copyright (c) 2000, 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.debug.core.sourcelookup.containers;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.sourcelookup.ISourceContainerTypeDelegate;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * Common function for source container type delegates.
 * <p>
 * Clients implementing source container delegates should subclass this class.
 * </p>
 * @since 3.0
 */
public abstract class AbstractSourceContainerTypeDelegate implements ISourceContainerTypeDelegate {

	/**
	 * Throws an exception with the given message and underlying exception.
	 *
	 * @param message error message
	 * @param exception underlying exception, or <code>null</code>
	 * @throws CoreException if a problem is encountered
	 */
	protected void abort(String message, Throwable exception) throws CoreException {
		IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, message, exception);
		throw new CoreException(status);
	}

	/**
	 * Creates and returns a new XML document.
	 *
	 * @return a new XML document
	 * @throws CoreException if unable to create a new document
	 */
	protected Document newDocument()throws CoreException {
		return DebugPlugin.newDocument();
	}

	/**
	 * Returns the given XML document as a string.
	 *
	 * @param document document to serialize
	 * @return the given XML document as a string
	 * @throws CoreException if unable to serialize the document
	 */
	protected String serializeDocument(Document document) throws CoreException {
		return DebugPlugin.serializeDocument(document);
	}

	/**
	 * Parses the given XML document, returning its root element.
	 *
	 * @param document XML document as a string
	 * @return the document's root element
	 * @throws CoreException if unable to parse the document
	 */
	protected Element parseDocument(String document) throws CoreException {
		return DebugPlugin.parseDocument(document);
	}
}

Back to the top