KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > launching > ClasspathContainerSourceContainerTypeDelegate


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.jdt.internal.launching;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
16 import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
17 import org.eclipse.jdt.launching.sourcelookup.containers.ClasspathContainerSourceContainer;
18 import org.w3c.dom.Document JavaDoc;
19 import org.w3c.dom.Element JavaDoc;
20 import org.w3c.dom.Node JavaDoc;
21
22 /**
23  * Classpath container source container type.
24  *
25  * @since 3.0
26  */

27 public class ClasspathContainerSourceContainerTypeDelegate extends AbstractSourceContainerTypeDelegate {
28     
29     /* (non-Javadoc)
30      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerTypeDelegate#createSourceContainer(java.lang.String)
31      */

32     public ISourceContainer createSourceContainer(String JavaDoc memento) throws CoreException {
33         Node JavaDoc node = parseDocument(memento);
34         if (node.getNodeType() == Node.ELEMENT_NODE) {
35             Element JavaDoc element = (Element JavaDoc)node;
36             if ("classpathContainer".equals(element.getNodeName())) { //$NON-NLS-1$
37
String JavaDoc string = element.getAttribute("path"); //$NON-NLS-1$
38
if (string == null || string.length() == 0) {
39                     abort(LaunchingMessages.ClasspathContainerSourceContainerTypeDelegate_5, null);
40                 }
41                 return new ClasspathContainerSourceContainer(new Path(string));
42             }
43             abort(LaunchingMessages.ClasspathContainerSourceContainerTypeDelegate_6, null);
44         }
45         abort(LaunchingMessages.ClasspathContainerSourceContainerTypeDelegate_7, null);
46         return null;
47     }
48     /* (non-Javadoc)
49      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerTypeDelegate#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
50      */

51     public String JavaDoc getMemento(ISourceContainer container) throws CoreException {
52         ClasspathContainerSourceContainer var = (ClasspathContainerSourceContainer) container;
53         Document JavaDoc document = newDocument();
54         Element JavaDoc element = document.createElement("classpathContainer"); //$NON-NLS-1$
55
element.setAttribute("path", var.getPath().toString()); //$NON-NLS-1$
56
document.appendChild(element);
57         return serializeDocument(document);
58     }
59 }
60
Popular Tags