Klasse PackageFragment

java.lang.Object
org.eclipse.core.runtime.PlatformObject
Alle implementierten Schnittstellen:
IBufferChangedListener, IJavaElement, IOpenable, IPackageFragment, IParent, ISourceManipulation, SuffixConstants, org.eclipse.core.runtime.IAdaptable

public class PackageFragment extends Openable implements IPackageFragment, SuffixConstants
Siehe auch:
  • Felddetails

    • NO_CLASSFILES

      protected static final IClassFile[] NO_CLASSFILES
      Constant empty list of class files
    • NO_ORDINARY_CLASSFILES

      protected static final IOrdinaryClassFile[] NO_ORDINARY_CLASSFILES
    • NO_COMPILATION_UNITS

      protected static final ICompilationUnit[] NO_COMPILATION_UNITS
      Constant empty list of compilation units
    • names

      public String[] names
  • Konstruktordetails

  • Methodendetails

    • buildStructure

      protected boolean buildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException
      Beschreibung aus Klasse kopiert: Openable
      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). 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.
      Angegeben von:
      buildStructure in Klasse Openable
      Löst aus:
      JavaModelException
      Siehe auch:
    • containsJavaResources

      public boolean containsJavaResources() throws JavaModelException
      Returns true if this fragment contains at least one java resource. Returns false otherwise.
      Angegeben von:
      containsJavaResources in Schnittstelle IPackageFragment
      Gibt zurück:
      true if this fragment contains at least one Java resource, false otherwise
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
    • copy

      public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ISourceManipulation
      Copies this element to the given container.
      Angegeben von:
      copy in Schnittstelle ISourceManipulation
      Parameter:
      container - the container
      sibling - the sibling element before which the copy should be inserted, or null if the copy should be inserted as the last child of the container
      rename - the new name for the element, or null if the copy retains the name of this element
      force - true if any existing child in the container with the target name should be replaced, and false to throw an exception in the event of a name collision
      monitor - a progress monitor
      Löst aus:
      JavaModelException - if this element could not be copied. Reasons include:
      • This Java element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
      • A CoreException occurred while updating an underlying resource
      • The container is of an incompatible type (INVALID_DESTINATION)
      • The sibling is not a child of the given container (INVALID_SIBLING)
      • The new name is invalid (INVALID_NAME)
      • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
      • The container or this element is read-only (READ_ONLY)
      Siehe auch:
    • createCompilationUnit

      public ICompilationUnit createCompilationUnit(String cuName, String contents, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Creates and returns a compilation unit in this package fragment with the specified name and contents. No verification is performed on the contents.

      It is possible that a compilation unit with the same name already exists in this package fragment. The value of the force parameter affects the resolution of such a conflict:

      • true - in this case the compilation is created with the new contents
      • false - in this case a JavaModelException is thrown
      Angegeben von:
      createCompilationUnit in Schnittstelle IPackageFragment
      Parameter:
      cuName - the given name
      contents - the given contents
      force - specify how to handle conflict is the same name already exists
      monitor - the given progress monitor
      Gibt zurück:
      a compilation unit in this package fragment with the specified name and contents
      Löst aus:
      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
      • The name is not a valid compilation unit name (INVALID_NAME)
      • The contents are null (INVALID_CONTENTS)
      Siehe auch:
    • createElementInfo

      protected Object createElementInfo()
      Setzt außer Kraft:
      createElementInfo in Klasse Openable
      Siehe auch:
    • delete

      public void delete(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ISourceManipulation
      Deletes this element, forcing if specified and necessary.
      Angegeben von:
      delete in Schnittstelle ISourceManipulation
      Parameter:
      force - a flag controlling whether underlying resources that are not in sync with the local file system will be tolerated (same as the force flag in IResource operations).
      monitor - a progress monitor
      Löst aus:
      JavaModelException - if this element could not be deleted. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      • A CoreException occurred while updating an underlying resource (CORE_EXCEPTION)
      • This element is read-only (READ_ONLY)
      Siehe auch:
    • equals

      public boolean equals(Object o)
      Beschreibung aus Klasse kopiert: JavaElement
      Returns true if this handle represents the same Java element as the given handle. By default, two handles represent the same element if they are identical or if they represent the same type of element, have equal names, parents, and occurrence counts.

      If a subclass has other requirements for equality, this method must be overridden.

      Setzt außer Kraft:
      equals in Klasse JavaElement
      Siehe auch:
    • exists

      public boolean exists()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns whether this Java element exists in the model.

      Java elements are handle objects that may or may not be backed by an actual element. Java elements that are backed by an actual element are said to "exist", and this method returns true. For Java elements that are not working copies, it is always the case that if the element exists, then its parent also exists (provided it has one) and includes the element as one of its children. It is therefore possible to navigated to any existing Java element from the root of the Java model along a chain of existing Java elements. On the other hand, working copies are said to exist until they are destroyed (with IWorkingCopy.destroy). Unlike regular Java elements, a working copy never shows up among the children of its parent element (which may or may not exist).

      Angegeben von:
      exists in Schnittstelle IJavaElement
      Setzt außer Kraft:
      exists in Klasse Openable
      Gibt zurück:
      true if this element exists in the Java model, and false if this element does not exist
      Siehe auch:
    • getOrdinaryClassFile

      public IOrdinaryClassFile getOrdinaryClassFile(String classFileName)
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns the class file with the specified name in this package (for example, "Object.class"). The ".class" suffix is required. This is a handle-only method. The class file may or may not be present.

      This method is not applicable to the files "module-info.class" as introduced in Java 9. For those please use IPackageFragment.getModularClassFile().

      Angegeben von:
      getOrdinaryClassFile in Schnittstelle IPackageFragment
      Parameter:
      classFileName - the given name
      Gibt zurück:
      the class file with the specified name in this package
      Löst aus:
      IllegalArgumentException - if the name does not end with ".class" or if the name is "module-info.class".
      Siehe auch:
    • getClassFile

      public IClassFile getClassFile(String classFileName)
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns the class file with the specified name in this package (for example, "Object.class"). The ".class" suffix is required. This is a handle-only method. The class file may or may not be present.

      This method can handle ordinary class files or modular class files denoted by the name "module-info.class".

      Angegeben von:
      getClassFile in Schnittstelle IPackageFragment
      Parameter:
      classFileName - the given name
      Gibt zurück:
      the class file with the specified name in this package
      Löst aus:
      IllegalArgumentException - if the name does not end with ".class".
      Siehe auch:
    • getModularClassFile

      public IModularClassFile getModularClassFile()
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns the class file for "module-info.class" in this package. This is a handle-only method. The class file may or may not be present. If the class file is present, then it is guaranteed to contain an IModuleDescription.
      Angegeben von:
      getModularClassFile in Schnittstelle IPackageFragment
      Gibt zurück:
      the class file representing "module-info.class" in this package.
    • getOrdinaryClassFiles

      public IOrdinaryClassFile[] getOrdinaryClassFiles() throws JavaModelException
      Returns a collection of ordinary class files in this - a folder package fragment which has a root that has its kind set to IPackageFragmentRoot.K_Source does not recognize class files.
      Angegeben von:
      getOrdinaryClassFiles in Schnittstelle IPackageFragment
      Gibt zurück:
      all of the ordinary class files in this package fragment
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getAllClassFiles

      public IClassFile[] getAllClassFiles() throws JavaModelException
      Returns a collection of all class files in this - a folder package fragment which has a root that has its kind set to IPackageFragmentRoot.K_Source does not recognize class files.
      Angegeben von:
      getAllClassFiles in Schnittstelle IPackageFragment
      Gibt zurück:
      all of the class files in this package fragment
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getClassFiles

      @Deprecated public IClassFile[] getClassFiles() throws JavaModelException
      Veraltet.
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns all of the ordinary class files in this package fragment.

      Note: this list never includes a modular class file (see IPackageFragment.getModularClassFile()).

      Note: it is possible that a package fragment contains only compilation units (in other words, its kind is K_SOURCE), in which case this method returns an empty collection.

      Angegeben von:
      getClassFiles in Schnittstelle IPackageFragment
      Gibt zurück:
      all of the ordinary class files in this package fragment
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
    • getCompilationUnit

      public ICompilationUnit getCompilationUnit(String cuName)
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns the compilation unit with the specified name in this package (for example, "Object.java"). The name has to be a valid compilation unit name. This is a handle-only method. The compilation unit may or may not be present.
      Angegeben von:
      getCompilationUnit in Schnittstelle IPackageFragment
      Parameter:
      cuName - the given name
      Gibt zurück:
      the compilation unit with the specified name in this package
      Löst aus:
      IllegalArgumentException - if the name does not end with ".java"
      Siehe auch:
    • getCompilationUnits

      public ICompilationUnit[] getCompilationUnits() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns all of the compilation units in this package fragment.

      Note: it is possible that a package fragment contains only class files (in other words, its kind is K_BINARY), in which case this method returns an empty collection.

      Angegeben von:
      getCompilationUnits in Schnittstelle IPackageFragment
      Gibt zurück:
      all of the compilation units in this package fragment
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getCompilationUnits

      public ICompilationUnit[] getCompilationUnits(WorkingCopyOwner owner)
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns all of the compilation units in this package fragment that are in working copy mode and that have the given owner.

      Only existing working copies are returned. So a compilation unit handle that has no corresponding resource on disk will be included if and only if is in working copy mode.

      Note: it is possible that a package fragment contains only class files (in other words, its kind is K_BINARY), in which case this method returns an empty collection.

      Angegeben von:
      getCompilationUnits in Schnittstelle IPackageFragment
      Parameter:
      owner - the owner of the returned compilation units
      Gibt zurück:
      all of the compilation units in this package fragment
      Siehe auch:
    • getElementName

      public String getElementName()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the name of this element. This is a handle-only method.
      Angegeben von:
      getElementName in Schnittstelle IJavaElement
      Angegeben von:
      getElementName in Schnittstelle IPackageFragment
      Setzt außer Kraft:
      getElementName in Klasse JavaElement
      Gibt zurück:
      the element name
      Siehe auch:
      • IAdaptable
    • getElementType

      public int getElementType()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns this element's kind encoded as an integer. This is a handle-only method.
      Angegeben von:
      getElementType in Schnittstelle IJavaElement
      Gibt zurück:
      the kind of element; one of the constants declared in IJavaElement
      Siehe auch:
    • getHandleFromMemento

      public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner)
      Angegeben von:
      getHandleFromMemento in Klasse JavaElement
    • getHandleMementoDelimiter

      protected char getHandleMementoDelimiter()
      Beschreibung aus Klasse kopiert: JavaElement
      Returns the char that marks the start of this handles contribution to a memento.
      Angegeben von:
      getHandleMementoDelimiter in Klasse JavaElement
      Siehe auch:
    • getKind

      public int getKind() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns this package fragment's root kind encoded as an integer. A package fragment can contain source files (i.e. files with one of the Java-like extensions), or .class files. This is a convenience method.
      Angegeben von:
      getKind in Schnittstelle IPackageFragment
      Gibt zurück:
      this package fragment's root kind encoded as an integer
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getNonJavaResources

      public Object[] getNonJavaResources() throws JavaModelException
      Returns an array of non-java resources contained in the receiver.
      Angegeben von:
      getNonJavaResources in Schnittstelle IPackageFragment
      Gibt zurück:
      an array of non-Java resources (IFiles, IFolders, or IStorages if the package fragment is in an archive) contained in this package fragment
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getPath

      public org.eclipse.core.runtime.IPath getPath()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns 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.
      Angegeben von:
      getPath in Schnittstelle IJavaElement
      Gibt zurück:
      the path to the innermost resource enclosing this element
      Siehe auch:
    • resource

      public org.eclipse.core.resources.IResource resource(PackageFragmentRoot root)
      Angegeben von:
      resource in Klasse Openable
      Siehe auch:
    • getUnderlyingResource

      public org.eclipse.core.resources.IResource getUnderlyingResource() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the smallest underlying resource that contains this element, or null if this element is not contained in a resource.
      Angegeben von:
      getUnderlyingResource in Schnittstelle IJavaElement
      Setzt außer Kraft:
      getUnderlyingResource in Klasse Openable
      Gibt zurück:
      the underlying resource, or null if none
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its underlying resource
      Siehe auch:
    • hashCode

      public int hashCode()
      Beschreibung aus Klasse kopiert: 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.
      Setzt außer Kraft:
      hashCode in Klasse JavaElement
    • hasChildren

      public boolean hasChildren() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IParent
      Returns whether this element has one or more immediate children. This is a convenience method, and may be more efficient than testing whether getChildren is an empty array.
      Angegeben von:
      hasChildren in Schnittstelle IParent
      Setzt außer Kraft:
      hasChildren in Klasse JavaElement
      Gibt zurück:
      true if the immediate children of this element, false otherwise
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
      Siehe auch:
    • hasSubpackages

      public boolean hasSubpackages() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns whether this package fragment's name is a prefix of other package fragments in this package fragment's root.
      Angegeben von:
      hasSubpackages in Schnittstelle IPackageFragment
      Gibt zurück:
      true if this package fragment's name is a prefix of other package fragments in this package fragment's root, false otherwise
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • internalIsValidPackageName

      protected boolean internalIsValidPackageName()
    • isDefaultPackage

      public boolean isDefaultPackage()
      Beschreibung aus Schnittstelle kopiert: IPackageFragment
      Returns whether this package fragment is a default package. This is a handle-only method.
      Angegeben von:
      isDefaultPackage in Schnittstelle IPackageFragment
      Gibt zurück:
      true if this package fragment is a default package
      Siehe auch:
    • isValidPackageName

      protected final boolean isValidPackageName()
    • move

      public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ISourceManipulation
      Moves this element to the given container.
      Angegeben von:
      move in Schnittstelle ISourceManipulation
      Parameter:
      container - the container
      sibling - the sibling element before which the element should be inserted, or null if the element should be inserted as the last child of the container
      rename - the new name for the element, or null if the element retains its name
      force - true if any existing child in the container with the target name should be replaced, and false to throw an exception in the event of a name collision
      monitor - a progress monitor
      Löst aus:
      JavaModelException - if this element could not be moved. Reasons include:
      • This Java element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
      • A CoreException occurred while updating an underlying resource
      • The container is of an incompatible type (INVALID_DESTINATION)
      • The sibling is not a child of the given container (INVALID_SIBLING)
      • The new name is invalid (INVALID_NAME)
      • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
      • The container or this element is read-only (READ_ONLY)
      Siehe auch:
    • rename

      public void rename(String newName, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ISourceManipulation
      Renames this element to the given name.
      Angegeben von:
      rename in Schnittstelle ISourceManipulation
      Parameter:
      newName - the new name for the element
      force - true if any existing element with the target name should be replaced, and false to throw an exception in the event of a name collision
      monitor - a progress monitor
      Löst aus:
      JavaModelException - if this element could not be renamed. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      • A CoreException occurred while updating an underlying resource
      • The new name is invalid (INVALID_NAME)
      • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
      • This element is read-only (READ_ONLY)
      Siehe auch:
    • toStringChildren

      protected void toStringChildren(int tab, StringBuffer buffer, Object info)
      Debugging purposes
      Setzt außer Kraft:
      toStringChildren in Klasse JavaElement
    • toStringInfo

      protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo)
      Debugging purposes
      Setzt außer Kraft:
      toStringInfo in Klasse JavaElement
      Parameter:
      showResolvedInfo - TODO
    • getAttachedJavadoc

      public String getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IJavaElement

      Returns the Javadoc as HTML source if this element has attached Javadoc, null otherwise.

      This should be used only for binary elements. Source elements will always return null.

      The encoding used to read the Javadoc is the one defined by the content type of the file. If none is defined, then the project's encoding of this Java element is used. If the project's encoding cannot be retrieved, then the platform encoding is used.

      In case the Javadoc doesn't exist for this element, null is returned.

      The HTML is extracted from the attached Javadoc and provided as is. No transformation or validation is done.

      Angegeben von:
      getAttachedJavadoc in Schnittstelle IJavaElement
      Setzt außer Kraft:
      getAttachedJavadoc in Klasse JavaElement
      Parameter:
      monitor - the given progress monitor, can be null
      Gibt zurück:
      the extracted javadoc from the attached javadoc, null if none
      Löst aus:
      JavaModelException - if:
      • this element does not exist
      • retrieving the attached javadoc fails (timed-out, invalid URL, ...)
      • the format of the javadoc doesn't match expected standards (different anchors,...)
      Siehe auch:
    • validateExistence

      protected org.eclipse.core.runtime.IStatus validateExistence(org.eclipse.core.resources.IResource underlyingResource)
      Angegeben von:
      validateExistence in Klasse Openable