Eclipse Platform
2.0

org.eclipse.update.core
Class JarContentReference

java.lang.Object
  |
  +--org.eclipse.update.core.ContentReference
        |
        +--org.eclipse.update.core.JarContentReference

public class JarContentReference
extends ContentReference

Local .jar file content reference

This class may be instantiated or subclassed by clients.

Since:
2.0
See Also:
ContentReference, JarEntryContentReference

Nested Class Summary
static class JarContentReference.ContentSelector
          Content selector used in .jar operations.
 
Field Summary
 
Fields inherited from class org.eclipse.update.core.ContentReference
UNKNOWN_SIZE
 
Constructor Summary
JarContentReference(String id, File file)
          Create jar content reference from file.
JarContentReference(String id, URL url)
          Create jar content reference from URL.
 
Method Summary
protected  JarFile asJarFile()
          Returns the content reference as a jar file.
 void closeArchive()
          Closes the jar archive corresponding to this reference
 ContentReference createContentReference(String id, File file)
          A factory method to create a jar content reference.
 ContentReference[] peek(JarContentReference.ContentSelector selector, InstallMonitor monitor)
          Peeks into the referenced jar archive.
 ContentReference peek(String entryName, JarContentReference.ContentSelector selector, InstallMonitor monitor)
          Peeks into the referenced jar archive looking for the named entry.
static void shutdown()
          Perform shutdown processing for jar archive handling.
 ContentReference[] unpack(File dir, JarContentReference.ContentSelector selector, InstallMonitor monitor)
          Unpacks the referenced jar archive into the specified location.
 ContentReference unpack(File dir, String entryName, JarContentReference.ContentSelector selector, InstallMonitor monitor)
          Unpacks the named jar entry into the specified location.
 
Methods inherited from class org.eclipse.update.core.ContentReference
asFile, asURL, getIdentifier, getInputSize, getInputStream, isLocalReference, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarContentReference

public JarContentReference(String id,
                           URL url)
Create jar content reference from URL.

Parameters:
id - "symbolic" path identifier
url - actual referenced URL
Since:
2.0

JarContentReference

public JarContentReference(String id,
                           File file)
Create jar content reference from file.

Parameters:
id - "symbolic" path identifier
file - actual referenced file
Since:
2.0
Method Detail

createContentReference

public ContentReference createContentReference(String id,
                                               File file)
A factory method to create a jar content reference.

Overrides:
createContentReference in class ContentReference
Parameters:
id - "symbolic" path identifier
file - actual referenced file
Returns:
jar content reference
Since:
2.0

asJarFile

protected JarFile asJarFile()
                     throws IOException
Returns the content reference as a jar file. Note, that this method does not cause the file to be downloaded if it is not already local.

Returns:
reference as jar file
Throws:
IOException - reference cannot be returned as jar file
Since:
2.0

unpack

public ContentReference[] unpack(File dir,
                                 JarContentReference.ContentSelector selector,
                                 InstallMonitor monitor)
                          throws IOException,
                                 InstallAbortedException
Unpacks the referenced jar archive into the specified location. Returns content references to the unpacked files.

Parameters:
dir - location to unpack the jar into
selector - selector, used to select entries to unpack, and to define "symbolic" path identifiers for the entries.
monitor - progress monitor
Throws:
IOException
InstallAbortedException
Since:
2.0

unpack

public ContentReference unpack(File dir,
                               String entryName,
                               JarContentReference.ContentSelector selector,
                               InstallMonitor monitor)
                        throws IOException,
                               InstallAbortedException
Unpacks the named jar entry into the specified location. Returns content reference to the unpacked file.

Parameters:
dir - location to unpack the jar into
entryName - name of the jar entry
selector - selector, used to define "symbolic" path identifier for the entry
monitor - progress monitor
Throws:
IOException
InstallAbortedException
Since:
2.0

peek

public ContentReference[] peek(JarContentReference.ContentSelector selector,
                               InstallMonitor monitor)
                        throws IOException
Peeks into the referenced jar archive. Returns content references to the jar entries within the jar file.

Parameters:
selector - selector, used to select entries to return, and to define "symbolic" path identifiers for the entries.
monitor - progress monitor
Throws:
IOException
Since:
2.0

peek

public ContentReference peek(String entryName,
                             JarContentReference.ContentSelector selector,
                             InstallMonitor monitor)
                      throws IOException
Peeks into the referenced jar archive looking for the named entry. Returns content reference to the jar entry within the jar file.

Parameters:
entryName - name of the jar entry
selector - selector, used to define "symbolic" path identifier for the entry
monitor - progress monitor
Returns:
the content reference ofr null if the entry doesn't exist
Throws:
IOException
Since:
2.0

closeArchive

public void closeArchive()
                  throws IOException
Closes the jar archive corresponding to this reference

Throws:
IOException
Since:
2.0

shutdown

public static void shutdown()
Perform shutdown processing for jar archive handling. This method is called when platform is shutting down. It is not intended to be called at any other time under normal circumstances. A side-effect of calling this method is that all jars referenced by JarContentReferences are closed.

Since:
2.0

Eclipse Platform
2.0

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