org.netbeans.modules.java.project/1 1.46

org.netbeans.api.java.project.classpath
Class ProjectClassPathModifier

java.lang.Object
  extended by org.netbeans.api.java.project.classpath.ProjectClassPathModifier

public class ProjectClassPathModifier
extends Object

An API for project's classpaths modification. An client can use this interface to add/remove classpath element (folder, archive, library, subproject) to/from the project's classpath. Not all operations on all project's classpath are supported, if the project type does not support a modification of a given classpath the UnsupportedOperationException is thrown.

Since:
org.netbeans.modules.java.project/1 1.10

Method Summary
static boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, FileObject projectArtifact, String classPathType)
          Adds artifacts (e.g.
static boolean addLibraries(Library[] libraries, FileObject projectArtifact, String classPathType)
          Adds libraries into the project's classpath if the libraries are not already included.
static boolean addProjects(Project[] projects, FileObject projectArtifact, String classPathType)
          Adds projects into project's classpath if the artifacts are not already on it.
static boolean addRoots(URI[] classPathRoots, FileObject projectArtifact, String classPathType)
          Adds archive files or folders into the project's classpath if the entries are not already there.
static boolean addRoots(URL[] classPathRoots, FileObject projectArtifact, String classPathType)
          Adds archive files or folders into the project's classpath if the entries are not already there.
static ProjectClassPathExtender extenderForModifier(Project p)
          Similar to extenderForModifier(ProjectClassPathModifierImplementation) but permits the new SPI to be created lazily.
static ProjectClassPathExtender extenderForModifier(ProjectClassPathModifierImplementation pcpmi)
          Translates the new SPI into an instance of the old SPI.
static boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, FileObject projectArtifact, String classPathType)
          Removes artifacts (e.g.
static boolean removeLibraries(Library[] libraries, FileObject projectArtifact, String classPathType)
          Removes libraries from the project's classpath if the libraries are included on it.
static boolean removeRoots(URI[] classPathRoots, FileObject projectArtifact, String classPathType)
          Removes archive files or folders from the project's classpath if the entries are included on it.
static boolean removeRoots(URL[] classPathRoots, FileObject projectArtifact, String classPathType)
          Removes archive files or folders from the project's classpath if the entries are included on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addLibraries

public static boolean addLibraries(Library[] libraries,
                                   FileObject projectArtifact,
                                   String classPathType)
                            throws IOException,
                                   UnsupportedOperationException
Adds libraries into the project's classpath if the libraries are not already included.

Parameters:
libraries - to be added
projectArtifact - a file whose classpath should be extended
classPathType - the type of classpath to be extended, @see ClassPath
Returns:
true in case the classpath was changed (at least one library was added to the classpath), the value false is returned when all the libraries are already included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support adding of a library to the classpath of the given type.

removeLibraries

public static boolean removeLibraries(Library[] libraries,
                                      FileObject projectArtifact,
                                      String classPathType)
                               throws IOException,
                                      UnsupportedOperationException
Removes libraries from the project's classpath if the libraries are included on it.

Parameters:
libraries - to be removed
projectArtifact - a file from whose classpath the libraries should be removed
classPathType - the type of classpath, @see ClassPath
Returns:
true in case the classpath was changed, (at least one library was removed from the classpath), the value false is returned when none of the libraries was included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support removing of a library from the classpath of the given type.

addRoots

public static boolean addRoots(URL[] classPathRoots,
                               FileObject projectArtifact,
                               String classPathType)
                        throws IOException,
                               UnsupportedOperationException
Adds archive files or folders into the project's classpath if the entries are not already there.

Parameters:
classPathRoots - roots to be added, each root has to be either a root of an archive or a folder url
projectArtifact - a file whose classpath should be extended
classPathType - the type of classpath to be extended, @see ClassPath
Returns:
true in case the classpath was changed, (at least one classpath root was added to the classpath), the value false is returned when all the classpath roots are already included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support adding of a root to the classpath of the given type.

addRoots

public static boolean addRoots(URI[] classPathRoots,
                               FileObject projectArtifact,
                               String classPathType)
                        throws IOException,
                               UnsupportedOperationException
Adds archive files or folders into the project's classpath if the entries are not already there.

Parameters:
classPathRoots - roots to be added, each root has to be either a root of an archive or a folder url; URI can be relative
projectArtifact - a file whose classpath should be extended
classPathType - the type of classpath to be extended, @see ClassPath
Returns:
true in case the classpath was changed, (at least one classpath root was added to the classpath), the value false is returned when all the classpath roots are already included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support adding of a root to the classpath of the given type.
Since:
org.netbeans.modules.java.project/1 1.16

removeRoots

public static boolean removeRoots(URL[] classPathRoots,
                                  FileObject projectArtifact,
                                  String classPathType)
                           throws IOException,
                                  UnsupportedOperationException
Removes archive files or folders from the project's classpath if the entries are included on it.

Parameters:
classPathRoots - roots to be removed, each root has to be either a root of an archive or a folder
projectArtifact - a file from whose classpath the roots should be removed
classPathType - the type of classpath, @see ClassPath
Returns:
true in case the classpath was changed, (at least one classpath root was removed from the classpath), the value false is returned when none of the classpath roots was included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support removing of a root from the classpath of the given type.

removeRoots

public static boolean removeRoots(URI[] classPathRoots,
                                  FileObject projectArtifact,
                                  String classPathType)
                           throws IOException,
                                  UnsupportedOperationException
Removes archive files or folders from the project's classpath if the entries are included on it.

Parameters:
classPathRoots - roots to be removed, each root has to be either a root of an archive or a folder; URI can be relative
projectArtifact - a file from whose classpath the roots should be removed
classPathType - the type of classpath, @see ClassPath
Returns:
true in case the classpath was changed, (at least one classpath root was removed from the classpath), the value false is returned when none of the classpath roots was included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support removing of a root from the classpath of the given type.
Since:
org.netbeans.modules.java.project/1 1.16

addAntArtifacts

public static boolean addAntArtifacts(AntArtifact[] artifacts,
                                      URI[] artifactElements,
                                      FileObject projectArtifact,
                                      String classPathType)
                               throws IOException,
                                      UnsupportedOperationException
Adds artifacts (e.g. subprojects) into project's classpath if the artifacts are not already on it.

Parameters:
artifacts - to be added
artifactElements - the URIs of the build output, the artifactElements has to have the same length as artifacts. (must be owned by the artifact and be relative to it)
projectArtifact - a file whose classpath should be extended
classPathType - the type of classpath to be extended, @see ClassPath
Returns:
true in case the classpath was changed, (at least one artifact was added to the classpath), the value false is returned when all the artifacts are already included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support adding of an artifact to the classpath of the given type.

addProjects

public static boolean addProjects(Project[] projects,
                                  FileObject projectArtifact,
                                  String classPathType)
                           throws IOException,
                                  UnsupportedOperationException
Adds projects into project's classpath if the artifacts are not already on it.

It's not guaranteed that the source and target project will connect in cases when each is of different class of project. Eg. Ant-based vs Maven project types. A way to check is to attempt to retrieve AntArtifact from the source and target projects..

Parameters:
projects - to be added
projectArtifact - a file whose classpath should be extended
classPathType - the type of classpath to be extended, see ClassPath
Returns:
true in case the classpath was changed, (at least one artifact was added to the classpath), the value false is returned when all the artifacts are already included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support adding of an artifact to the classpath of the given type.
Since:
org.netbeans.modules.java.project/1 1.24

removeAntArtifacts

public static boolean removeAntArtifacts(AntArtifact[] artifacts,
                                         URI[] artifactElements,
                                         FileObject projectArtifact,
                                         String classPathType)
                                  throws IOException,
                                         UnsupportedOperationException
Removes artifacts (e.g. subprojects) from project's classpath if the artifacts are included on it.

Parameters:
artifacts - to be added
artifactElements - the URIs of the build output, the artifactElements has to have the same length as artifacts. (must be owned by the artifact and be relative to it)
projectArtifact - a file from whose classpath the dependent projects should be removed
classPathType - the type of classpath, ClassPath
Returns:
true in case the classpath was changed, (at least one artifact was removed from the classpath), the value false is returned when none of the artifacts was included on the classpath.
Throws:
IOException - in case the project metadata cannot be changed
UnsupportedOperationException - is thrown when the project does not support removing of an artifact from the classpath of the given type.

extenderForModifier

public static ProjectClassPathExtender extenderForModifier(ProjectClassPathModifierImplementation pcpmi)
Translates the new SPI into an instance of the old SPI. Useful to place in project lookup so that you need not bother implementing the old SPI. (Since there was not previously a matching API, old clients may directly look for the old SPI interface in a project's lookup.) Corresponding methods are called using the first reported source group (if any) and extensible classpath type (if any).

Parameters:
pcpmi - the new SPI
Returns:
a proxy fitting the old SPI
Since:
1.41
See Also:
extenderForModifier(Project)

extenderForModifier

public static ProjectClassPathExtender extenderForModifier(Project p)
Similar to extenderForModifier(ProjectClassPathModifierImplementation) but permits the new SPI to be created lazily. This is useful if the project is using LookupMergerSupport.createClassPathModifierMerger() and it is thus impossible to get the final SPI instance during construction of the project's lookup. The new SPI is located at runtime on each call; if not present, false is returned from all methods.

Parameters:
p - a project whose lookup may contain a ProjectClassPathModifierImplementation
Returns:
an SPI equivalent
Since:
1.41

org.netbeans.modules.java.project/1 1.46

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.