Eclipse JDT
2.1

org.eclipse.jdt.core
Class ClasspathContainerInitializer

java.lang.Object
  |
  +--org.eclipse.jdt.core.ClasspathContainerInitializer

public abstract class ClasspathContainerInitializer
extends Object

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 resolve.

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.

Since:
2.0
See Also:
IClasspathEntry, IClasspathContainer

Constructor Summary
ClasspathContainerInitializer()
          Creates a new classpath container initializer.
 
Method Summary
 boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project)
          Returns true if this container initializer can be requested to perform updates on its own container values.
 String getDescription(IPath containerPath, IJavaProject project)
          Returns a readable description for a container path.
abstract  void initialize(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(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClasspathContainerInitializer

public ClasspathContainerInitializer()
Creates a new classpath container initializer.
Method Detail

initialize

public abstract void initialize(IPath containerPath,
                                IJavaProject project)
                         throws CoreException
Binds a classpath container to a 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 can set the corresponding container using JavaCore#setClasspathContainer.

Parameters:
containerPath - a two-segment path (ID/hint) identifying the container that needs to be resolved
project - the Java project in which context the container is to be resolved. This allows generic containers to be bound with project specific values.
See Also:
JavaCore.getClasspathContainer(IPath, IJavaProject), JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor), IClasspathContainer

canUpdateClasspathContainer

public boolean canUpdateClasspathContainer(IPath containerPath,
                                           IJavaProject project)
Returns 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 ClasspathContainerInitializer#requestClasspathContainerUpdate/

Parameters:
containerPath - the path of the container which requires to be updated
project - the project for which the container is to be updated
Returns:
returns true if the container can be updated
Since:
2.1

requestClasspathContainerUpdate

public void requestClasspathContainerUpdate(IPath containerPath,
                                            IJavaProject project,
                                            IClasspathContainer containerSuggestion)
                                     throws CoreException
Request a registered container definition to be updated according to a container suggestion. The container suggestion only acts as a place-holder to pass along the information to update the matching container definition(s) held by the container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust the actual container definition based on suggested changes.

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 JavaCore#canUpdateClasspathContainer should be used.

Parameters:
containerPath - the path of the container which requires to be updated
project - the project for which the container is to be updated
containerSuggestion - a suggestion to update the corresponding container definition
Throws:
CoreException - when JavaCore#setClasspathContainer would throw any.
Since:
2.1
See Also:
JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor), canUpdateClasspathContainer(IPath, IJavaProject)

getDescription

public String getDescription(IPath containerPath,
                             IJavaProject project)
Returns a readable description for a container path. A readable description for a container path can be used for improving the display of references to container, without actually needing to resolve them. A good implementation should answer a description consistent with the description of the associated target container (see IClasspathContainer.getDescription()).
Parameters:
containerPath - the path of the container which requires a readable description
project - the project from which the container is referenced
Returns:
a string description of the container
Since:
2.1

Eclipse JDT
2.1

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