KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > core > sourcelookup > containers > AbstractSourceContainerTypeDelegate


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.core.sourcelookup.containers;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.debug.core.DebugPlugin;
17 import org.eclipse.debug.core.sourcelookup.ISourceContainerTypeDelegate;
18 import org.w3c.dom.Document JavaDoc;
19 import org.w3c.dom.Element JavaDoc;
20
21 /**
22  * Common function for source container type delegates.
23  * <p>
24  * Clients implementing source container delegates should subclass this class.
25  * </p>
26  * @since 3.0
27  */

28 public abstract class AbstractSourceContainerTypeDelegate implements ISourceContainerTypeDelegate {
29     
30     /**
31      * Throws an exception with the given message and underlying exception.
32      *
33      * @param message error message
34      * @param exception underlying exception, or <code>null</code>
35      * @throws CoreException
36      */

37     protected void abort(String JavaDoc message, Throwable JavaDoc exception) throws CoreException {
38         IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, message, exception);
39         throw new CoreException(status);
40     }
41     
42     /**
43      * Creates and returns a new XML document.
44      *
45      * @return a new XML document
46      * @throws CoreException if unable to create a new document
47      */

48     protected Document JavaDoc newDocument()throws CoreException {
49         return DebugPlugin.newDocument();
50     }
51     
52     /**
53      * Returns the given XML document as a string.
54      *
55      * @param document document to serialize
56      * @return the given XML document as a string
57      * @throws CoreException if unable to serialize the document
58      */

59     protected String JavaDoc serializeDocument(Document JavaDoc document) throws CoreException {
60         return DebugPlugin.serializeDocument(document);
61     }
62
63     /**
64      * Parses the given XML document, returning its root element.
65      *
66      * @param document XML document as a string
67      * @return the document's root element
68      * @throws CoreException if unable to parse the document
69      */

70     protected Element JavaDoc parseDocument(String JavaDoc document) throws CoreException {
71         return DebugPlugin.parseDocument(document);
72     }
73 }
74
Popular Tags