Package org.eclipse.jdt.ui.jarpackager
Class JarWriter3
java.lang.Object
org.eclipse.jdt.ui.jarpackager.JarWriter3
Creates a JAR file for the given JAR package data.
Clients may subclass.
- Since:
- 3.2
- See Also:
-
Constructor Summary
ConstructorDescriptionJarWriter3
(JarPackageData jarPackage, org.eclipse.swt.widgets.Shell parent) Creates an instance which is used to create a JAR based on the given JarPackage. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDirectories
(String destPath) Creates the directory entries for the given path and writes it to the current archive.protected void
addDirectories
(org.eclipse.core.resources.IResource resource, org.eclipse.core.runtime.IPath destinationPath) Creates the directory entries for the given path and writes it to the current archive.protected void
addDirectories
(org.eclipse.core.runtime.IPath destinationPath) Creates the directory entries for the given path and writes it to the current archive.protected void
addEntry
(JarEntry entry, InputStream content) Write the given entry describing the given content to the current archiveprotected void
addFile
(org.eclipse.core.resources.IFile resource, org.eclipse.core.runtime.IPath path) Creates a new JarEntry with the passed path and contents, and writes it to the current archive.protected boolean
canCreateJar
(org.eclipse.swt.widgets.Shell parent) Checks if the JAR file can be overwritten.void
close()
Closes the archive and does all required cleanup.Gets the fDirectories of this JarWriter3Gets the fJarOutputStream of this JarWriter3void
write
(org.eclipse.core.resources.IFile resource, org.eclipse.core.runtime.IPath destinationPath) Writes the passed resource to the current archive.
-
Constructor Details
-
JarWriter3
public JarWriter3(JarPackageData jarPackage, org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException Creates an instance which is used to create a JAR based on the given JarPackage.- Parameters:
jarPackage
- the JAR specificationparent
- the shell used to display question dialogs, ornull
if "false/no/cancel" is the answer and no dialog should be shown- Throws:
org.eclipse.core.runtime.CoreException
- to signal any other unusual termination. This can also be used to return information in the status object.
-
-
Method Details
-
getJarOutputStream
Gets the fJarOutputStream of this JarWriter3- Returns:
- the fJarOutputStream of this JarWriter3
- Since:
- 3.22
-
getDirectories
Gets the fDirectories of this JarWriter3- Returns:
- the fDirectories of this JarWriter3
- Since:
- 3.22
-
addDirectories
Creates the directory entries for the given path and writes it to the current archive.- Parameters:
destinationPath
- the path to add- Throws:
IOException
- if an I/O error has occurred
-
addDirectories
Creates the directory entries for the given path and writes it to the current archive.- Parameters:
destPath
- the path to add- Throws:
IOException
- if an I/O error has occurred- Since:
- 3.5
-
addDirectories
protected void addDirectories(org.eclipse.core.resources.IResource resource, org.eclipse.core.runtime.IPath destinationPath) throws IOException, org.eclipse.core.runtime.CoreException Creates the directory entries for the given path and writes it to the current archive.- Parameters:
resource
- the resource for which the parent directories are to be addeddestinationPath
- the path to add- Throws:
IOException
- if an I/O error has occurredorg.eclipse.core.runtime.CoreException
- if accessing the resource failes
-
addFile
protected void addFile(org.eclipse.core.resources.IFile resource, org.eclipse.core.runtime.IPath path) throws IOException, org.eclipse.core.runtime.CoreException Creates a new JarEntry with the passed path and contents, and writes it to the current archive.- Parameters:
resource
- the file to writepath
- the path inside the archive- Throws:
IOException
- if an I/O error has occurredorg.eclipse.core.runtime.CoreException
- if the resource can-t be accessed
-
addEntry
Write the given entry describing the given content to the current archive- Parameters:
entry
- the entry to writecontent
- the content to write- Throws:
IOException
- If an I/O error occurred- Since:
- 3.4
-
canCreateJar
protected boolean canCreateJar(org.eclipse.swt.widgets.Shell parent) Checks if the JAR file can be overwritten. If the JAR package setting does not allow to overwrite the JAR then a dialog will ask the user again.- Parameters:
parent
- the parent for the dialog, ornull
if no dialog should be presented- Returns:
true
if it is OK to create the JAR
-
close
public void close() throws org.eclipse.core.runtime.CoreExceptionCloses the archive and does all required cleanup.- Throws:
org.eclipse.core.runtime.CoreException
- to signal any other unusual termination. This can also be used to return information in the status object.
-
write
public void write(org.eclipse.core.resources.IFile resource, org.eclipse.core.runtime.IPath destinationPath) throws org.eclipse.core.runtime.CoreException Writes the passed resource to the current archive.- Parameters:
resource
- the file to be writtendestinationPath
- the path for the file inside the archive- Throws:
org.eclipse.core.runtime.CoreException
- to signal any other unusual termination. This can also be used to return information in the status object.
-