Eclipse JDT
Release 3.8

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, IPackageFragmentRoot.K_SOURCE, or binary, IPackageFragmentRoot.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(boolean) 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 default output folder, which is implicitly exported, and any auxiliary output folders specified on source classpath entries. The project's output folder(s) are always listed first, followed by the any exported entries.

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
Restriction:
This interface is not intended to be implemented by clients.

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
 boolean combineAccessRules()
          Returns whether the access rules of the project's exported entries should be combined with this entry's access rules.
 IAccessRule[] getAccessRules()
          Returns the possibly empty list of access rules for this entry.
 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[] getExclusionPatterns()
          Returns the set of patterns used to exclude resources or classes associated with this classpath entry.
 IClasspathAttribute[] getExtraAttributes()
          Returns the extra classpath attributes for this classpath entry.
 IPath[] getInclusionPatterns()
          Returns the set of patterns used to explicitly define resources or classes to be included with this classpath entry.
 IPath getOutputLocation()
          Returns the full path to the specific location where the builder writes .class files generated for this source entry (entry kind CPE_SOURCE).
 IPath getPath()
          Returns the path of this classpath entry.
 IClasspathEntry getReferencingEntry()
          Returns the classpath entry that is making a reference to this classpath entry.
 IClasspathEntry getResolvedEntry()
          Deprecated. Use JavaCore.getResolvedClasspathEntry(IClasspathEntry) instead
 IPath getSourceAttachmentPath()
          Returns the path to the source archive or folder associated with this classpath entry, or null if this classpath entry has no source attachment.
 IPath getSourceAttachmentRootPath()
          Returns the path within the source archive or folder where package fragments are located.
 boolean isExported()
          Returns whether this entry is exported to dependent projects.
 

Field Detail

CPE_LIBRARY

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

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

See Also:
Constant Field Values

CPE_SOURCE

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

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

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

combineAccessRules

boolean combineAccessRules()
Returns whether the access rules of the project's exported entries should be combined with this entry's access rules. Returns true for container entries. Returns false otherwise.

Returns:
whether the access rules of the project's exported entries should be combined with this entry's access rules
Since:
3.1

getAccessRules

IAccessRule[] getAccessRules()
Returns the possibly empty list of access rules for this entry.

Returns:
the possibly empty list of access rules for this entry
Since:
3.1

getContentKind

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

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

getExclusionPatterns

IPath[] getExclusionPatterns()
Returns the set of patterns used to exclude resources or classes associated with this classpath entry.

For source classpath entries, exclusion patterns allow specified portions of the resource tree rooted at this source entry's path to be filtered out. If no exclusion patterns are specified, this source entry includes all relevent files. Each path specified must be a relative path, and will be interpreted relative to this source entry's path. File patterns are case-sensitive. A file matched by one or more of these patterns is excluded from the corresponding package fragment root. Exclusion patterns have higher precedence than inclusion patterns; in other words, exclusion patterns can remove files for the ones that are to be included, not the other way around.

Note that there is no need to supply a pattern to exclude ".class" files because a source entry filters these out automatically.

The pattern mechanism is similar to Ant's. Each pattern is represented as a relative path. The path segments can be regular file or folder names or simple patterns involving standard wildcard characters.

'*' matches 0 or more characters within a segment. So *.java matches .java, a.java and Foo.java, but not Foo.properties (does not end with .java).

'?' matches 1 character within a segment. So ?.java matches a.java, A.java, but not .java or xyz.java (neither have just one character before .java).

Combinations of *'s and ?'s are allowed.

The special pattern '**' matches zero or more segments. In a source entry, a path like tests/ that ends in a trailing separator is interpreted as tests/**, and would match everything under the folder named tests.

Example patterns in source entries (assuming that "java" is the only Java-like extension):

Returns:
the possibly empty list of resource exclusion patterns associated with this classpath entry, or null if this kind of classpath entry does not support exclusion patterns
Since:
2.1

getExtraAttributes

IClasspathAttribute[] getExtraAttributes()
Returns the extra classpath attributes for this classpath entry. Returns an empty array if this entry has no extra attributes.

Returns:
the possibly empty list of extra classpath attributes for this classpath entry
Since:
3.1

getInclusionPatterns

IPath[] getInclusionPatterns()
Returns the set of patterns used to explicitly define resources or classes to be included with this classpath entry.

For source classpath entries, when no inclusion patterns are specified, the source entry includes all relevent files in the resource tree rooted at this source entry's path. Specifying one or more inclusion patterns means that only the specified portions of the resource tree are to be included. Each path specified must be a relative path, and will be interpreted relative to this source entry's path. File patterns are case-sensitive. A file matched by one or more of these patterns is included in the corresponding package fragment root unless it is excluded by one or more of this entrie's exclusion patterns. Exclusion patterns have higher precedence than inclusion patterns; in other words, exclusion patterns can remove files for the ones that are to be included, not the other way around.

See getExclusionPatterns() for a discussion of the syntax and semantics of path patterns. The absence of any inclusion patterns is semantically equivalent to the explicit inclusion pattern **.

Example patterns in source entries:

Returns:
the possibly empty list of resource inclusion patterns associated with this classpath entry, or null if this kind of classpath entry does not support inclusion patterns
Since:
3.0

getOutputLocation

IPath getOutputLocation()
Returns the full path to the specific location where the builder writes .class files generated for this source entry (entry kind CPE_SOURCE).

Source entries can optionally be associated with a specific output location. If none is provided, the source entry will be implicitly associated with its project default output location (see IJavaProject.getOutputLocation()).

NOTE: A specific output location cannot coincidate with another source/library entry.

Returns:
the full path to the specific location where the builder writes .class files for this source entry, or null if using default output folder
Since:
2.1

getPath

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

IPath getSourceAttachmentPath()
Returns the path to the source archive or folder 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 or folder. This archive or folder can be located in a project of the workspace or outside the workspace. 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 folder, or null if none

getSourceAttachmentRootPath

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

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

getReferencingEntry

IClasspathEntry getReferencingEntry()
Returns the classpath entry that is making a reference to this classpath entry. For entry kinds CPE_LIBRARY, the return value is the entry that is representing the JAR that includes this in the MANIFEST.MF file's Class-Path section. For entry kinds other than CPE_LIBRARY, this returns null. For those entries that are on the raw classpath already, this returns null.

It is possible that multiple library entries refer to the same entry via the MANIFEST.MF file. In those cases, this method returns the first classpath entry that appears in the raw classpath. However, this does not mean that the other referencing entries do not relate to their referenced entries. See JavaCore.getReferencedClasspathEntries(IClasspathEntry, IJavaProject) for more details.

Returns:
the classpath entry that is referencing this entry or null if not applicable.
Since:
3.6

isExported

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

IClasspathEntry getResolvedEntry()
Deprecated. Use JavaCore.getResolvedClasspathEntry(IClasspathEntry) instead

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:

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
Release 3.8

Guidelines for using Eclipse APIs.

Copyright (c) 2000, 2012 IBM Corporation and others. All rights reserved.