org.aspectj.org.eclipse.jdt.internal.core
Class JarPackageFragmentRoot

java.lang.Object
  extended by PlatformObject
      extended by org.aspectj.org.eclipse.jdt.internal.core.JavaElement
          extended by org.aspectj.org.eclipse.jdt.internal.core.Openable
              extended by org.aspectj.org.eclipse.jdt.internal.core.PackageFragmentRoot
                  extended by org.aspectj.org.eclipse.jdt.internal.core.JarPackageFragmentRoot
All Implemented Interfaces:
IBufferChangedListener, IJavaElement, IOpenable, IPackageFragmentRoot, IParent

public class JarPackageFragmentRoot
extends PackageFragmentRoot

A package fragment root that corresponds to a .jar or .zip.

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.

See Also:
IPackageFragmentRoot, JarPackageFragmentRootInfo

Field Summary
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)
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.PackageFragmentRoot
ATTACHMENT_PROPERTY_DELIMITER, NO_SOURCE_ATTACHMENT, resource
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaElement
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, parent
 
Fields inherited from interface org.aspectj.org.eclipse.jdt.core.IPackageFragmentRoot
DEFAULT_PACKAGEROOT_PATH, DESTINATION_PROJECT_CLASSPATH, K_BINARY, K_SOURCE, NO_RESOURCE_MODIFICATION, ORIGINATING_PROJECT_CLASSPATH, OTHER_REFERRING_PROJECTS_CLASSPATH, REPLACE
 
Fields inherited from interface org.aspectj.org.eclipse.jdt.core.IJavaElement
ANNOTATION, 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, TYPE_PARAMETER
 
Constructor Summary
protected JarPackageFragmentRoot(IPath externalJarPath, JavaProject project)
          Constructs a package fragment root which is the root of the Java package directory hierarchy based on a JAR file that is not contained in a IJavaProject and does not have an associated IResource.
protected JarPackageFragmentRoot(IResource resource, JavaProject project)
          Constructs a package fragment root which is the root of the Java package directory hierarchy based on a JAR file.
 
Method Summary
protected  boolean computeChildren(OpenableElementInfo info, IResource underlyingResource)
          Compute the package fragment children of this package fragment root.
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 getElementName()
          Returns the name of this element.
 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.lang.Object[] getNonJavaResources()
          Returns an array of non-java resources contained in the receiver.
 PackageFragment getPackageFragment(java.lang.String[] pkgName)
           
 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.
 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
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.PackageFragmentRoot
attachSource, buildStructure, computeFolderChildren, copy, createPackageFragment, delete, fullExclusionPatternChars, fullInclusionPatternChars, getElementType, getHandleFromMemento, getHandleMemento, getHandleMementoDelimiter, getPackageFragment, getPackageName, getPath, getRawClasspathEntry, getResolvedClasspathEntry, getSourceAttachmentPath, getSourceAttachmentRootPath, getSourceMapper, hasChildren, move, resource, setSourceMapper, toStringInfo, validateExistence, validateOnClasspath, verifyAttachSource
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.Openable
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, closeBuffer, closing, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBuffer, getBufferFactory, getBufferManager, getCorrespondingResource, getOpenable, getPackageFragmentRoot, getResource, hasBuffer, hasUnsavedChanges, isConsistent, isOpen, isSourceElement, isStructureKnown, makeConsistent, open, openAncestors, openBuffer, save
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaElement
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IParent
getChildren
 
Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IJavaElement
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, isStructureKnown
 
Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IOpenable
close, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save
 

Field Detail

jarPath

protected final 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)

Constructor Detail

JarPackageFragmentRoot

protected JarPackageFragmentRoot(IPath externalJarPath,
                                 JavaProject project)
Constructs a package fragment root which is the root of the Java package directory hierarchy based on a JAR file that is not contained in a IJavaProject and does not have an associated IResource.


JarPackageFragmentRoot

protected JarPackageFragmentRoot(IResource resource,
                                 JavaProject project)
Constructs a package fragment root which is the root of the Java package directory hierarchy based on a JAR file.

Method Detail

computeChildren

protected boolean computeChildren(OpenableElementInfo info,
                                  IResource underlyingResource)
                           throws JavaModelException
Compute the package fragment children of this package fragment root. These are all of the directory zip entries, and any directories implied by the path of class files contained in the jar of this package fragment root.

Overrides:
computeChildren in class PackageFragmentRoot
Throws:
JavaModelException - The resource associated with this package fragment root does not exist

createElementInfo

protected java.lang.Object createElementInfo()
Returns a new element info for this element.

Overrides:
createElementInfo in class PackageFragmentRoot

determineKind

protected int determineKind(IResource underlyingResource)
A Jar is always K_BINARY.

Overrides:
determineKind in class PackageFragmentRoot

equals

public boolean equals(java.lang.Object o)
Returns true if this handle represents the same jar as the given handle. Two jars are equal if they share the same zip file.

Overrides:
equals in class PackageFragmentRoot
See Also:
Object.equals(java.lang.Object)

getElementName

public java.lang.String getElementName()
Description copied from interface: IJavaElement
Returns the name of this element. This is a handle-only method.

Specified by:
getElementName in interface IJavaElement
Overrides:
getElementName in class PackageFragmentRoot
Returns:
the element name
See Also:
IAdaptable

getJar

public java.util.zip.ZipFile getJar()
                             throws CoreException
Returns the underlying ZipFile for this Jar package fragment root.

Throws:
CoreException - if an error occurs accessing the jar

getKind

public int getKind()
Description copied from interface: IPackageFragmentRoot
Returns this package fragment root's kind encoded as an integer. A package fragment root can contain source files (i.e. files with one of the Java-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.

Specified by:
getKind in interface IPackageFragmentRoot
Overrides:
getKind in class PackageFragmentRoot
Returns:
this package fragment root's kind encoded as an integer
See Also:
IPackageFragmentRoot

getNonJavaResources

public java.lang.Object[] getNonJavaResources()
                                       throws JavaModelException
Returns an array of non-java resources contained in the receiver.

Specified by:
getNonJavaResources in interface IPackageFragmentRoot
Overrides:
getNonJavaResources in class PackageFragmentRoot
Returns:
an array of non-Java resources (IFiles, IFolders, or IStorages 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 PackageFragment getPackageFragment(java.lang.String[] pkgName)
Overrides:
getPackageFragment in class PackageFragmentRoot

internalPath

public IPath internalPath()
Overrides:
internalPath in class PackageFragmentRoot

resource

public IResource resource(PackageFragmentRoot root)
Overrides:
resource in class PackageFragmentRoot

getUnderlyingResource

public IResource getUnderlyingResource()
                                throws JavaModelException
Description copied from interface: IJavaElement
Returns the smallest underlying resource that contains this element, or null if this element is not contained in a resource.

Specified by:
getUnderlyingResource in interface IJavaElement
Overrides:
getUnderlyingResource in class PackageFragmentRoot
Returns:
the underlying resource, or null if none
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its underlying resource
See Also:
IJavaElement

hashCode

public int hashCode()
Description copied from class: JavaElement
Returns the hash code for this Java element. By default, the hash code for an element is a combination of its name and parent's hash code. Elements with other requirements must override this method.

Overrides:
hashCode in class PackageFragmentRoot

isArchive

public boolean isArchive()
Description copied from interface: IPackageFragmentRoot
Returns 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:
isArchive in interface IPackageFragmentRoot
Overrides:
isArchive in class PackageFragmentRoot
Returns:
true if this package fragment root's underlying resource is a binary archive, false otherwise
See Also:
IPackageFragmentRoot

isExternal

public boolean isExternal()
Description copied from interface: IPackageFragmentRoot
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.

Specified by:
isExternal in interface IPackageFragmentRoot
Overrides:
isExternal in class PackageFragmentRoot
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:
IPackageFragmentRoot

isReadOnly

public boolean isReadOnly()
Jars and jar entries are all read only

Specified by:
isReadOnly in interface IJavaElement
Overrides:
isReadOnly in class JavaElement
Returns:
true if this element is read-only
See Also:
IJavaElement

resourceExists

protected boolean resourceExists(IResource underlyingResource)
Returns whether the corresponding resource or associated file exists

Overrides:
resourceExists in class Openable

toStringAncestors

protected void toStringAncestors(java.lang.StringBuffer buffer)
Description copied from class: JavaElement
Debugging purposes

Overrides:
toStringAncestors in class JavaElement