Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jdt.core
Interface IPackageFragmentRoot

All Superinterfaces:
  IAdaptable, IJavaElement, IOpenable, IParent

public interface IPackageFragmentRoot
extends IParent, IJavaElement, IOpenable

A package fragment root contains a set of package fragments. It corresponds to an underlying resource which is either a folder, JAR, or zip. In the case of a folder, all descendant folders represent package fragments. For a given child folder representing a package fragment, the corresponding package name is composed of the folder names between the folder for this root and the child folder representing the package, separated by '.'. In the case of a JAR or zip, the contents of the archive dictates the set of package fragments in an analogous manner. Package fragment roots need to be opened before they can be navigated or manipulated. The children are of type `IPackageFragment`, and are in no particular order.

This interface is not intended to be implemented by clients.

Field Summary
`static String` | `DEFAULT_PACKAGEROOT_PATH` Empty root path
`static int` | `DESTINATION_PROJECT_CLASSPATH` Update model flag constant (bit mask value 8) indicating that the operation is to update the classpath of the destination project.
`static int` | `K_BINARY` Kind constant for a binary path root.
`static int` | `K_SOURCE` Kind constant for a source path root.
`static int` | `NO_RESOURCE_MODIFICATION` Update model flag constant (bit mask value 1) indicating that the operation is to not copy/move/delete the package fragment root resource.
`static int` | `ORIGINATING_PROJECT_CLASSPATH` Update model flag constant (bit mask value 2) indicating that the operation is to update the classpath of the originating project.
`static int` | `OTHER_REFERRING_PROJECTS_CLASSPATH` Update model flag constant (bit mask value 4) indicating that the operation is to update the classpath of all referring projects except the originating project.
`static int` | `REPLACE` Update model flag constant (bit mask value 16) indicating that the operation is to replace the resource and the destination project's classpath entry.

Fields inherited from interface org.eclipse.jdt.core.IJavaElement
`CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE`

Method Summary
`void` | `attachSource(IPath sourcePath, IPath rootPath, IProgressMonitor monitor)` Attaches the source archive identified by the given absolute path to this binary package fragment root.
`void` | `copy(IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, IProgressMonitor monitor)` Copies the resource of this package fragment root to the destination path as specified by `IResource.copy(IPath, int, IProgressMonitor)` but excluding nested source folders.
`IPackageFragment` | `createPackageFragment(String name, boolean force, IProgressMonitor monitor)` Creates and returns a package fragment in this root with the given dot-separated package name.
`void` | `delete(int updateResourceFlags, int updateModelFlags, IProgressMonitor monitor)` Deletes the resource of this package fragment root as specified by `IResource.delete(int, IProgressMonitor)` but excluding nested source folders.
`int` | `getKind()` Returns this package fragment root's kind encoded as an integer.
`Object[]` | `getNonJavaResources()` Returns an array of non-Java resources contained in this package fragment root.
`IPackageFragment` | `getPackageFragment(String packageName)` Returns the package fragment with the given package name.
`IClasspathEntry` | `getRawClasspathEntry()` Returns the first raw classpath entry that corresponds to this package fragment root.
`IPath` | `getSourceAttachmentPath()` Returns the absolute path to the source archive attached to this package fragment root's binary archive.
`IPath` | `getSourceAttachmentRootPath()` Returns the path within this package fragment root's source archive.
`boolean` | `isArchive()` Returns whether this package fragment root's underlying resource is a binary archive (a JAR or zip file).
`boolean` | `isExternal()` Returns whether this package fragment root is external to the workbench (that is, a local file), and has no underlying resource.
`void` | `move(IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, IProgressMonitor monitor)` Moves the resource of this package fragment root to the destination path as specified by `IResource.move(IPath,int,IProgressMonitor)` but excluding nested source folders.

Methods inherited from interface org.eclipse.jdt.core.IParent
`getChildren, hasChildren`

Methods inherited from interface org.eclipse.jdt.core.IJavaElement
`exists, getAncestor, getCorrespondingResource, getElementName, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown`

Methods inherited from interface org.eclipse.core.runtime.IAdaptable
`getAdapter`

Methods inherited from interface org.eclipse.jdt.core.IOpenable
`close, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save`

Field Detail

### K_SOURCE

    public static final int K_SOURCE

  Kind constant for a source path root. Indicates this root only contains source files.

  See Also:
    Constant Field Values

### K_BINARY

    public static final int K_BINARY

  Kind constant for a binary path root. Indicates this root only contains binary files.

  See Also:
    Constant Field Values

### DEFAULT_PACKAGEROOT_PATH

    public static final String DEFAULT_PACKAGEROOT_PATH

  Empty root path

  See Also:
    Constant Field Values

### NO_RESOURCE_MODIFICATION

    public static final int NO_RESOURCE_MODIFICATION

  Update model flag constant (bit mask value 1) indicating that the operation is to not copy/move/delete the package fragment root resource.

  Since:
    2.1
  See Also:
    Constant Field Values

### ORIGINATING_PROJECT_CLASSPATH

    public static final int ORIGINATING_PROJECT_CLASSPATH

  Update model flag constant (bit mask value 2) indicating that the operation is to update the classpath of the originating project.

  Since:
    2.1
  See Also:
    Constant Field Values

### OTHER_REFERRING_PROJECTS_CLASSPATH

    public static final int OTHER_REFERRING_PROJECTS_CLASSPATH

  Update model flag constant (bit mask value 4) indicating that the operation is to update the classpath of all referring projects except the originating project.

  Since:
    2.1
  See Also:
    Constant Field Values

### DESTINATION_PROJECT_CLASSPATH

    public static final int DESTINATION_PROJECT_CLASSPATH

  Update model flag constant (bit mask value 8) indicating that the operation is to update the classpath of the destination project.

  Since:
    2.1
  See Also:
    Constant Field Values

### REPLACE

    public static final int REPLACE

  Update model flag constant (bit mask value 16) indicating that the operation is to replace the resource and the destination project's classpath entry.

  Since:
    2.1
  See Also:
    Constant Field Values

Method Detail

### attachSource

    public void attachSource(IPath sourcePath,
                             IPath rootPath,
                             IProgressMonitor monitor)
                      throws JavaModelException

  Attaches the source archive identified by the given absolute path to this binary package fragment root. `rootPath` specifies the location of the root within the archive or folder (empty specifies the default root and `null` specifies the root path should be detected). Once a source archive or folder is attached to the package fragment root, the `getSource` and `getSourceRange` methods become operational for binary types/members. To detach a source archive or folder from a package fragment root, specify `null` as the source path.

  Parameters:
    `sourcePath` - the given absolute path to the source archive or folder
    `rootPath` - specifies the location of the root within the archive (empty specifies the default root and `null` specifies automatic detection of the root path)
    `monitor` - the given progress monitor
  Throws:
    `JavaModelException` - if this operation fails. Reasons include:
    - This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
    - A `CoreException` occurred while updating a server property
    - This package fragment root is not of kind binary (INVALID_ELEMENT_TYPES)
    - The path provided is not absolute (RELATIVE_PATH)

### copy

    public void copy(IPath destination,
                     int updateResourceFlags,
                     int updateModelFlags,
                     IClasspathEntry sibling,
                     IProgressMonitor monitor)
              throws JavaModelException

  Copies the resource of this package fragment root to the destination path as specified by `IResource.copy(IPath, int, IProgressMonitor)` but excluding nested source folders.

  If `NO_RESOURCE_MODIFICATION` is specified in `updateModelFlags` or if this package fragment root is external, this operation doesn't copy the resource. `updateResourceFlags` is then ignored.

  If `DESTINATION_PROJECT_CLASSPATH` is specified in `updateModelFlags`, updates the classpath of the destination's project (if it is a Java project). If a non-`null` sibling is specified, a copy of this root's classpath entry is inserted before the sibling on the destination project's raw classpath. If `null` is specified, the classpath entry is added at the end of the raw classpath.

  If `REPLACE` is specified in `updateModelFlags`, overwrites the resource at the destination path if any. If the same classpath entry already exists on the destination project's raw classpath, then the sibling is ignored and the new classpath entry replaces the existing one.

  If no flags is specified in `updateModelFlags` (using `IResource.NONE`), the default behavior applies: the resource is copied (if this package fragment root is not external) and the classpath is not updated.

  Parameters:
    `destination` - the destination path
    `updateResourceFlags` - bit-wise or of update resource flag constants (`IResource.FORCE` and `IResource.SHALLOW`)
    `updateModelFlags` - bit-wise or of update resource flag constants (`DESTINATION_PROJECT_CLASSPATH` and `NO_RESOURCE_MODIFICATION`)
    `sibling` - the classpath entry before which a copy of the classpath entry should be inserted or `null` if the classpath entry should be inserted at the end
    `monitor` - a progress monitor
  Throws:
    `JavaModelException` - if this root could not be copied. Reasons include:
    - This root does not exist (ELEMENT_DOES_NOT_EXIST)
    - A `CoreException` occurred while copying the resource or updating a classpath
    - The destination is not inside an existing project and `updateModelFlags` has been specified as `DESTINATION_PROJECT_CLASSPATH` (INVALID_DESTINATION)
    - The sibling is not a classpath entry on the destination project's raw classpath (INVALID_SIBLING)
    - The same classpath entry already exists on the destination project's classpath (NAME_COLLISION) and `updateModelFlags` has not been specified as `REPLACE`
  Since:
    2.1
  See Also:
    `IResource.copy(IPath, boolean, IProgressMonitor)`

### createPackageFragment

    public IPackageFragment createPackageFragment(String name,
                                                  boolean force,
                                                  IProgressMonitor monitor)
                                           throws JavaModelException

  Creates and returns a package fragment in this root with the given dot-separated package name. An empty string specifies the default package. This has the side effect of creating all package fragments that are a prefix of the new package fragment which do not exist yet. If the package fragment already exists, this has no effect. For a description of the `force` flag, see `IFolder.create`.

  Parameters:
    `name` - the given dot-separated package name
    `force` - a flag controlling how to deal with resources that are not in sync with the local file system
    `monitor` - the given progress monitor
  Returns:
    a package fragment in this root with the given dot-separated package name
  Throws:
    `JavaModelException` - if the element could not be created. Reasons include:
    - This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
    - A `CoreException` occurred while creating an underlying resource
    - This package fragment root is read only (READ_ONLY)
    - The name is not a valid package name (INVALID_NAME)
  See Also:
    `IFolder.create(boolean, boolean, IProgressMonitor)`

### delete

    public void delete(int updateResourceFlags,
                       int updateModelFlags,
                       IProgressMonitor monitor)
                throws JavaModelException

  Deletes the resource of this package fragment root as specified by `IResource.delete(int, IProgressMonitor)` but excluding nested source folders.

  If `NO_RESOURCE_MODIFICATION` is specified in `updateModelFlags` or if this package fragment root is external, this operation doesn't delete the resource. `updateResourceFlags` is then ignored.

  If `ORIGINATING_PROJECT_CLASSPATH` is specified in `updateModelFlags`, update the raw classpath of this package fragment root's project by removing the corresponding classpath entry.

  If `OTHER_REFERRING_PROJECTS_CLASSPATH` is specified in `updateModelFlags`, update the raw classpaths of all other Java projects referring to this root's resource by removing the corresponding classpath entries.

  If no flags is specified in `updateModelFlags` (using `IResource.NONE`), the default behavior applies: the resource is deleted (if this package fragment root is not external) and no classpaths are updated.

  Parameters:
    `updateResourceFlags` - bit-wise or of update resource flag constants (`IResource.FORCE` and `IResource.KEEP_HISTORY`)
    `updateModelFlags` - bit-wise or of update resource flag constants (`ORIGINATING_PROJECT_CLASSPATH`, `OTHER_REFERRING_PROJECTS_CLASSPATH` and `NO_RESOURCE_MODIFICATION`)
    `monitor` - a progress monitor
  Throws:
    `JavaModelException` - if this root could not be deleted. Reasons include:
    - This root does not exist (ELEMENT_DOES_NOT_EXIST)
    - A `CoreException` occurred while deleting the resource or updating a classpath
  Since:
    2.1
  See Also:
    `IResource.delete(boolean, IProgressMonitor)`

### getKind

    public int getKind()
                throws JavaModelException

  Returns this package fragment root's kind encoded as an integer. A package fragment root can contain `.java` source files, or `.class` files, but not both. If the underlying folder or archive contains other kinds of files, they are ignored. In particular, `.class` files are ignored under a source package fragment root, and `.java` files are ignored under a binary package fragment root.

  Returns:
    this package fragment root's kind encoded as an integer
  Throws:
    `JavaModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource.
  See Also:
    `K_SOURCE`, `K_BINARY`

### getNonJavaResources

    public Object[] getNonJavaResources()
                                 throws JavaModelException

  Returns an array of non-Java resources contained in this package fragment root.

  Non-Java resources includes other files and folders located in the same directories as the compilation units or class files under this package fragment root. Resources excluded from this package fragment root by virtue of inclusion/exclusion patterns on the corresponding source classpath entry are considered non-Java resources and will appear in the result (possibly in a folder). Thus when a nested source folder is excluded, it will appear in the non-Java resources of the outer folder.

  Returns:
    an array of non-Java resources (`IFile`s, `IFolder`s, or `IStorage`s if the package fragment root is in archive) contained in this package fragment root
  Throws:
    `JavaModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource.
  See Also:
    `IClasspathEntry.getInclusionPatterns()`, `IClasspathEntry.getExclusionPatterns()`

### getPackageFragment

    public IPackageFragment getPackageFragment(String packageName)

  Returns the package fragment with the given package name. An empty string indicates the default package. This is a handle-only operation. The package fragment may or may not exist.

  Parameters:
    `packageName` - the given package name
  Returns:
    the package fragment with the given package name

### getRawClasspathEntry

    public IClasspathEntry getRawClasspathEntry()
                                         throws JavaModelException

  Returns the first raw classpath entry that corresponds to this package fragment root. A raw classpath entry corresponds to a package fragment root if once resolved this entry's path is equal to the root's path.

  Returns:
    the first raw classpath entry that corresponds to this package fragment root
  Throws:
    `JavaModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource.
  Since:
    2.0

### getSourceAttachmentPath

    public IPath getSourceAttachmentPath()
                                  throws JavaModelException

  Returns the absolute path to the source archive attached to this package fragment root's binary archive.

  Returns:
    the absolute path to the corresponding source archive, or `null` if this package fragment root's binary archive has no corresponding source archive, or if this package fragment root is not a binary archive
  Throws:
    `JavaModelException` - if this operation fails

### getSourceAttachmentRootPath

    public IPath getSourceAttachmentRootPath()
                                      throws JavaModelException

  Returns the path within this package fragment root's source archive. An empty path indicates that packages are located at the root of the source archive.

  Returns:
    the path within the corresponding source archive, or `null` if this package fragment root's binary archive has no corresponding source archive, or if this package fragment root is not a binary archive
  Throws:
    `JavaModelException` - if this operation fails

### isArchive

    public boolean isArchive()

  Returns whether this package fragment root's underlying resource is a binary archive (a JAR or zip file).

  This is a handle-only method.

  Returns:
    true if this package fragment root's underlying resource is a binary archive, false otherwise

### isExternal

    public boolean isExternal()

  Returns whether this package fragment root is external to the workbench (that is, a local file), and has no underlying resource.

  This is a handle-only method.

  Returns:
    true if this package fragment root is external to the workbench (that is, a local file), and has no underlying resource, false otherwise

### move

    public void move(IPath destination,
                     int updateResourceFlags,
                     int updateModelFlags,
                     IClasspathEntry sibling,
                     IProgressMonitor monitor)
              throws JavaModelException

  Moves the resource of this package fragment root to the destination path as specified by `IResource.move(IPath,int,IProgressMonitor)` but excluding nested source folders.

  If `NO_RESOURCE_MODIFICATION` is specified in `updateModelFlags` or if this package fragment root is external, this operation doesn't move the resource. `updateResourceFlags` is then ignored.

  If `DESTINATION_PROJECT_CLASSPATH` is specified in `updateModelFlags`, updates the classpath of the destination's project (if it is a Java project). If a non-`null` sibling is specified, a copy of this root's classpath entry is inserted before the sibling on the destination project's raw classpath. If `null` is specified, the classpath entry is added at the end of the raw classpath.

  If `ORIGINATING_PROJECT_CLASSPATH` is specified in `updateModelFlags`, update the raw classpath of this package fragment root's project by removing the corresponding classpath entry.

  If `OTHER_REFERRING_PROJECTS_CLASSPATH` is specified in `updateModelFlags`, update the raw classpaths of all other Java projects referring to this root's resource by removing the corresponding classpath entries.

  If `REPLACE` is specified in `updateModelFlags`, overwrites the resource at the destination path if any. If the same classpath entry already exists on the destination project's raw classpath, then the sibling is ignored and the new classpath entry replaces the existing one.

  If no flags is specified in `updateModelFlags` (using `IResource.NONE`), the default behavior applies: the resource is moved (if this package fragment root is not external) and no classpaths are updated.

  Parameters:
    `destination` - the destination path
    `updateResourceFlags` - bit-wise or of update flag constants (`IResource.FORCE`, `IResource.KEEP_HISTORY` and `IResource.SHALLOW`)
    `updateModelFlags` - bit-wise or of update resource flag constants (`DESTINATION_PROJECT_CLASSPATH`, `ORIGINATING_PROJECT_CLASSPATH`, `OTHER_REFERRING_PROJECTS_CLASSPATH` and `NO_RESOURCE_MODIFICATION`)
    `sibling` - the classpath entry before which a copy of the classpath entry should be inserted or `null` if the classpath entry should be inserted at the end
    `monitor` - a progress monitor
  Throws:
    `JavaModelException` - if this root could not be moved. Reasons include:
    - This root does not exist (ELEMENT_DOES_NOT_EXIST)
    - A `CoreException` occurred while copying the resource or updating a classpath
    - The destination is not inside an existing project and `updateModelFlags` has been specified as `DESTINATION_PROJECT_CLASSPATH` (INVALID_DESTINATION)
    - The sibling is not a classpath entry on the destination project's raw classpath (INVALID_SIBLING)
    - The same classpath entry already exists on the destination project's classpath (NAME_COLLISION) and `updateModelFlags` has not been specified as `REPLACE`
  Since:
    2.1
  See Also:
    `IResource.move(IPath, boolean, IProgressMonitor)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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