Class PackageFragmentRoot
- All Implemented Interfaces:
IBufferChangedListener, IJavaElement, IOpenable, IPackageFragmentRoot, IParent, org.eclipse.core.runtime.IAdaptable
- Direct Known Subclasses:
ExternalPackageFragmentRoot, JarPackageFragmentRoot
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final charThe delimiter between the source path and root path in the attachment server property.static final Stringprotected org.eclipse.core.resources.IResourceThe resource associated with this root (null for external jar)Fields inherited from class JavaElement
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_DELIMITER_ESCAPE, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LAMBDA_EXPRESSION, JEM_LAMBDA_METHOD, JEM_LOCALVARIABLE, JEM_METHOD, JEM_MODULAR_CLASSFILE, JEM_MODULE, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_STRING, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, NO_STRINGSModifier and TypeFieldDescriptionstatic final charstatic final charstatic final charstatic final charstatic final charBefore ')','&'and '"' became the newest additions as delimiters, the former two were allowed as part of element attributes and possibly stored.static final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charprotected static final JavaElement[]protected static final Objectstatic final String[]Fields inherited from interface IJavaElement
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_MODULE, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETERModifier and TypeFieldDescriptionstatic final intConstant representing an annotation.static final intConstant representing a class file.static final intConstant representing a Java compilation unit.static final intConstant representing a field.static final intConstant representing all import declarations within a compilation unit.static final intConstant representing an import declaration within a compilation unit.static final intConstant representing a stand-alone instance or class initializer.static final intConstant representing a Java model (workspace level object).static final intConstant represents a module descriptor.static final intConstant representing a Java project.static final intConstant representing a local variable declaration.static final intConstant representing a method or constructor.static final intConstant representing a package declaration within a compilation unit.static final intConstant representing a package fragment.static final intConstant representing a package fragment root.static final intConstant representing a type (a class or interface).static final intConstant representing a type parameter declaration.Fields inherited from interface IPackageFragmentRoot
DEFAULT_PACKAGEROOT_PATH, DESTINATION_PROJECT_CLASSPATH, K_BINARY, K_SOURCE, NO_RESOURCE_MODIFICATION, ORIGINATING_PROJECT_CLASSPATH, OTHER_REFERRING_PROJECTS_CLASSPATH, REPLACEModifier and TypeFieldDescriptionstatic final StringEmpty root pathstatic final intUpdate model flag constant (bit mask value 8) indicating that the operation is to update the classpath of the destination project.static final intKind constant for a binary path root.static final intKind constant for a source path root.static final intUpdate model flag constant (bit mask value 1) indicating that the operation is to not copy/move/delete the package fragment root resource.static final intUpdate model flag constant (bit mask value 2) indicating that the operation is to update the classpath of the originating project.static final intUpdate 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 final intUpdate model flag constant (bit mask value 16) indicating that the operation is to replace the resource and the destination project's classpath entry. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPackageFragmentRoot(org.eclipse.core.resources.IResource resource, JavaProject project) Constructs a package fragment root which is the root of the java package directory hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionvoidattachSource(org.eclipse.core.runtime.IPath sourcePath, org.eclipse.core.runtime.IPath rootPath, org.eclipse.core.runtime.IProgressMonitor monitor) Attaches the source archive identified by the given absolute path to this binary package fragment root.protected booleanbuildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) Builds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer).protected intprotected booleancomputeChildren(OpenableElementInfo info, org.eclipse.core.resources.IResource underlyingResource) Compute the package fragment children of this package fragment root.protected voidcomputeFolderChildren(org.eclipse.core.resources.IContainer folder, boolean isIncluded, String[] pkgName, ArrayList vChildren, char[][] inclusionPatterns, char[][] exclusionPatterns) Starting at this folder, create package fragments and add the fragments that are not excluded to the collection of children.voidcopy(org.eclipse.core.runtime.IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, org.eclipse.core.runtime.IProgressMonitor monitor) Copies the resource of this package fragment root to the destination path as specified byIResource.copy(IPath, int, IProgressMonitor)but excluding nested source folders.protected org.aspectj.org.eclipse.jdt.internal.core.PackageFragmentRootInfoReturns a new element info for this element.createPackageFragment(String pkgName, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Creates and returns a package fragment in this root with the given dot-separated package name.voiddelete(int updateResourceFlags, int updateModelFlags, org.eclipse.core.runtime.IProgressMonitor monitor) Deletes the resource of this package fragment root as specified byIResource.delete(int, IProgressMonitor)but excluding nested source folders.protected intdetermineKind(org.eclipse.core.resources.IResource underlyingResource) Returns the root's kind - K_SOURCE or K_BINARY, defaults to K_SOURCE if it is not on the classpath.booleanCompares two objects for equality; forPackageFragmentRoots, equality is having the same parent, same resources, and occurrence count.char[][]char[][]getClassFilePath(String classname) Returns the relative path within an archive for the given class file name.Returns the name of this element.intReturns this element's kind encoded as an integer.getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) protected voidprotected charReturns thecharthat marks the start of this handles contribution to a memento.intgetKind()Returns this package fragment root's kind encoded as an integer.Convenience lookup, though currently only JarPackageFragmentRoot is searched for a manifest.Returns theIModuleDescriptionthat this package fragment root contains.Object[]Returns an array of non-java resources contained in the receiver.getPackageFragment(String packageName) Returns the package fragment with the given package name.getPackageFragment(String[] pkgName) getPackageFragment(String[] pkgName, String mod) protected StringgetPackageName(org.eclipse.core.resources.IFolder folder) Returns the package name for the given folder (which is a decendent of this root).org.eclipse.core.runtime.IPathgetPath()Returns the path to the innermost resource enclosing this element.Returns the first raw classpath entry that corresponds to this package fragment root.Returns the first resolved classpath entry that corresponds to this package fragment root.org.eclipse.core.runtime.IPathReturns the absolute path to the source archive attached to this package fragment root's binary archive.org.eclipse.core.runtime.IPathReturns the path within this package fragment root's source archive.Returns the SourceMapper facility for this element, ornullif this element does not have a SourceMapper.org.eclipse.core.resources.IResourceReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.booleanReturns whether this element has one or more immediate children.booleanhasCompilationUnit(String qualifiedPackageName, String moduleName) booleanorg.eclipse.core.runtime.IPathbooleanReturns whether this package fragment root's underlying resource is a binary archive (a JAR or zip file).protected booleanbooleanReturns whether this package fragment root is external to the workbench (that is, a local file), and has no underlying resource.voidmove(org.eclipse.core.runtime.IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, org.eclipse.core.runtime.IProgressMonitor monitor) Moves the resource of this package fragment root to the destination path as specified byIResource.move(IPath,int,IProgressMonitor)but excluding nested source folders.org.eclipse.core.resources.IResourceresource()org.eclipse.core.resources.IResourceresource(PackageFragmentRoot root) voidsetSourceMapper(SourceMapper mapper) For use byAttachSourceOperationonly.protected voidtoStringInfo(int tab, StringBuilder buffer, Object info, boolean showResolvedInfo) for debugging onlyprotected org.eclipse.core.runtime.IStatusvalidateExistence(org.eclipse.core.resources.IResource underlyingResource) protected org.eclipse.core.runtime.IStatusprotected voidverifyAttachSource(org.eclipse.core.runtime.IPath sourcePath) Possible failures: ELEMENT_NOT_PRESENT - the root supplied to the operation does not exist INVALID_ELEMENT_TYPES - the root is not of kind K_BINARY RELATIVE_PATH - the path supplied to this operation must be an absolute pathMethods inherited from class Openable
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, closeBuffer, closing, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBuffer, getBufferFactory, getBufferManager, getCorrespondingResource, getOpenable, getPackageFragmentRoot, getResource, hasBuffer, hasUnsavedChanges, ignoreErrorStatus, isConsistent, isOpen, isSourceElement, isStructureKnown, makeConsistent, open, openAncestors, openBuffer, resourceExists, saveModifier and TypeMethodDescriptionvoidbufferChanged(BufferChangedEvent event) The buffer associated with this element has changed.booleanbooleancanBufferBeRemovedFromCache(IBuffer buffer) protected voidClose the buffer associated with this element, if any.protected voidThis element is being closed.protected voidcodeComplete(ICompilationUnit cu, ICompilationUnit unitToSkip, int position, CompletionRequestor requestor, WorkingCopyOwner owner, ITypeRoot typeRoot, org.eclipse.core.runtime.IProgressMonitor monitor) protected IJavaElement[]codeSelect(ICompilationUnit cu, int offset, int length, WorkingCopyOwner owner) booleanexists()Returns whether this Java element exists in the model.Finds and returns the recommended line separator for this element.protected voidgenerateInfos(IElementInfo info, Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable).Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time.Deprecated.protected BufferManagerReturns the buffer manager for this element.org.eclipse.core.resources.IResourceReturn my underlying resource.Returns the first openable parent.Find enclosing package fragment root if anyorg.eclipse.core.resources.IResourceReturns the innermost resource enclosing this element.protected booleanReturns true if this element may have an associated source buffer, otherwise false.booleanReturnstrueif this element is open and: its buffer has unsaved changes, or one of its descendants has unsaved changes, or a working copy has been created on one of this element's children and has not yet destroyedprotected booleanignoreErrorStatus(org.eclipse.core.runtime.IStatus status) booleanSubclasses must override as required.booleanisOpen()Returns whether this openable is open.protected booleanReturns true if this represents a source element.booleanReturns whether the structure of this element is known.voidmakeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor) Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary.voidopen(org.eclipse.core.runtime.IProgressMonitor pm) Opens this element and all parent elements that are not already open.protected voidopenAncestors(Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) protected IBufferopenBuffer(org.eclipse.core.runtime.IProgressMonitor pm, IElementInfo info) Opens a buffer on the contents of this element, and returns the buffer, or returnsnullif opening fails.protected booleanresourceExists(org.eclipse.core.resources.IResource underlyingResource) Returns whether the corresponding resource or associated file existsvoidsave(org.eclipse.core.runtime.IProgressMonitor pm, boolean force) Saves any changes in this element's buffer to its underlying resource via a workspace resource operation.Methods inherited from class JavaElement
appendEscapedDelimiter, close, escapeMementoName, findNode, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getCompilationUnit, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavadocBaseLocation, getJavaModel, getJavaProject, getLibraryJavadocLocation, getOpenableParent, getParent, getPrimaryElement, getPrimaryElement, getSchedulingRule, getSourceElementAt, getURLContents, hashCode, isAncestorOf, isReadOnly, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resetHashCode, resolved, tabString, toDebugString, toString, toString, toStringAncestors, toStringChildren, toStringInfo, toStringName, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheModifier and TypeMethodDescriptionprotected voidappendEscapedDelimiter(StringBuilder buffer, char delimiter) voidclose()protected voidescapeMementoName(StringBuilder buffer, String mementoName) findNode(CompilationUnit ast) Returns theASTNodethat corresponds to thisJavaElementornullif there is no corresponding node.getAncestor(int ancestorType) Returns this Java element or the first ancestor of this element that has the given type.getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the Javadoc as HTML source if this element has attached Javadoc,nullotherwise.getChildrenOfType(int type) Returns a collection of (immediate) children of this node of the specified type.Returns the info for this handle.getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the info for this handle.getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) Returns a string representation of this element handle.protected URLReturns the Java model.Returns the Java project this element is contained in, ornullif this element is not contained in any Java project (for instance, theIJavaModelis not contained in any Java project).protected static URLReturn the first instance of IOpenable in the parent hierarchy of this element.Returns the element directly containing this element, ornullif this element has no parent.Returns the primary element (whose compilation unit is the primary compilation unit) this working copy element was created from, or this element if it is a descendant of a primary compilation unit or if it is not a descendant of a working copy (e.g.getPrimaryElement(boolean checkOwner) org.eclipse.core.runtime.jobs.ISchedulingRuleReturns the scheduling rule associated with this Java element.protected IJavaElementgetSourceElementAt(int position) Returns the element that is located at the given source position in this element.protected StringgetURLContents(URL baseLoc, String docUrlValue) final inthashCode()Returns the hash code for this Java element.booleanReturns true if this element is an ancestor of the given element, otherwise false.booleanReturns whether this Java element is read-only.protected JavaModelStatusnewJavaModelException(org.eclipse.core.runtime.IStatus status) Creates and returns a new Java model exception for this element with the given status.Creates and returns a new not present exception for this element.protected IElementInfoopenWhenClosed(IElementInfo info, boolean forceAdd, org.eclipse.core.runtime.IProgressMonitor monitor) protected voidshould not be needed but some implementations do have mutable member "occurrenceCount"protected StringtabString(int tab) Debugging purposestoString()Debugging purposesprotected voidtoString(int tab, StringBuilder buffer) Debugging purposesprotected voidtoStringAncestors(StringBuilder buffer) Debugging purposesprotected voidtoStringChildren(int tab, StringBuilder buffer, Object info) Debugging purposestoStringInfo(int tab, StringBuilder buffer) Debugging purposesprotected voidtoStringName(StringBuilder buffer) Debugging purposesDebugging purposestoStringWithAncestors(boolean showResolvedInfo) Debugging purposesprotected voidvalidateAndCache(URL baseLoc, FileNotFoundException e) Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from interface IParent
getChildrenModifier and TypeMethodDescriptionReturns the immediate children of this element.
-
Field Details
-
ATTACHMENT_PROPERTY_DELIMITER
protected static final char ATTACHMENT_PROPERTY_DELIMITERThe delimiter between the source path and root path in the attachment server property.- See Also:
-
NO_SOURCE_ATTACHMENT
- See Also:
-
resource
protected org.eclipse.core.resources.IResource resourceThe resource associated with this root (null for external jar)
-
-
Constructor Details
-
PackageFragmentRoot
Constructs a package fragment root which is the root of the java package directory hierarchy.
-
-
Method Details
-
attachSource
public void attachSource(org.eclipse.core.runtime.IPath sourcePath, org.eclipse.core.runtime.IPath rootPath, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IPackageFragmentRootAttaches the source archive identified by the given absolute path to this binary package fragment root.rootPathspecifies the location of the root within the archive or folder (empty specifies the default root andnullspecifies the root path should be detected). Once a source archive or folder is attached to the package fragment root, thegetSourceandgetSourceRangemethods become operational for binary types/members. To detach a source archive or folder from a package fragment root, specifynullas the source path.- Specified by:
attachSourcein interfaceIPackageFragmentRoot- Parameters:
sourcePath- the given absolute path to the source archive or folderrootPath- specifies the location of the root within the archive (empty specifies the default root andnullspecifies 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
CoreExceptionoccurred 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)
- See Also:
-
buildStructure
protected boolean buildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException Description copied from class:OpenableBuilds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer). Children are placed in the given newElements table (note, this element has already been placed in the newElements table). Returns true if successful, or false if an error is encountered while determining the structure of this element.- Specified by:
buildStructurein classOpenable- Throws:
JavaModelException- See Also:
-
delete
public void delete(int updateResourceFlags, int updateModelFlags, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IPackageFragmentRootDeletes the resource of this package fragment root as specified byIResource.delete(int, IProgressMonitor)but excluding nested source folders.If
NO_RESOURCE_MODIFICATIONis specified inupdateModelFlagsor if this package fragment root is external, this operation doesn't delete the resource.updateResourceFlagsis then ignored.If
ORIGINATING_PROJECT_CLASSPATHis specified inupdateModelFlags, update the raw classpath of this package fragment root's project by removing the corresponding classpath entry.If
OTHER_REFERRING_PROJECTS_CLASSPATHis specified inupdateModelFlags, 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(usingIResource.NONE), the default behavior applies: the resource is deleted (if this package fragment root is not external) and no classpaths are updated.- Specified by:
deletein interfaceIPackageFragmentRoot- Parameters:
updateResourceFlags- bit-wise or of update resource flag constants (IResource.FORCEandIResource.KEEP_HISTORY)updateModelFlags- bit-wise or of update resource flag constants (ORIGINATING_PROJECT_CLASSPATH,OTHER_REFERRING_PROJECTS_CLASSPATHandNO_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
CoreExceptionoccurred while deleting the resource or updating a classpath
- See Also:
-
computeChildren
protected boolean computeChildren(OpenableElementInfo info, org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException Compute the package fragment children of this package fragment root.- Throws:
JavaModelException- The resource associated with this package fragment root does not exist
-
computeFolderChildren
protected void computeFolderChildren(org.eclipse.core.resources.IContainer folder, boolean isIncluded, String[] pkgName, ArrayList vChildren, char[][] inclusionPatterns, char[][] exclusionPatterns) throws JavaModelException Starting at this folder, create package fragments and add the fragments that are not excluded to the collection of children.- Throws:
JavaModelException- The resource associated with this package fragment does not exist
-
copy
public void copy(org.eclipse.core.runtime.IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IPackageFragmentRootCopies the resource of this package fragment root to the destination path as specified byIResource.copy(IPath, int, IProgressMonitor)but excluding nested source folders.If
NO_RESOURCE_MODIFICATIONis specified inupdateModelFlagsor if this package fragment root is external, this operation doesn't copy the resource.updateResourceFlagsis then ignored.If
DESTINATION_PROJECT_CLASSPATHis specified inupdateModelFlags, updates the classpath of the destination's project (if it is a Java project). If a non-nullsibling is specified, a copy of this root's classpath entry is inserted before the sibling on the destination project's raw classpath. Ifnullis specified, the classpath entry is added at the end of the raw classpath.If
REPLACEis specified inupdateModelFlags, 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(usingIResource.NONE), the default behavior applies: the resource is copied (if this package fragment root is not external) and the classpath is not updated.- Specified by:
copyin interfaceIPackageFragmentRoot- Parameters:
destination- the destination pathupdateResourceFlags- bit-wise or of update resource flag constants (IResource.FORCEandIResource.SHALLOW)updateModelFlags- bit-wise or of update resource flag constants (DESTINATION_PROJECT_CLASSPATHandNO_RESOURCE_MODIFICATION)sibling- the classpath entry before which a copy of the classpath entry should be inserted ornullif the classpath entry should be inserted at the endmonitor- a progress monitor- Throws:
JavaModelException- if this root could not be copied. Reasons include:- This root does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while copying the resource or updating a classpath -
The destination is not inside an existing project and
updateModelFlagshas been specified asDESTINATION_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
updateModelFlagshas not been specified asREPLACE
- See Also:
-
createElementInfo
protected org.aspectj.org.eclipse.jdt.internal.core.PackageFragmentRootInfo createElementInfo()Returns a new element info for this element.- Overrides:
createElementInfoin classOpenable
-
createPackageFragment
public IPackageFragment createPackageFragment(String pkgName, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IPackageFragmentRootCreates 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 theforceflag, seeIFolder.create.- Specified by:
createPackageFragmentin interfaceIPackageFragmentRoot- Parameters:
pkgName- the given dot-separated package nameforce- a flag controlling how to deal with resources that are not in sync with the local file systemmonitor- 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
CoreExceptionoccurred 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:
-
determineKind
protected int determineKind(org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException Returns the root's kind - K_SOURCE or K_BINARY, defaults to K_SOURCE if it is not on the classpath.- Throws:
JavaModelException- if the project and root do not exist.
-
equals
Compares two objects for equality; forPackageFragmentRoots, equality is having the same parent, same resources, and occurrence count.- Overrides:
equalsin classJavaElement- See Also:
-
calculateHashCode
protected int calculateHashCode()- Overrides:
calculateHashCodein classJavaElement
-
fullExclusionPatternChars
public char[][] fullExclusionPatternChars() -
fullInclusionPatternChars
public char[][] fullInclusionPatternChars() -
getElementName
Description copied from interface:IJavaElementReturns the name of this element. This is a handle-only method.- Specified by:
getElementNamein interfaceIJavaElement- Overrides:
getElementNamein classJavaElement- Returns:
- the element name
- See Also:
-
getElementType
public int getElementType()Description copied from interface:IJavaElementReturns this element's kind encoded as an integer. This is a handle-only method.- Specified by:
getElementTypein interfaceIJavaElement- Returns:
- the kind of element; one of the constants declared in
IJavaElement - See Also:
-
getHandleMementoDelimiter
protected char getHandleMementoDelimiter()Description copied from class:JavaElementReturns thecharthat marks the start of this handles contribution to a memento.- Specified by:
getHandleMementoDelimiterin classJavaElement- See Also:
-
getHandleFromMemento
public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) - Specified by:
getHandleFromMementoin classJavaElement
-
getHandleMemento
- Overrides:
getHandleMementoin classJavaElement- See Also:
-
getKind
Description copied from interface:IPackageFragmentRootReturns this package fragment root's kind encoded as an integer. A package fragment root can contain source files (i.e. files with one of theJava-like extensions, or.classfiles, but not both. If the underlying folder or archive contains other kinds of files, they are ignored. In particular,.classfiles are ignored under a source package fragment root, and source files are ignored under a binary package fragment root.- Specified by:
getKindin interfaceIPackageFragmentRoot- 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:
-
getNonJavaResources
Returns an array of non-java resources contained in the receiver.- Specified by:
getNonJavaResourcesin interfaceIPackageFragmentRoot- Returns:
- an array of non-Java resources (
IFiles,IFolders, orIStorages 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:
-
getPackageFragment
Description copied from interface:IPackageFragmentRootReturns 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.- Specified by:
getPackageFragmentin interfaceIPackageFragmentRoot- Parameters:
packageName- the given package name- Returns:
- the package fragment with the given package name
- See Also:
-
getPackageFragment
-
getPackageFragment
-
getPackageName
Returns the package name for the given folder (which is a decendent of this root). -
getPath
public org.eclipse.core.runtime.IPath getPath()Description copied from interface:IJavaElementReturns the path to the innermost resource enclosing this element. If this element is not included in an external library, the path returned is the full, absolute path to the underlying resource, relative to the workbench. If this element is included in an external library, the path returned is the absolute path to the archive or to the folder in the file system. This is a handle-only method.- Specified by:
getPathin interfaceIJavaElement- Returns:
- the path to the innermost resource enclosing this element
- See Also:
-
internalPath
public org.eclipse.core.runtime.IPath internalPath() -
getRawClasspathEntry
Description copied from interface:IPackageFragmentRootReturns 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.- Specified by:
getRawClasspathEntryin interfaceIPackageFragmentRoot- 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.
-
getResolvedClasspathEntry
Description copied from interface:IPackageFragmentRootReturns the first resolved classpath entry that corresponds to this package fragment root. A resolved classpath entry is said to correspond to a root if the path of the resolved entry is equal to the root's path.- Specified by:
getResolvedClasspathEntryin interfaceIPackageFragmentRoot- Returns:
- the first resolved 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.
-
resource
-
resource
-
getSourceAttachmentPath
Description copied from interface:IPackageFragmentRootReturns the absolute path to the source archive attached to this package fragment root's binary archive.- Specified by:
getSourceAttachmentPathin interfaceIPackageFragmentRoot- Returns:
- the absolute path to the corresponding source archive,
or
nullif 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- See Also:
-
setSourceMapper
For use byAttachSourceOperationonly. Sets the source mapper associated with this root.- Throws:
JavaModelException
-
getSourceAttachmentRootPath
Description copied from interface:IPackageFragmentRootReturns 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.- Specified by:
getSourceAttachmentRootPathin interfaceIPackageFragmentRoot- Returns:
- the path within the corresponding source archive,
or
nullif 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- See Also:
-
getSourceMapper
Description copied from class:JavaElementReturns the SourceMapper facility for this element, ornullif this element does not have a SourceMapper.- Overrides:
getSourceMapperin classJavaElement- See Also:
-
getUnderlyingResource
Description copied from interface:IJavaElementReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.- Specified by:
getUnderlyingResourcein interfaceIJavaElement- Overrides:
getUnderlyingResourcein classOpenable- Returns:
- the underlying resource, or
nullif none - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its underlying resource- See Also:
-
hasChildren
Description copied from interface:IParentReturns whether this element has one or more immediate children. This is a convenience method, and may be more efficient than testing whethergetChildrenis an empty array.- Specified by:
hasChildrenin interfaceIParent- Overrides:
hasChildrenin classJavaElement- Returns:
- true if the immediate children of this element, false otherwise
- Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource- See Also:
-
ignoreOptionalProblems
public boolean ignoreOptionalProblems() -
isArchive
public boolean isArchive()Description copied from interface:IPackageFragmentRootReturns whether this package fragment root's underlying resource is a binary archive (a JAR or zip file).This is a handle-only method.
- Specified by:
isArchivein interfaceIPackageFragmentRoot- Returns:
- true if this package fragment root's underlying resource is a binary archive, false otherwise
- See Also:
-
isExternal
public boolean isExternal()Description copied from interface:IPackageFragmentRootReturns 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.
- Specified by:
isExternalin interfaceIPackageFragmentRoot- Returns:
- true if this package fragment root is external to the workbench (that is, a local file), and has no underlying resource, false otherwise
- See Also:
-
validateOnClasspath
protected org.eclipse.core.runtime.IStatus validateOnClasspath() -
move
public void move(org.eclipse.core.runtime.IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IPackageFragmentRootMoves the resource of this package fragment root to the destination path as specified byIResource.move(IPath,int,IProgressMonitor)but excluding nested source folders.If
NO_RESOURCE_MODIFICATIONis specified inupdateModelFlagsor if this package fragment root is external, this operation doesn't move the resource.updateResourceFlagsis then ignored.If
DESTINATION_PROJECT_CLASSPATHis specified inupdateModelFlags, updates the classpath of the destination's project (if it is a Java project). If a non-nullsibling is specified, a copy of this root's classpath entry is inserted before the sibling on the destination project's raw classpath. Ifnullis specified, the classpath entry is added at the end of the raw classpath.If
ORIGINATING_PROJECT_CLASSPATHis specified inupdateModelFlags, update the raw classpath of this package fragment root's project by removing the corresponding classpath entry.If
OTHER_REFERRING_PROJECTS_CLASSPATHis specified inupdateModelFlags, update the raw classpaths of all other Java projects referring to this root's resource by removing the corresponding classpath entries.If
REPLACEis specified inupdateModelFlags, 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(usingIResource.NONE), the default behavior applies: the resource is moved (if this package fragment root is not external) and no classpaths are updated.- Specified by:
movein interfaceIPackageFragmentRoot- Parameters:
destination- the destination pathupdateResourceFlags- bit-wise or of update flag constants (IResource.FORCE,IResource.KEEP_HISTORYandIResource.SHALLOW)updateModelFlags- bit-wise or of update resource flag constants (DESTINATION_PROJECT_CLASSPATH,ORIGINATING_PROJECT_CLASSPATH,OTHER_REFERRING_PROJECTS_CLASSPATHandNO_RESOURCE_MODIFICATION)sibling- the classpath entry before which a copy of the classpath entry should be inserted ornullif the classpath entry should be inserted at the endmonitor- a progress monitor- Throws:
JavaModelException- if this root could not be moved. Reasons include:- This root does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while copying the resource or updating a classpath -
The destination is not inside an existing project and
updateModelFlagshas been specified asDESTINATION_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
updateModelFlagshas not been specified asREPLACE
- See Also:
-
toStringInfo
for debugging only- Overrides:
toStringInfoin classJavaElement- Parameters:
showResolvedInfo- TODO
-
validateExistence
protected org.eclipse.core.runtime.IStatus validateExistence(org.eclipse.core.resources.IResource underlyingResource) - Specified by:
validateExistencein classOpenable
-
verifyAttachSource
protected void verifyAttachSource(org.eclipse.core.runtime.IPath sourcePath) throws JavaModelException Possible failures:- ELEMENT_NOT_PRESENT - the root supplied to the operation does not exist
- INVALID_ELEMENT_TYPES - the root is not of kind K_BINARY
- RELATIVE_PATH - the path supplied to this operation must be an absolute path
- Throws:
JavaModelException
-
getClassFilePath
Returns the relative path within an archive for the given class file name. In certain kind of archives, such as a JMOD file, class files are stored in a nested folder, as opposed to directly under the root. It is the responsibility of such package fragment roots to provide the custom behavior.- Returns:
- the relative path for the class file within the archive
-
getModuleDescription
Description copied from interface:IPackageFragmentRootReturns theIModuleDescriptionthat this package fragment root contains. Returnsnullif the root doesn't contain any named module or if the project compiler compliance is 1.8 or lower. If present the module descriptor is found as a child of the package fragment representing the default package. Note that only one of the source package fragment roots in a Java Project can legally contain a module descriptor.- Specified by:
getModuleDescriptionin interfaceIPackageFragmentRoot- Returns:
- the
IModuleDescriptionthis root contains.
-
getAutomaticModuleDescription
- Throws:
JavaModelException
-
hasCompilationUnit
-
getManifest
Convenience lookup, though currently only JarPackageFragmentRoot is searched for a manifest. -
isComplianceJava9OrHigher
protected boolean isComplianceJava9OrHigher()
-