public class JarPackageFragmentRoot extends PackageFragmentRoot
NOTE: The only visible entries from a .jar or .zip package fragment root are .class files.
NOTE: A jar package fragment root may or may not have an associated resource.
IPackageFragmentRoot,
JarPackageFragmentRootInfo| Modifier and Type | Field and Description |
|---|---|
protected static java.util.ArrayList |
EMPTY_LIST |
protected IClasspathAttribute[] |
extraAttributes
Reflects the extra attributes of the classpath entry declaring this root.
|
protected IPath |
jarPath
The path to the jar file
(a workspace relative path if the jar is internal,
or an OS path if the jar is external)
|
ATTACHMENT_PROPERTY_DELIMITER, NO_SOURCE_ATTACHMENT, resourceJEM_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_STRINGS, parentDEFAULT_PACKAGEROOT_PATH, DESTINATION_PROJECT_CLASSPATH, K_BINARY, K_SOURCE, NO_RESOURCE_MODIFICATION, ORIGINATING_PROJECT_CLASSPATH, OTHER_REFERRING_PROJECTS_CLASSPATH, REPLACEANNOTATION, 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_PARAMETER| Constructor and Description |
|---|
JarPackageFragmentRoot(IResource resource,
IPath externalJarPath,
JavaProject project,
IClasspathAttribute[] attributes)
Constructs a package fragment root which is the root of the Java package directory hierarchy
based on a JAR file.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
computeChildren(OpenableElementInfo info,
IResource underlyingResource)
Compute the package fragment children of this package fragment root.
|
protected IJavaElement[] |
createChildren(HashtableOfArrayToObject rawPackageInfo) |
protected java.lang.Object |
createElementInfo()
Returns a new element info for this element.
|
protected int |
determineKind(IResource underlyingResource)
A Jar is always K_BINARY.
|
boolean |
equals(java.lang.Object o)
Returns true if this handle represents the same jar
as the given handle.
|
java.lang.String |
getClassFilePath(java.lang.String classname)
Returns the relative path within an archive for the given class file name.
|
java.lang.String |
getElementName()
Returns the name of this element.
|
java.net.URL |
getIndexPath() |
java.util.zip.ZipFile |
getJar()
Returns the underlying ZipFile for this Jar package fragment root.
|
int |
getKind()
Returns this package fragment root's kind encoded as an integer.
|
java.util.jar.Manifest |
getManifest()
Convenience lookup, though currently only JarPackageFragmentRoot is searched for a manifest.
|
IModuleDescription |
getModuleDescription()
Returns the
IModuleDescription that this package fragment root contains. |
java.lang.Object[] |
getNonJavaResources()
Returns an array of non-java resources contained in the receiver.
|
PackageFragment |
getPackageFragment(java.lang.String[] pkgName) |
PackageFragment |
getPackageFragment(java.lang.String[] pkgName,
java.lang.String mod) |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains
this element, or
null if this element is not contained
in a resource. |
int |
hashCode()
Returns the hash code for this Java element.
|
protected void |
initRawPackageInfo(HashtableOfArrayToObject rawPackageInfo,
java.lang.String entryName,
boolean isDirectory,
java.lang.String compliance) |
IPath |
internalPath() |
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.
|
boolean |
isReadOnly()
Jars and jar entries are all read only
|
IResource |
resource(PackageFragmentRoot root) |
protected boolean |
resourceExists(IResource underlyingResource)
Returns whether the corresponding resource or associated file exists
|
protected void |
toStringAncestors(java.lang.StringBuffer buffer)
Debugging purposes
|
attachSource, buildStructure, computeFolderChildren, copy, createPackageFragment, delete, fullExclusionPatternChars, fullInclusionPatternChars, getAutomaticModuleDescription, getElementType, getHandleFromMemento, getHandleMemento, getHandleMementoDelimiter, getPackageFragment, getPackageName, getPath, getRawClasspathEntry, getResolvedClasspathEntry, getSourceAttachmentPath, getSourceAttachmentRootPath, getSourceMapper, hasChildren, hasCompilationUnit, ignoreOptionalProblems, isComplianceJava9OrHigher, move, resource, setSourceMapper, toStringInfo, validateExistence, validateOnClasspath, verifyAttachSourcebufferChanged, 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, saveappendEscapedDelimiter, 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, isAncestorOf, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resolved, tabString, toDebugString, toString, toString, toStringChildren, toStringInfo, toStringName, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetChildrenexists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, isStructureKnownclose, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, saveprotected static final java.util.ArrayList EMPTY_LIST
protected final IPath jarPath
protected final IClasspathAttribute[] extraAttributes
public JarPackageFragmentRoot(IResource resource,
IPath externalJarPath,
JavaProject project,
IClasspathAttribute[] attributes)
protected boolean computeChildren(OpenableElementInfo info, IResource underlyingResource) throws JavaModelException
computeChildren in class PackageFragmentRootJavaModelException - The resource associated with this package fragment root does not existprotected IJavaElement[] createChildren(HashtableOfArrayToObject rawPackageInfo)
protected java.lang.Object createElementInfo()
createElementInfo in class PackageFragmentRootprotected int determineKind(IResource underlyingResource)
determineKind in class PackageFragmentRootpublic boolean equals(java.lang.Object o)
equals in class PackageFragmentRootObject.equals(java.lang.Object)public java.lang.String getElementName()
IJavaElementgetElementName in interface IJavaElementgetElementName in class PackageFragmentRootIAdaptablepublic java.util.zip.ZipFile getJar()
throws CoreException
CoreException - if an error occurs accessing the jarpublic int getKind()
IPackageFragmentRootJava-like extensions,
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 source files are ignored under a binary package fragment root.getKind in interface IPackageFragmentRootgetKind in class PackageFragmentRootIPackageFragmentRootpublic java.lang.Object[] getNonJavaResources()
throws JavaModelException
getNonJavaResources in interface IPackageFragmentRootgetNonJavaResources in class PackageFragmentRootIFiles,
IFolders, or IStorages if the
package fragment root is in archive) contained in this package
fragment rootJavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resource.IClasspathEntry.getInclusionPatterns(),
IClasspathEntry.getExclusionPatterns()public PackageFragment getPackageFragment(java.lang.String[] pkgName)
getPackageFragment in class PackageFragmentRootpublic PackageFragment getPackageFragment(java.lang.String[] pkgName, java.lang.String mod)
getPackageFragment in class PackageFragmentRootpublic java.lang.String getClassFilePath(java.lang.String classname)
PackageFragmentRootgetClassFilePath in class PackageFragmentRootpublic IModuleDescription getModuleDescription()
IPackageFragmentRootIModuleDescription that this package fragment root contains.
Returns null if 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.getModuleDescription in interface IPackageFragmentRootgetModuleDescription in class PackageFragmentRootIModuleDescription this root contains.public IPath internalPath()
internalPath in class PackageFragmentRootpublic IResource resource(PackageFragmentRoot root)
resource in class PackageFragmentRootpublic IResource getUnderlyingResource()
throws JavaModelException
IJavaElementnull if this element is not contained
in a resource.getUnderlyingResource in interface IJavaElementgetUnderlyingResource in class PackageFragmentRootnull if noneJavaModelException - if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElementpublic int hashCode()
JavaElementhashCode in class PackageFragmentRootprotected void initRawPackageInfo(HashtableOfArrayToObject rawPackageInfo, java.lang.String entryName, boolean isDirectory, java.lang.String compliance)
public boolean isArchive()
IPackageFragmentRootThis is a handle-only method.
isArchive in interface IPackageFragmentRootisArchive in class PackageFragmentRootIPackageFragmentRootpublic boolean isExternal()
IPackageFragmentRootThis is a handle-only method.
isExternal in interface IPackageFragmentRootisExternal in class PackageFragmentRootIPackageFragmentRootpublic boolean isReadOnly()
isReadOnly in interface IJavaElementisReadOnly in class JavaElementtrue if this element is read-onlyIJavaElementprotected boolean resourceExists(IResource underlyingResource)
resourceExists in class Openableprotected void toStringAncestors(java.lang.StringBuffer buffer)
JavaElementtoStringAncestors in class JavaElementpublic java.net.URL getIndexPath()
public java.util.jar.Manifest getManifest()
PackageFragmentRootgetManifest in class PackageFragmentRoot