|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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:
.java
source files. The root folder itself represents a default
package, subfolders represent package fragments, and .java
files
represent compilation units. All compilation units will be compiled when
the project is built. The classpath entry must specify the
absolute path to the root folder. Entries of this kind are
associated with the CPE_SOURCE
constant..class
files. The classpath entry
must specify the absolute path to the JAR (or root folder), and in case it refers
to an external JAR, then there is no associated resource in the workbench. Entries
of this kind are associated with the CPE_LIBRARY
constant..class
files when building). When performing other
"development" operations - such as code assist, code resolve, type hierarchy
creation, etc. - the source code of the project is referred to. Thus, development
is performed against a required project's source code, and compilation is
performed against a required project's last built state. The
classpath entry must specify the absolute path to the
project. Entries of this kind are associated with the CPE_PROJECT
constant.
Note: referencing a required project with a classpath entry refers to the source
code or associated .class
files located in its output location.
It will also automatically include any other libraries or projects that the required project's classpath
refers to, iff the corresponding classpath entries are tagged as being exported
(IClasspathEntry#isExported
).
Unless exporting some classpath entries, classpaths are not chained by default -
each project must specify its own classpath in its entirety.CPE_VARIABLE
constant.
Classpath variables are created using JavaCore#setClasspathVariable
,
and gets resolved, to either a project or library entry, using
JavaCore#getResolvedClasspathVariable
.
It is also possible to register an automatic initializer (ClasspathVariableInitializer
),
which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
After resolution, a classpath variable entry may either correspond to a project or a library entry. CPE_CONTAINER
. Typically, a classpath container can
be used to describe a complex library composed of multiple JARs, projects or classpath variables,
considering also that containers can be mapped differently on each project. Several projects can
reference the same generic container path, but have each of them actually bound to a different
container object.
The container path is a formed by a first ID segment followed with extra segments,
which can be used as additional hints for resolving this container reference. If no container was ever
recorded for this container path onto this project (using setClasspathContainer
,
then a ClasspathContainerInitializer
will be activated if any was registered for this
container ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
A classpath container entry can be resolved explicitly using JavaCore#getClasspathContainer
and the resulting container entries can contain any non-container entry. In particular, it may contain variable
entries, which in turn needs to be resolved before being directly used.
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
.
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 |
public static final int CPE_LIBRARY
public static final int CPE_PROJECT
public static final int CPE_SOURCE
public static final int CPE_VARIABLE
public static final int CPE_CONTAINER
Method Detail |
public int getContentKind()
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
).public int getEntryKind()
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
public IPath getPath()
CPE_SOURCE
) -
The path associated with this entry is the absolute path to the root folder. CPE_LIBRARY
) - the path
associated with this entry is the absolute path to the JAR (or root folder), and
in case it refers to an external JAR, then there is no associated resource in
the workbench.
CPE_PROJECT
) - the path of the entry denotes the
path to the corresponding project resource.CPE_VARIABLE
) - the first segment of the path
is the name of a classpath variable. If this classpath variable
is bound to the path CPE_CONTAINER
) - the path of the entry
is the name of the classpath container, which can be bound indirectly to a set of classpath
entries after resolution. The containerPath is a formed by a first ID segment followed with
extra segments that can be used as additional hints for resolving this container
reference (also see IClasspathContainer
).
public IPath getSourceAttachmentPath()
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.
null
if nonepublic IPath getSourceAttachmentRootPath()
null
value
if and only if getSourceAttachmentPath
returns
a non-null
value.
null
if
not applicablepublic boolean isExported()
false
for source entries (kind
CPE_SOURCE
), which cannot be exported.
true
if exported, and false
otherwisepublic IClasspathEntry getResolvedEntry()
null
null
Variable source attachment is also resolved and recorded in the resulting classpath entry.
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 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |