|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jdt.core.ClasspathContainerInitializer
public abstract class ClasspathContainerInitializer
Abstract base implementation of all classpath container initializer. Classpath variable containers are used in conjunction with the "org.eclipse.jdt.core.classpathContainerInitializer" extension point.
Clients should subclass this class to implement a specific classpath
container initializer. The subclass must have a public 0-argument
constructor and a concrete implementation of initialize(IPath, IJavaProject)
.
Multiple classpath containers can be registered, each of them declares the container ID they can handle, so as to narrow the set of containers they can resolve, in other words, a container initializer is guaranteed to only be activated to resolve containers which match the ID they registered onto.
In case multiple container initializers collide on the same container ID, the first registered one will be invoked.
IClasspathEntry
,
IClasspathContainer
Field Summary | |
---|---|
static int |
ATTRIBUTE_NOT_SUPPORTED
Status code indicating that an attribute is not supported. |
static int |
ATTRIBUTE_READ_ONLY
Status code indicating that an attribute is not modifiable. |
Constructor Summary | |
---|---|
ClasspathContainerInitializer()
Creates a new classpath container initializer. |
Method Summary | |
---|---|
boolean |
canUpdateClasspathContainer(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns true if this container initializer can be requested to perform updates
on its own container values. |
org.eclipse.core.runtime.IStatus |
getAccessRulesStatus(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns the access rules attribute status according to this initializer. |
org.eclipse.core.runtime.IStatus |
getAttributeStatus(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project,
java.lang.String attributeKey)
Returns the extra attribute status according to this initializer. |
java.lang.Object |
getComparisonID(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns an object which identifies a container for comparison purpose. |
java.lang.String |
getDescription(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns a readable description for a container path. |
IClasspathContainer |
getFailureContainer(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns a classpath container that is used after this initializer failed to bind a classpath container to a IClasspathContainer for the given project. |
org.eclipse.core.runtime.IStatus |
getSourceAttachmentStatus(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Returns the source attachment attribute status according to this initializer. |
abstract void |
initialize(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project)
Binds a classpath container to a IClasspathContainer for a given project,
or silently fails if unable to do so. |
void |
requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath containerPath,
IJavaProject project,
IClasspathContainer containerSuggestion)
Request a registered container definition to be updated according to a container suggestion. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ATTRIBUTE_NOT_SUPPORTED
getAccessRulesStatus(IPath, IJavaProject)
,
getAttributeStatus(IPath, IJavaProject, String)
,
getSourceAttachmentStatus(IPath, IJavaProject)
,
Constant Field Valuespublic static final int ATTRIBUTE_READ_ONLY
getAccessRulesStatus(IPath, IJavaProject)
,
getAttributeStatus(IPath, IJavaProject, String)
,
getSourceAttachmentStatus(IPath, IJavaProject)
,
Constant Field ValuesConstructor Detail |
---|
public ClasspathContainerInitializer()
Method Detail |
---|
public abstract void initialize(org.eclipse.core.runtime.IPath containerPath, IJavaProject project) throws org.eclipse.core.runtime.CoreException
IClasspathContainer
for a given project,
or silently fails if unable to do so.
A container is identified by a container path, which must be formed of two segments. The first segment is used as a unique identifier (which this initializer did register onto), and the second segment can be used as an additional hint when performing the resolution.
The initializer is invoked if a container path needs to be resolved for a given project, and no
value for it was recorded so far. The implementation of the initializer would typically set the
corresponding container using JavaCore#setClasspathContainer
.
A container initialization can be indirectly performed while attempting to resolve a project
classpath using IJavaProject#getResolvedClasspath(
; or directly when using
JavaCore#getClasspathContainer
. During the initialization process, any attempt
to further obtain the same container will simply return null
so as to avoid an
infinite regression of initializations.
A container initialization may also occur indirectly when setting a project classpath, as the operation needs to resolve the classpath for validation purpose. While the operation is in progress, a referenced container initializer may be invoked. If the initializer further tries to access the referring project classpath, it will not see the new assigned classpath until the operation has completed. Note that once the Java change notification occurs (at the end of the operation), the model has been updated, and the project classpath can be queried normally.
This method is called by the Java model to give the party that defined this particular kind of classpath container the chance to install classpath container objects that will be used to convert classpath container entries into simpler classpath entries. The method is typically called exactly once for a given Java project and classpath container entry. This method must not be called by other clients.
There are a wide variety of conditions under which this method may be invoked. To ensure that the implementation does not interfere with correct functioning of the Java model, the implementation should use only the following Java model APIs:
JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
JavaCore.getClasspathContainer(IPath, IJavaProject)
JavaCore.create(org.eclipse.core.resources.IWorkspaceRoot)
JavaCore.create(org.eclipse.core.resources.IProject)
IJavaModel.getJavaProjects()
containerPath
- a two-segment path (ID/hint) identifying the container that needs
to be resolvedproject
- the Java project in which context the container is to be resolved.
This allows generic containers to be bound with project specific values.
org.eclipse.core.runtime.CoreException
- if an exception occurs during the initializationJavaCore.getClasspathContainer(IPath, IJavaProject)
,
JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
,
IClasspathContainer
public boolean canUpdateClasspathContainer(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
true
if this container initializer can be requested to perform updates
on its own container values. If so, then an update request will be performed using
requestClasspathContainerUpdate(IPath, IJavaProject, IClasspathContainer)
.
containerPath
- the path of the container which requires to be updatedproject
- the project for which the container is to be updated
true
if the container can be updatedpublic void requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws org.eclipse.core.runtime.CoreException
IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding
container definition (after reconciling changes) at its earliest convenience, using
JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
.
Until it does so, the update will not be reflected in the Java Model.
In order to anticipate whether the container initializer allows to update its containers, the predicate
canUpdateClasspathContainer(IPath, IJavaProject)
should be used.
containerPath
- the path of the container which requires to be updatedproject
- the project for which the container is to be updatedcontainerSuggestion
- a suggestion to update the corresponding container definition
org.eclipse.core.runtime.CoreException
- when JavaCore#setClasspathContainer
would throw any.JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
,
canUpdateClasspathContainer(IPath, IJavaProject)
public java.lang.String getDescription(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
IClasspathContainer.getDescription()
).
containerPath
- the path of the container which requires a readable descriptionproject
- the project from which the container is referenced
public IClasspathContainer getFailureContainer(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
IClasspathContainer
for the given project. A non-null
failure container indicates that there will be no more request to initialize the given container
for the given project.
By default a non-null
failure container with no classpath entries is returned.
Clients wishing to get a chance to run the initializer again should override this method
and return null
.
containerPath
- the path of the container which failed to initializeproject
- the project from which the container is referenced
null
if wishing to run the initializer againpublic java.lang.Object getComparisonID(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
containerPath
- the path of the container which is being checkedproject
- the project for which the container is to being checked
public org.eclipse.core.runtime.IStatus getAccessRulesStatus(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the classpath container can
be updated (see canUpdateClasspathContainer(IPath, IJavaProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updated
public org.eclipse.core.runtime.IStatus getAttributeStatus(org.eclipse.core.runtime.IPath containerPath, IJavaProject project, java.lang.String attributeKey)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the classpath container can
be updated (see canUpdateClasspathContainer(IPath, IJavaProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updatedattributeKey
- the key of the extra attribute
IClasspathAttribute
public org.eclipse.core.runtime.IStatus getSourceAttachmentStatus(org.eclipse.core.runtime.IPath containerPath, IJavaProject project)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the classpath container can
be updated (see canUpdateClasspathContainer(IPath, IJavaProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updated
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |