Eclipse Platform v3.1

org.eclipse.jdt.internal.core
Class ClasspathEntry

java.lang.Object
  extended by org.eclipse.jdt.internal.core.ClasspathEntry
All Implemented Interfaces:
IClasspathEntry

public class ClasspathEntry
extends Object
implements IClasspathEntry

See Also:
IClasspathEntry

Field Summary
 int contentKind
          Describes the kind of package fragment roots found on this classpath entry - either K_BINARY or K_SOURCE or K_OUTPUT.
 int entryKind
          Describes the kind of classpath entry - one of CPE_PROJECT, CPE_LIBRARY, CPE_SOURCE, CPE_VARIABLE or CPE_CONTAINER
static IPath[] EXCLUDE_NONE
           
static IPath[] INCLUDE_ALL
           
 boolean isExported
          The export flag
static int K_OUTPUT
          A constant indicating an output location.
static IAccessRule[] NO_ACCESS_RULES
           
static IClasspathAttribute[] NO_EXTRA_ATTRIBUTES
           
 IPath path
          The meaning of the path of a classpath entry depends on its entry kind: Source code in the current project (CPE_SOURCE) - The path associated with this entry is the absolute path to the root folder.
 IPath sourceAttachmentPath
          Describes the path to the source archive associated with this classpath entry, or null if this classpath entry has no source attachment.
 IPath sourceAttachmentRootPath
          Describes the path within the source archive where package fragments are located.
 IPath specificOutputLocation
          Specific output location (for this source entry)
static String TAG_ACCESS_RULE
           
static String TAG_ACCESS_RULES
           
static String TAG_ACCESSIBLE
           
static String TAG_ATTRIBUTE
           
static String TAG_ATTRIBUTE_NAME
           
static String TAG_ATTRIBUTE_VALUE
           
static String TAG_ATTRIBUTES
           
static String TAG_CLASSPATH
           
static String TAG_CLASSPATHENTRY
           
static String TAG_COMBINE_ACCESS_RULES
           
static String TAG_DISCOURAGED
           
static String TAG_EXCLUDING
           
static String TAG_EXPORTED
           
static String TAG_INCLUDING
           
static String TAG_KIND
           
static String TAG_NON_ACCESSIBLE
           
static String TAG_OUTPUT
           
static String TAG_PATH
           
static String TAG_PATTERN
           
static String TAG_ROOTPATH
           
static String TAG_SOURCEPATH
           
 
Fields inherited from interface org.eclipse.jdt.core.IClasspathEntry
CPE_CONTAINER, CPE_LIBRARY, CPE_PROJECT, CPE_SOURCE, CPE_VARIABLE
 
Constructor Summary
ClasspathEntry(int contentKind, int entryKind, IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath specificOutputLocation, boolean isExported, IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes)
          Creates a class path entry of the specified kind with the given path.
 
Method Summary
 boolean combineAccessRules()
          Returns whether the access rules of the project's exported entries should be combined with this entry's access rules.
 ClasspathEntry combineWith(ClasspathEntry referringEntry)
          Used to perform export/restriction propagation across referring projects/containers
static IClasspathEntry elementDecode(Element element, IJavaProject project, Map unknownElements)
           
 void elementEncode(org.eclipse.jdt.internal.core.XMLWriter writer, IPath projectPath, boolean indent, boolean newLine, Map unknownElements)
          Returns the XML encoding of the class path.
 boolean equals(Object object)
          Returns true if the given object is a classpath entry with equivalent attributes.
 char[][] fullExclusionPatternChars()
           
 char[][] fullInclusionPatternChars()
           
 IAccessRule[] getAccessRules()
          Returns the possibly empty list of access rules for this entry.
static IAccessRule[] getAccessRules(IPath[] accessibleFiles, IPath[] nonAccessibleFiles)
           
 AccessRuleSet getAccessRuleSet()
           
static NodeList getChildAttributes(String childName, NodeList children, boolean[] foundChildren)
           
 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 getResolvedEntry()
          Deprecated.  
 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.
 int hashCode()
          Returns the hash code for this classpath entry
 boolean isExported()
          Returns whether this entry is exported to dependent projects.
 String rootID()
          Answers an ID which is used to distinguish entries during package fragment root computations
 String toString()
          Returns a printable representation of this classpath entry.
static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] rawClasspath, IPath projectOutputLocation)
          Validate a given classpath and output location for a project, using the following rules: Classpath entries cannot collide with each other; that is, all entry paths must be unique.
static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers)
          Returns a Java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine (that is, if the given classpath entry denotes a valid element to be referenced onto a classpath).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_CLASSPATH

public static final String TAG_CLASSPATH
See Also:
Constant Field Values

TAG_CLASSPATHENTRY

public static final String TAG_CLASSPATHENTRY
See Also:
Constant Field Values

TAG_OUTPUT

public static final String TAG_OUTPUT
See Also:
Constant Field Values

TAG_KIND

public static final String TAG_KIND
See Also:
Constant Field Values

TAG_PATH

public static final String TAG_PATH
See Also:
Constant Field Values

TAG_SOURCEPATH

public static final String TAG_SOURCEPATH
See Also:
Constant Field Values

TAG_ROOTPATH

public static final String TAG_ROOTPATH
See Also:
Constant Field Values

TAG_EXPORTED

public static final String TAG_EXPORTED
See Also:
Constant Field Values

TAG_INCLUDING

public static final String TAG_INCLUDING
See Also:
Constant Field Values

TAG_EXCLUDING

public static final String TAG_EXCLUDING
See Also:
Constant Field Values

TAG_ATTRIBUTES

public static final String TAG_ATTRIBUTES
See Also:
Constant Field Values

TAG_ATTRIBUTE

public static final String TAG_ATTRIBUTE
See Also:
Constant Field Values

TAG_ATTRIBUTE_NAME

public static final String TAG_ATTRIBUTE_NAME
See Also:
Constant Field Values

TAG_ATTRIBUTE_VALUE

public static final String TAG_ATTRIBUTE_VALUE
See Also:
Constant Field Values

TAG_COMBINE_ACCESS_RULES

public static final String TAG_COMBINE_ACCESS_RULES
See Also:
Constant Field Values

TAG_ACCESS_RULES

public static final String TAG_ACCESS_RULES
See Also:
Constant Field Values

TAG_ACCESS_RULE

public static final String TAG_ACCESS_RULE
See Also:
Constant Field Values

TAG_PATTERN

public static final String TAG_PATTERN
See Also:
Constant Field Values

TAG_ACCESSIBLE

public static final String TAG_ACCESSIBLE
See Also:
Constant Field Values

TAG_NON_ACCESSIBLE

public static final String TAG_NON_ACCESSIBLE
See Also:
Constant Field Values

TAG_DISCOURAGED

public static final String TAG_DISCOURAGED
See Also:
Constant Field Values

entryKind

public int entryKind
Describes the kind of classpath entry - one of CPE_PROJECT, CPE_LIBRARY, CPE_SOURCE, CPE_VARIABLE or CPE_CONTAINER


contentKind

public int contentKind
Describes the kind of package fragment roots found on this classpath entry - either K_BINARY or K_SOURCE or K_OUTPUT.


path

public IPath path
The meaning of the path of a classpath entry depends on its entry kind:

INCLUDE_ALL

public static final IPath[] INCLUDE_ALL

EXCLUDE_NONE

public static final IPath[] EXCLUDE_NONE

NO_EXTRA_ATTRIBUTES

public static final IClasspathAttribute[] NO_EXTRA_ATTRIBUTES

NO_ACCESS_RULES

public static final IAccessRule[] NO_ACCESS_RULES

sourceAttachmentPath

public IPath sourceAttachmentPath
Describes 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.


sourceAttachmentRootPath

public IPath sourceAttachmentRootPath
Describes 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.


specificOutputLocation

public IPath specificOutputLocation
Specific output location (for this source entry)


K_OUTPUT

public static final int K_OUTPUT
A constant indicating an output location.

See Also:
Constant Field Values

isExported

public boolean isExported
The export flag

Constructor Detail

ClasspathEntry

public ClasspathEntry(int contentKind,
                      int entryKind,
                      IPath path,
                      IPath[] inclusionPatterns,
                      IPath[] exclusionPatterns,
                      IPath sourceAttachmentPath,
                      IPath sourceAttachmentRootPath,
                      IPath specificOutputLocation,
                      boolean isExported,
                      IAccessRule[] accessRules,
                      boolean combineAccessRules,
                      IClasspathAttribute[] extraAttributes)
Creates a class path entry of the specified kind with the given path.

Method Detail

combineAccessRules

public boolean combineAccessRules()
Description copied from interface: IClasspathEntry
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.

Specified by:
combineAccessRules in interface IClasspathEntry
Returns:
whether the access rules of the project's exported entries should be combined with this entry's access rules

combineWith

public ClasspathEntry combineWith(ClasspathEntry referringEntry)
Used to perform export/restriction propagation across referring projects/containers


fullExclusionPatternChars

public char[][] fullExclusionPatternChars()

fullInclusionPatternChars

public char[][] fullInclusionPatternChars()

elementEncode

public void elementEncode(org.eclipse.jdt.internal.core.XMLWriter writer,
                          IPath projectPath,
                          boolean indent,
                          boolean newLine,
                          Map unknownElements)
Returns the XML encoding of the class path.


elementDecode

public static IClasspathEntry elementDecode(Element element,
                                            IJavaProject project,
                                            Map unknownElements)

getChildAttributes

public static NodeList getChildAttributes(String childName,
                                          NodeList children,
                                          boolean[] foundChildren)

equals

public boolean equals(Object object)
Returns true if the given object is a classpath entry with equivalent attributes.

Overrides:
equals in class Object

getAccessRules

public IAccessRule[] getAccessRules()
Description copied from interface: IClasspathEntry
Returns the possibly empty list of access rules for this entry.

Specified by:
getAccessRules in interface IClasspathEntry
Returns:
the possibly empty list of access rules for this entry
See Also:
IClasspathEntry.getAccessRules()

getAccessRuleSet

public AccessRuleSet getAccessRuleSet()

getContentKind

public int getContentKind()
Description copied from interface: IClasspathEntry
Returns the kind of files found in the package fragments identified by this classpath entry.

Specified by:
getContentKind in interface IClasspathEntry
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).
See Also:
IClasspathEntry

getEntryKind

public int getEntryKind()
Description copied from interface: IClasspathEntry
Returns the kind of this classpath entry.

Specified by:
getEntryKind in interface IClasspathEntry
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
See Also:
IClasspathEntry

getExclusionPatterns

public IPath[] getExclusionPatterns()
Description copied from interface: IClasspathEntry
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 enry, 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:

Specified by:
getExclusionPatterns in interface IClasspathEntry
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
See Also:
IClasspathEntry.getExclusionPatterns()

getExtraAttributes

public IClasspathAttribute[] getExtraAttributes()
Description copied from interface: IClasspathEntry
Returns the extra classpath attributes for this classpath entry. Returns an empty array if this entry has no extra attributes.

Specified by:
getExtraAttributes in interface IClasspathEntry
Returns:
the possibly empty list of extra classpath attributes for this classpath entry

getInclusionPatterns

public IPath[] getInclusionPatterns()
Description copied from interface: IClasspathEntry
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 IClasspathEntry.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:

Specified by:
getInclusionPatterns in interface IClasspathEntry
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
See Also:
IClasspathEntry.getExclusionPatterns()

getOutputLocation

public IPath getOutputLocation()
Description copied from interface: IClasspathEntry
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.

Specified by:
getOutputLocation in interface IClasspathEntry
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
See Also:
IClasspathEntry.getOutputLocation()

getPath

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

Specified by:
getPath in interface IClasspathEntry
Returns:
the path of this classpath entry
See Also:
IClasspathEntry

getSourceAttachmentPath

public IPath getSourceAttachmentPath()
Description copied from interface: IClasspathEntry
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 thr 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.

Specified by:
getSourceAttachmentPath in interface IClasspathEntry
Returns:
the path to the source archive or folder, or null if none
See Also:
IClasspathEntry

getSourceAttachmentRootPath

public IPath getSourceAttachmentRootPath()
Description copied from interface: IClasspathEntry
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.

Specified by:
getSourceAttachmentRootPath in interface IClasspathEntry
Returns:
the path within the source archive or folder, or null if not applicable
See Also:
IClasspathEntry

hashCode

public int hashCode()
Returns the hash code for this classpath entry

Overrides:
hashCode in class Object

isExported

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

Specified by:
isExported in interface IClasspathEntry
Returns:
true if exported, and false otherwise
See Also:
IClasspathEntry.isExported()

getAccessRules

public static IAccessRule[] getAccessRules(IPath[] accessibleFiles,
                                           IPath[] nonAccessibleFiles)

toString

public String toString()
Returns a printable representation of this classpath entry.

Overrides:
toString in class Object

rootID

public String rootID()
Answers an ID which is used to distinguish entries during package fragment root computations


getResolvedEntry

public IClasspathEntry getResolvedEntry()
Deprecated. 

Description copied from interface: IClasspathEntry
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.

Specified by:
getResolvedEntry in interface IClasspathEntry
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.

See Also:
IClasspathEntry

validateClasspath

public static IJavaModelStatus validateClasspath(IJavaProject javaProject,
                                                 IClasspathEntry[] rawClasspath,
                                                 IPath projectOutputLocation)
Validate a given classpath and output location for a project, using the following rules: Note that the classpath entries are not validated automatically. Only bound variables or containers are considered in the checking process (this allows to perform a consistency check on a classpath which has references to yet non existing projects, folders, ...).

This validation is intended to anticipate classpath issues prior to assigning it to a project. In particular, it will automatically be performed during the classpath setting operation (if validation fails, the classpath setting will not complete).

Parameters:
javaProject - the given java project
rawClasspath - a given classpath
projectOutputLocation - a given output location
Returns:
a status object with code IStatus.OK if the given classpath and output location are compatible, otherwise a status object indicating what is wrong with the classpath or output location

validateClasspathEntry

public static IJavaModelStatus validateClasspathEntry(IJavaProject project,
                                                      IClasspathEntry entry,
                                                      boolean checkSourceAttachment,
                                                      boolean recurseInContainers)
Returns a Java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine (that is, if the given classpath entry denotes a valid element to be referenced onto a classpath).

Parameters:
project - the given java project
entry - the given classpath entry
checkSourceAttachment - a flag to determine if source attachement should be checked
recurseInContainers - flag indicating whether validation should be applied to container entries recursively
Returns:
a java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine

Eclipse Platform v3.1