KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > UserLibraryClasspathContainer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.core;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.jdt.core.IClasspathContainer;
16 import org.eclipse.jdt.core.IClasspathEntry;
17 import org.eclipse.jdt.core.JavaCore;
18 import org.eclipse.jdt.internal.core.util.Util;
19
20 /**
21  *
22  */

23 public class UserLibraryClasspathContainer implements IClasspathContainer {
24     
25     private String JavaDoc name;
26     
27     public UserLibraryClasspathContainer(String JavaDoc name) {
28         this.name = name;
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
33      */

34     public IClasspathEntry[] getClasspathEntries() {
35         UserLibrary library= getUserLibrary();
36         if (library != null) {
37             return library.getEntries();
38         }
39         return new IClasspathEntry[0];
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
44      */

45     public String JavaDoc getDescription() {
46         return this.name;
47     }
48
49     /* (non-Javadoc)
50      * @see org.eclipse.jdt.core.IClasspathContainer#getKind()
51      */

52     public int getKind() {
53         UserLibrary library= getUserLibrary();
54         if (library != null && library.isSystemLibrary()) {
55             return K_SYSTEM;
56         }
57         return K_APPLICATION;
58     }
59
60     /* (non-Javadoc)
61      * @see org.eclipse.jdt.core.IClasspathContainer#getPath()
62      */

63     public IPath getPath() {
64         return new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(this.name);
65     }
66     
67     private UserLibrary getUserLibrary() {
68         UserLibrary userLibrary = JavaModelManager.getUserLibraryManager().getUserLibrary(this.name);
69         if (userLibrary == null && JavaModelManager.CP_RESOLVE_VERBOSE) {
70             verbose_no_user_library_found(this.name);
71         }
72         return userLibrary;
73     }
74
75     private void verbose_no_user_library_found(String JavaDoc userLibraryName) {
76         Util.verbose(
77             "UserLibrary INIT - FAILED (no user library found)\n" + //$NON-NLS-1$
78
" userLibraryName: " + userLibraryName); //$NON-NLS-1$
79
}
80 }
81
Popular Tags