Eclipse JDT
2.0

org.eclipse.jdt.core
Interface IClasspathEntry


public interface IClasspathEntry

An entry on a Java project classpath identifying one or more package fragment roots. A classpath entry has a content kind (either source, K_SOURCE, or binary, K_BINARY), which is inherited by each package fragment root and package fragment associated with the entry.

A classpath entry can refer to any of the following:

The result of IJavaProject#getResolvedClasspath will have all entries of type CPE_VARIABLE and CPE_CONTAINER resolved to a set of CPE_SOURCE, CPE_LIBRARY or CPE_PROJECT classpath entries.

Any classpath entry other than a source folder (kind CPE_SOURCE) can be marked as being exported. Exported entries are automatically contributed to dependent projects, along with the project's output folder, which is implicitly exported. The project's output folder is always listed first, followed by the any exported entries.

This interface is not intended to be implemented by clients. Classpath entries can be created via methods on JavaCore.

See Also:
JavaCore.newLibraryEntry(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath), JavaCore.newProjectEntry(org.eclipse.core.runtime.IPath), JavaCore.newSourceEntry(org.eclipse.core.runtime.IPath), JavaCore.newVariableEntry(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath), JavaCore.newContainerEntry(org.eclipse.core.runtime.IPath), ClasspathVariableInitializer, ClasspathContainerInitializer

Field Summary
static int CPE_CONTAINER
          Entry kind constant describing a classpath entry representing a name classpath container.
static int CPE_LIBRARY
          Entry kind constant describing a classpath entry identifying a library.
static int CPE_PROJECT
          Entry kind constant describing a classpath entry identifying a required project.
static int CPE_SOURCE
          Entry kind constant describing a classpath entry identifying a folder containing package fragments with source code to be compiled.
static int CPE_VARIABLE
          Entry kind constant describing a classpath entry defined using a path that begins with a classpath variable reference.
 
Method Summary
 int getContentKind()
          Returns the kind of files found in the package fragments identified by this classpath entry.
 int getEntryKind()
          Returns the kind of this classpath entry.
 IPath getPath()
          Returns the path of this classpath entry.
 IClasspathEntry getResolvedEntry()
          Deprecated. - use JavaCore.getResolvedClasspathEntry(...)
 IPath getSourceAttachmentPath()
          Returns the path to the source archive associated with this classpath entry, or null if this classpath entry has no source attachment.
 IPath getSourceAttachmentRootPath()
          Returns the path within the source archive where package fragments are located.
 boolean isExported()
          Returns whether this entry is exported to dependent projects.
 

Field Detail

CPE_LIBRARY

public static final int CPE_LIBRARY
Entry kind constant describing a classpath entry identifying a library. A library is a folder or JAR containing package fragments consisting of pre-compiled binaries.

See Also:
Constant Field Values

CPE_PROJECT

public static final int CPE_PROJECT
Entry kind constant describing a classpath entry identifying a required project.

See Also:
Constant Field Values

CPE_SOURCE

public static final int CPE_SOURCE
Entry kind constant describing a classpath entry identifying a folder containing package fragments with source code to be compiled.

See Also:
Constant Field Values

CPE_VARIABLE

public static final int CPE_VARIABLE
Entry kind constant describing a classpath entry defined using a path that begins with a classpath variable reference.

See Also:
Constant Field Values

CPE_CONTAINER

public static final int CPE_CONTAINER
Entry kind constant describing a classpath entry representing a name classpath container.

Since:
2.0
See Also:
Constant Field Values
Method Detail

getContentKind

public int getContentKind()
Returns the kind of files found in the package fragments identified by this classpath entry.

Returns:
IPackageFragmentRoot.K_SOURCE for files containing source code, and IPackageFragmentRoot.K_BINARY for binary class files. There is no specified value for an entry denoting a variable (CPE_VARIABLE) or a classpath container (CPE_CONTAINER).

getEntryKind

public int getEntryKind()
Returns the kind of this classpath entry.

Returns:
one of:
  • CPE_SOURCE - this entry describes a source root in its project
  • CPE_LIBRARY - this entry describes a folder or JAR containing binaries
  • CPE_PROJECT - this entry describes another project
  • CPE_VARIABLE - this entry describes a project or library indirectly via a classpath variable in the first segment of the path *
  • CPE_CONTAINER - this entry describes set of entries referenced indirectly via a classpath container

getPath

public IPath getPath()
Returns the path of this classpath entry. The meaning of the path of a classpath entry depends on its entry kind:

Returns:
the path of this classpath entry

getSourceAttachmentPath

public IPath getSourceAttachmentPath()
Returns the path to the source archive associated with this classpath entry, or null if this classpath entry has no source attachment.

Only library and variable classpath entries may have source attachments. For library classpath entries, the result path (if present) locates a source archive. For variable classpath entries, the result path (if present) has an analogous form and meaning as the variable path, namely the first segment is the name of a classpath variable.

Returns:
the path to the source archive, or null if none

getSourceAttachmentRootPath

public IPath getSourceAttachmentRootPath()
Returns the path within the source archive where package fragments are located. An empty path indicates that packages are located at the root of the source archive. Returns a non-null value if and only if getSourceAttachmentPath returns a non-null value.

Returns:
the path within the source archive, or null if not applicable

isExported

public boolean isExported()
Returns whether this entry is exported to dependent projects. Always returns false for source entries (kind CPE_SOURCE), which cannot be exported.

Returns:
true if exported, and false otherwise
Since:
2.0

getResolvedEntry

public IClasspathEntry getResolvedEntry()
Deprecated. - use JavaCore.getResolvedClasspathEntry(...)

This is a helper method, which returns the resolved classpath entry denoted by an entry (if it is a variable entry). It is obtained by resolving the variable reference in the first segment. Returns null if unable to resolve using the following algorithm:
  • if variable segment cannot be resolved, returns null
  • finds a project, JAR or binary folder in the workspace at the resolved path location
  • if none finds an external JAR file or folder outside the workspace at the resolved path location
  • if none returns null

Variable source attachment is also resolved and recorded in the resulting classpath entry.

Returns:
the resolved library or project classpath entry, or null if the given path could not be resolved to a classpath entry

Note that this deprecated API doesn't handle CPE_CONTAINER entries.


Eclipse JDT
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.