Class JarPackageData

java.lang.Object
org.eclipse.jdt.ui.jarpackager.JarPackageData

public class JarPackageData extends Object
Model for a JAR package which stores information used during JAR export and import.

Clients may subclass.

Since:
2.0
See Also:
  • Constructor Details

    • JarPackageData

      public JarPackageData()
      Creates a new Jar Package Data structure
  • Method Details

    • isCompressed

      public boolean isCompressed()
      Tells whether the JAR is compressed or not.
      Returns:
      true if the JAR is compressed
    • setCompress

      public void setCompress(boolean state)
      Set whether the JAR is compressed or not.
      Parameters:
      state - a boolean indicating the new state
    • allowOverwrite

      public boolean allowOverwrite()
      Tells whether files can be overwritten without warning.
      Returns:
      true if files can be overwritten without warning
    • setOverwrite

      public void setOverwrite(boolean state)
      Sets whether files can be overwritten without warning.
      Parameters:
      state - a boolean indicating the new state
    • areClassFilesExported

      public boolean areClassFilesExported()
      Tells whether class files and resources are exported.
      Returns:
      true if class files and resources are exported
    • setExportClassFiles

      public void setExportClassFiles(boolean state)
      Sets option to export class files and resources.
      Parameters:
      state - a boolean indicating the new state
    • areOutputFoldersExported

      public boolean areOutputFoldersExported()
      Tells whether all output folders for the enclosing projects of the exported elements.
      Returns:
      true if output folder are exported
      Since:
      3.0
    • setExportOutputFolders

      public void setExportOutputFolders(boolean state)
      Sets option to export all output folders for the enclosing projects of the exported elements.
      Parameters:
      state - a boolean indicating the new state
      Since:
      3.0
    • areGeneratedFilesExported

      public boolean areGeneratedFilesExported()
      Tells whether files created by the Java builder are exported.
      Returns:
      true if output folder are exported
      Since:
      3.0
    • areJavaFilesExported

      public boolean areJavaFilesExported()
      Tells whether java files and resources are exported.
      Returns:
      true if java files and resources are exported
    • setExportJavaFiles

      public void setExportJavaFiles(boolean state)
      Sets the option to export Java source and resources.
      Parameters:
      state - the new state
    • useSourceFolderHierarchy

      public boolean useSourceFolderHierarchy()
      Tells whether the source folder hierarchy is used.

      Using the source folder hierarchy only makes sense if java files are but class files aren't exported.

      Returns:
      true if source folder hierarchy is used
    • setUseSourceFolderHierarchy

      public void setUseSourceFolderHierarchy(boolean state)
      Set the option to export the source folder hierarchy.
      Parameters:
      state - the new state
    • getAbsoluteJarLocation

      public org.eclipse.core.runtime.IPath getAbsoluteJarLocation()
      Gets the absolute location of the JAR file. This path is normally external to the workspace.
      Returns:
      the absolute path representing the location of the JAR file
      Since:
      3.0
    • getJarLocation

      public org.eclipse.core.runtime.IPath getJarLocation()
      Gets the location of the JAR file. This path is normally external to the workspace.
      Returns:
      the path representing the location of the JAR file
    • setJarLocation

      public void setJarLocation(org.eclipse.core.runtime.IPath jarLocation)
      Sets the JAR file location.
      Parameters:
      jarLocation - a path denoting the location of the JAR file
    • isManifestGenerated

      public boolean isManifestGenerated()
      Tells whether the manifest file must be generated.
      Returns:
      true if the manifest has to be generated
    • setGenerateManifest

      public void setGenerateManifest(boolean state)
      Set whether a manifest must be generated or not.
      Parameters:
      state - the new state
    • isManifestSaved

      public boolean isManifestSaved()
      Tells whether the manifest file must be saved to the specified file during the export operation.
      Returns:
      true if the manifest must be saved
      See Also:
    • setSaveManifest

      public void setSaveManifest(boolean state)
      Sets whether the manifest file must be saved during export operation or not.
      Parameters:
      state - the new state
      See Also:
    • isManifestReused

      public boolean isManifestReused()
      Tells whether a previously generated manifest should be reused.
      Returns:
      true if the generated manifest will be reused when regenerating this JAR, false if the manifest has to be regenerated
    • setReuseManifest

      public void setReuseManifest(boolean state)
      Sets whether a previously generated manifest should be reused.
      Parameters:
      state - the new state
    • getManifestLocation

      public org.eclipse.core.runtime.IPath getManifestLocation()
      Returns the location of a user-defined manifest file.
      Returns:
      the path of the user-defined manifest file location, or null if none is specified
    • setManifestLocation

      public void setManifestLocation(org.eclipse.core.runtime.IPath manifestLocation)
      Sets the location of a user-defined manifest file.
      Parameters:
      manifestLocation - the path of the user-define manifest location
    • getManifestFile

      public org.eclipse.core.resources.IFile getManifestFile()
      Gets the manifest file (as workspace resource).
      Returns:
      a file which points to the manifest
    • getManifestVersion

      public String getManifestVersion()
      Gets the manifest version.
      Returns:
      a string containing the manifest version
    • setManifestVersion

      public void setManifestVersion(String manifestVersion)
      Sets the manifest version.
      Parameters:
      manifestVersion - the string which contains the manifest version
    • usesManifest

      public boolean usesManifest()
      Answers whether a manifest must be included in the JAR.
      Returns:
      true if a manifest has to be included
    • setUsesManifest

      public void setUsesManifest(boolean state)
      Sets whether a manifest must be included in the JAR.
      Parameters:
      state - the new state
    • getManifestProvider

      public IManifestProvider getManifestProvider()
      Gets the manifest provider for this JAR package.
      Returns:
      the IManifestProvider
    • setManifestProvider

      public void setManifestProvider(IManifestProvider manifestProvider)
      Sets the manifest provider.
      Parameters:
      manifestProvider - the ManifestProvider to set
    • isJarSealed

      public boolean isJarSealed()
      Answers whether the JAR itself is sealed. The manifest will contain a "Sealed: true" statement.

      This option should only be considered when the manifest file is generated.

      Returns:
      true if the JAR must be sealed
      See Also:
    • setSealJar

      public void setSealJar(boolean sealJar)
      Sets whether the JAR itself is sealed. The manifest will contain the following entry: Sealed: true

      This option should only be considered when the manifest file is generated.

      Parameters:
      sealJar - true if the JAR must be sealed
      See Also:
    • setPackagesToSeal

      public void setPackagesToSeal(IPackageFragment[] packagesToSeal)
      Sets the packages which should be sealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: true

      This should only be used if the JAR itself is not sealed.

      Parameters:
      packagesToSeal - an array of IPackageFragment to seal
    • getPackagesToSeal

      public IPackageFragment[] getPackagesToSeal()
      Gets the packages which should be sealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: true

      This should only be used if the JAR itself is not sealed.

      Returns:
      an array of IPackageFragment
    • getPackagesToUnseal

      public IPackageFragment[] getPackagesToUnseal()
      Gets the packages which should explicitly be unsealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: false

      This should only be used if the JAR itself is sealed.

      Returns:
      an array of IPackageFragment
    • setPackagesToUnseal

      public void setPackagesToUnseal(IPackageFragment[] packagesToUnseal)
      Set the packages which should explicitly be unsealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: false

      This should only be used if the JAR itself is sealed.

      Parameters:
      packagesToUnseal - an array of IPackageFragment
    • isDescriptionSaved

      public boolean isDescriptionSaved()
      Tells whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.

      The JAR writer defines the format of the file.

      Returns:
      true if this JAR package will be saved
      See Also:
    • setSaveDescription

      public void setSaveDescription(boolean state)
      Set whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.

      The format is defined by the client who implements the reader/writer pair.

      Parameters:
      state - a boolean containing the new state
      See Also:
    • getDescriptionLocation

      public org.eclipse.core.runtime.IPath getDescriptionLocation()
      Returns the location of file containing the description of a JAR. This location is inside the workspace.
      Returns:
      the path of the description file location, or null if none is specified
    • setDescriptionLocation

      public void setDescriptionLocation(org.eclipse.core.runtime.IPath descriptionLocation)
      Set the location of the JAR description file.
      Parameters:
      descriptionLocation - the path of location
    • getDescriptionFile

      public org.eclipse.core.resources.IFile getDescriptionFile()
      Gets the description file (as workspace resource).
      Returns:
      a file which points to the description
    • getManifestMainClass

      public IType getManifestMainClass()
      Gets the manifest's main class.
      Returns:
      the type which contains the main class or, null if none is specified
    • setManifestMainClass

      public void setManifestMainClass(IType manifestMainClass)
      Set the manifest's main class.
      Parameters:
      manifestMainClass - the type with the main class for the manifest file
    • getElements

      public Object[] getElements()
      Returns the elements which will be exported. These elements are leaf objects e.g. IFile and not containers.
      Returns:
      an array of leaf objects
    • setElements

      public void setElements(Object[] elements)
      Set the elements which will be exported. These elements are leaf objects e.g. IFile. and not containers.
      Parameters:
      elements - an array with leaf objects
    • getComment

      public String getComment()
      Returns the JAR's comment.
      Returns:
      the comment string or null if the JAR does not contain a comment
    • setComment

      public void setComment(String comment)
      Sets the JAR's comment.
      Parameters:
      comment - a string or null if the JAR does not contain a comment
    • logErrors

      @Deprecated public boolean logErrors()
      Deprecated.
      will be removed in final 2.0
      Tell whether errors are logged.

      The export operation decides where and how the errors are logged.

      Returns:
      true if errors are logged
    • setLogErrors

      @Deprecated public void setLogErrors(boolean logErrors)
      Deprecated.
      will be removed in final 2.0
      Sets whether errors are logged.

      The export operation decides where and how the errors are logged.

      Parameters:
      logErrors - true if errors are logged
    • logWarnings

      @Deprecated public boolean logWarnings()
      Deprecated.
      will be removed in final 2.0
      Tells whether warnings are logged or not.

      The export operation decides where and how the warnings are logged.

      Returns:
      true if warnings are logged
    • setLogWarnings

      @Deprecated public void setLogWarnings(boolean logWarnings)
      Deprecated.
      will be removed in final 2.0
      Sets if warnings are logged.

      The export operation decides where and how the warnings are logged.

      Parameters:
      logWarnings - true if warnings are logged
    • areErrorsExported

      public boolean areErrorsExported()
      Answers if compilation units with errors are exported.
      Returns:
      true if CUs with errors should be exported
    • setExportErrors

      public void setExportErrors(boolean exportErrors)
      Sets if compilation units with errors are exported.
      Parameters:
      exportErrors - true if CUs with errors should be exported
    • exportWarnings

      public boolean exportWarnings()
      Answers if compilation units with warnings are exported.
      Returns:
      true if CUs with warnings should be exported
    • setExportWarnings

      public void setExportWarnings(boolean exportWarnings)
      Sets if compilation units with warnings are exported.
      Parameters:
      exportWarnings - true if CUs with warnings should be exported
    • isBuildingIfNeeded

      public boolean isBuildingIfNeeded()
      Answers if a build should be performed before exporting files. This flag is only considered if auto-build is off.
      Returns:
      a boolean telling if a build should be performed
    • setBuildIfNeeded

      public void setBuildIfNeeded(boolean buildIfNeeded)
      Sets if a build should be performed before exporting files. This flag is only considered if auto-build is off.
      Parameters:
      buildIfNeeded - a boolean telling if a build should be performed
    • findClassfilesFor

      public org.eclipse.core.resources.IFile[] findClassfilesFor(org.eclipse.core.resources.IFile javaFile) throws org.eclipse.core.runtime.CoreException
      Finds the class files for the given java file and returns them.

      This is a hook for subclasses which want to implement a different strategy for finding the class files. The default strategy is to query the class files for the source file name attribute. If this attribute is missing then all class files in the corresponding output folder are exported.

      A CoreException can be thrown if an error occurs during this operation. The CoreException will not stop the export process but adds the status object to the status of the export runnable.

      Parameters:
      javaFile - a .java file
      Returns:
      an array with class files or null to used the default strategy
      Throws:
      org.eclipse.core.runtime.CoreException - if find failed, e.g. I/O error or resource out of sync
      See Also:
    • createJarWriter

      @Deprecated public JarWriter2 createJarWriter(org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException
      Deprecated.
      Creates and returns a JarWriter for this JAR package.
      Parameters:
      parent - the shell used to display question dialogs, or null if "false/no/cancel" is the answer and no dialog should be shown
      Returns:
      a JarWriter2
      Throws:
      org.eclipse.core.runtime.CoreException - if an unexpected exception happens
      See Also:
    • createJarWriter3

      @Deprecated public JarWriter3 createJarWriter3(org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException
      Deprecated.
      Creates and returns a JarWriter for this JAR package.
      Parameters:
      parent - the shell used to display question dialogs, or null if "false/no/cancel" is the answer and no dialog should be shown
      Returns:
      a JarWriter3
      Throws:
      org.eclipse.core.runtime.CoreException - if an unexpected exception happens
      Since:
      3.2
      See Also:
    • createPlainJarBuilder

      public IJarBuilder createPlainJarBuilder()
      Creates and returns a jar builder capable of handling files but not archives.
      Returns:
      a new instance of a plain jar builder
      Since:
      3.4
    • createFatJarBuilder

      public IJarBuilder createFatJarBuilder()
      Creates and returns a jar builder capable of handling files and archives.
      Returns:
      a new instance of a fat jar builder
      Since:
      3.4
    • createJarExportRunnable

      public IJarExportRunnable createJarExportRunnable(org.eclipse.swt.widgets.Shell parent)
      Creates and returns a JarExportRunnable.
      Parameters:
      parent - the parent for the dialog, or null if no questions should be asked and no checks for unsaved files should be made.
      Returns:
      a JarExportRunnable
    • createJarExportRunnable

      public IJarExportRunnable createJarExportRunnable(JarPackageData[] jarPackagesData, org.eclipse.swt.widgets.Shell parent)
      Creates and returns a JarExportRunnable for a list of JAR package data objects.
      Parameters:
      jarPackagesData - an array with JAR package data objects
      parent - the parent for the dialog, or null if no dialog should be presented
      Returns:
      the IJarExportRunnable
    • createJarDescriptionWriter

      @Deprecated public IJarDescriptionWriter createJarDescriptionWriter(OutputStream outputStream)
      Creates and returns a JAR package data description writer for this JAR package data object.

      It is the client's responsibility to close this writer.

      Parameters:
      outputStream - the output stream to write to
      Returns:
      a JarWriter
    • createJarDescriptionWriter

      public IJarDescriptionWriter createJarDescriptionWriter(OutputStream outputStream, String encoding)
      Creates and returns a JAR package data description writer for this JAR package data object.

      It is the client's responsibility to close this writer.

      Parameters:
      outputStream - the output stream to write to
      encoding - the encoding to use
      Returns:
      a JarWriter
      Since:
      3.3
    • createJarDescriptionReader

      public IJarDescriptionReader createJarDescriptionReader(InputStream inputStream)
      Creates and returns a JAR package data description reader for this JAR package data object.

      It is the client's responsibility to close this reader.

      Parameters:
      inputStream - the input stream to read from
      Returns:
      a JarWriter
    • isValid

      public boolean isValid()
      Tells whether this JAR package data can be used to generate a valid JAR.
      Returns:
      true if the JAR Package info is valid
    • isManifestAccessible

      public boolean isManifestAccessible()
      Tells whether a manifest is available.
      Returns:
      true if the manifest is generated or the provided one is accessible
    • isMainClassValid

      public boolean isMainClassValid(org.eclipse.jface.operation.IRunnableContext context)
      Tells whether the specified manifest main class is valid.
      Parameters:
      context - the IRunnableContext
      Returns:
      true if a main class is specified and valid
    • areDirectoryEntriesIncluded

      public boolean areDirectoryEntriesIncluded()
      Tells whether directory entries are added to the jar.
      Returns:
      true if directory entries are to be included
      Since:
      3.1
    • setIncludeDirectoryEntries

      public void setIncludeDirectoryEntries(boolean includeDirectoryEntries)
      Sets the option to include directory entries into the jar.
      Parameters:
      includeDirectoryEntries - true to include directory entries false otherwise
      Since:
      3.1
    • getRefactoringProjects

      public org.eclipse.core.resources.IProject[] getRefactoringProjects()
      Returns the projects for which refactoring information should be stored.

      This information is used for JAR export.

      Returns:
      the projects for which refactoring information should be stored, or an empty array
      Since:
      3.2
    • isExportStructuralOnly

      public boolean isExportStructuralOnly()
      Is the JAR export wizard only exporting refactorings causing structural changes?

      This information is used for JAR export.

      Returns:
      true if exporting structural changes only, false otherwise
      Since:
      3.2
    • isRefactoringAware

      public boolean isRefactoringAware()
      Is the JAR package refactoring aware?

      This information is used both in JAR export and import

      Returns:
      true if it is refactoring aware, false otherwise
      Since:
      3.2
    • isDeprecationAware

      public boolean isDeprecationAware()
      Is the JAR package deprecation aware?

      This information is used in JAR export.

      Returns:
      true if it is deprecation aware, false otherwise
      Since:
      3.2
    • setRefactoringProjects

      public void setRefactoringProjects(org.eclipse.core.resources.IProject[] projects)
      Sets the projects for which refactoring information should be stored.

      This information is used for JAR export.

      Parameters:
      projects - the projects for which refactoring information should be stored
      Since:
      3.2
    • setRefactoringAware

      public void setRefactoringAware(boolean aware)
      Determines whether the jar package is refactoring aware.

      This information is used both in JAR export and import.

      Parameters:
      aware - true if it is refactoring aware, false otherwise
      Since:
      3.2
    • setDeprecationAware

      public void setDeprecationAware(boolean aware)
      Determines whether the jar package is deprecation aware.

      This information is used in JAR export.

      Parameters:
      aware - true if it is deprecation aware, false otherwise
      Since:
      3.2
    • setRefactoringDescriptors

      public void setRefactoringDescriptors(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[] descriptors)
      Sets the refactoring descriptors to export.

      This information is used in JAR export.

      Parameters:
      descriptors - the refactoring descriptors
      Since:
      3.2
    • getRefactoringDescriptors

      public org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[] getRefactoringDescriptors()
      Returns the refactoring descriptors to export.

      This information is used in JAR export.

      Returns:
      the refactoring descriptors to export
      Since:
      3.2
    • setExportStructuralOnly

      public void setExportStructuralOnly(boolean structural)
      Determines whether the jar packager exports only refactorings causing structural changes.

      This information is used for JAR export.

      Parameters:
      structural - true if it exports only refactorings causing structural changes, false otherwise
      Since:
      3.2
    • getJarBuilder

      public IJarBuilder getJarBuilder()
      Returns the jar builder which can be used to build the jar described by this package data.
      Returns:
      the builder to use
      Since:
      3.4
    • setJarBuilder

      public void setJarBuilder(IJarBuilder jarBuilder)
      Set the jar builder to use to build the jar.
      Parameters:
      jarBuilder - the builder to use
      Since:
      3.4
    • getLaunchConfigurationName

      public String getLaunchConfigurationName()
      Get the name of the launch configuration from which to retrieve classpath information.
      Returns:
      the name of the launch configuration
      Since:
      3.4
    • setLaunchConfigurationName

      public void setLaunchConfigurationName(String name)
      Set the name of the launch configuration form which to retrieve classpath information.
      Parameters:
      name - name of the launch configuration
      Since:
      3.4