Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse JDT
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.jdt.ui.jarpackager
Class JarPackageData

java.lang.Object
  extended byorg.eclipse.jdt.ui.jarpackager.JarPackageData


public class JarPackageData
extends Object

Model for a JAR package. Describes a JAR package including a bunch of useful options to generate a JAR file with a JAR writer. Clients may subclass.

Since:
2.0
See Also:
JarWriter


Constructor Summary
JarPackageData()
           
 
Method Summary
 boolean allowOverwrite()
          Tells whether files can be overwritten without warning.
 boolean areClassFilesExported()
          Tells whether class files and resources are exported.
 boolean areErrorsExported()
          Answers if compilation units with errors are exported.
 boolean areGeneratedFilesExported()
          Tells whether files created by the Java builder are exported.
 boolean areJavaFilesExported()
          Tells whether java files and resources are exported.
 boolean areOutputFoldersExported()
          Tells whether all output folders for the enclosing projects of the exported elements.
 IJarDescriptionReader createJarDescriptionReader(InputStream inputStream)
          Creates and returns a JAR package data description reader for this JAR package data object.
 IJarDescriptionWriter createJarDescriptionWriter(OutputStream outputStream)
          Creates and returns a JAR package data description writer for this JAR package data object.
 IJarExportRunnable createJarExportRunnable(JarPackageData[] jarPackagesData, Shell parent)
          Creates and returns a JarExportRunnable for a list of JAR package data objects.
 IJarExportRunnable createJarExportRunnable(Shell parent)
          Creates and returns a JarExportRunnable.
 JarWriter createJarWriter(Shell parent)
          Creates and returns a JarWriter for this JAR package.
 boolean exportWarnings()
          Answers if compilation units with warnings are exported.
 IFile[] findClassfilesFor(IFile javaFile)
          Finds the class files for the given java file and returns them.
 IPath getAbsoluteJarLocation()
          Gets the absolute location of the JAR file.
 String getComment()
          Returns the JAR's comment.
 IFile getDescriptionFile()
          Gets the description file (as workspace resource).
 IPath getDescriptionLocation()
          Returns the location of file containing the description of a JAR.
 Object[] getElements()
          Returns the elements which will be exported.
 IPath getJarLocation()
          Gets the location of the JAR file.
 IFile getManifestFile()
          Gets the manifest file (as workspace resource).
 IPath getManifestLocation()
          Returns the location of a user-defined manifest file.
 IType getManifestMainClass()
          Gets the manifest's main class.
 IManifestProvider getManifestProvider()
          Gets the manifest provider for this JAR package.
 String getManifestVersion()
          Gets the manifest version.
 IPackageFragment[] getPackagesToSeal()
          Gets the packages which should be sealed.
 IPackageFragment[] getPackagesToUnseal()
          Gets the packages which should explicitly be unsealed.
 boolean isBuildingIfNeeded()
          Answers if a build should be performed before exporting files.
 boolean isCompressed()
          Tells whether the JAR is compressed or not.
 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.
 boolean isJarSealed()
          Answers whether the JAR itself is sealed.
 boolean isMainClassValid(IRunnableContext context)
          Tells whether the specified manifest main class is valid.
 boolean isManifestAccessible()
          Tells whether a manifest is available.
 boolean isManifestGenerated()
          Tells whether the manifest file must be generated.
 boolean isManifestReused()
          Tells whether a previously generated manifest should be reused.
 boolean isManifestSaved()
          Tells whether the manifest file must be saved to the specified file during the export operation.
 boolean isValid()
          Tells whether this JAR package data can be used to generate a valid JAR.
 boolean logErrors()
          Deprecated. will be removed in final 2.0
 boolean logWarnings()
          Deprecated. will be removed in final 2.0
 void setBuildIfNeeded(boolean buildIfNeeded)
          Sets if a build should be performed before exporting files.
 void setComment(String comment)
          Sets the JAR's comment.
 void setCompress(boolean state)
          Set whether the JAR is compressed or not.
 void setDescriptionLocation(IPath descriptionLocation)
          Set the location of the JAR description file.
 void setElements(Object[] elements)
          Set the elements which will be exported.
 void setExportClassFiles(boolean state)
          Sets option to export class files and resources.
 void setExportErrors(boolean exportErrors)
          Sets if compilation units with errors are exported.
 void setExportJavaFiles(boolean state)
          Sets the option to export Java source and resources.
 void setExportOutputFolders(boolean state)
          Sets option to export all output folders for the enclosing projects of the exported elements.
 void setExportWarnings(boolean exportWarnings)
          Sets if compilation units with warnings are exported.
 void setGenerateManifest(boolean state)
          Set whether a manifest must be generated or not.
 void setJarLocation(IPath jarLocation)
          Sets the JAR file location.
 void setLogErrors(boolean logErrors)
          Deprecated. will be removed in final 2.0
 void setLogWarnings(boolean logWarnings)
          Deprecated. will be removed in final 2.0
 void setManifestLocation(IPath manifestLocation)
          Sets the location of a user-defined manifest file.
 void setManifestMainClass(IType manifestMainClass)
          Set the manifest's main class.
 void setManifestProvider(IManifestProvider manifestProvider)
          Sets the manifest provider.
 void setManifestVersion(String manifestVersion)
          Sets the manifest version.
 void setOverwrite(boolean state)
          Sets whether files can be overwritten without warning.
 void setPackagesToSeal(IPackageFragment[] packagesToSeal)
          Sets the packages which should be sealed.
 void setPackagesToUnseal(IPackageFragment[] packagesToUnseal)
          Set the packages which should explicitly be unsealed.
 void setReuseManifest(boolean state)
          Sets whether a previously generated manifest should be reused.
 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.
 void setSaveManifest(boolean state)
          Sets whether the manifest file must be saved during export operation or not.
 void setSealJar(boolean sealJar)
          Sets whether the JAR itself is sealed.
 void setUsesManifest(boolean state)
          Sets whether a manifest must be included in the JAR.
 void setUseSourceFolderHierarchy(boolean state)
          Set the option to export the source folder hierarchy.
 boolean usesManifest()
          Answers whether a manifest must be included in the JAR.
 boolean useSourceFolderHierarchy()
          Tells whether the source folder hierarchy is used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

 

 

JarPackageData

public JarPackageData()

Method Detail

 

 

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 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 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(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:
getManifestLocation()


 

 

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:
getManifestLocation()


 

 

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 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(IPath manifestLocation)

Sets the location of a user-defined manifest file.

Parameters:
manifestLocation - the path of the user-define manifest location


 

 

getManifestFile

public 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:
isManifestGenerated()


 

 

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:
isManifestGenerated()


 

 

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: 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: 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: 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: 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:
getDescriptionLocation()


 

 

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(), IJarDescriptionWriter


 

 

getDescriptionLocation

public 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(IPath descriptionLocation)

Set the location of the JAR description file.

Parameters:
descriptionLocation - the path of location


 

 

getDescriptionFile

public 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

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

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

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

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 IFile[] findClassfilesFor(IFile javaFile)
                          throws 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:
CoreException - if find failed, e.g. I/O error or resource out of sync
See Also:
IJarExportRunnable.getStatus()


 

 

createJarWriter

public JarWriter createJarWriter(Shell parent)
                          throws CoreException

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 JarWriter
Throws:
CoreException
See Also:
JarWriter


 

 

createJarExportRunnable

public IJarExportRunnable createJarExportRunnable(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,
                                                  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

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


 

 

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(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


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse JDT
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.