org.openide.filesystems
Class JarFileSystem

java.lang.Object
  |
  +--org.openide.filesystems.FileSystem
        |
        +--org.openide.filesystems.AbstractFileSystem
              |
              +--org.openide.filesystems.JarFileSystem
All Implemented Interfaces:
Serializable

public class JarFileSystem
extends AbstractFileSystem

A virtual file system based on a JAR archive.

See Also:
Serialized Form

Inner Class Summary
static class JarFileSystem.Impl
          Implementation of all interfaces List, Change, Info and Attr that delegates to JarFileSystem
 
Inner classes inherited from class org.openide.filesystems.AbstractFileSystem
AbstractFileSystem.Attr, AbstractFileSystem.Change, AbstractFileSystem.Info, AbstractFileSystem.List, AbstractFileSystem.Transfer
 
Inner classes inherited from class org.openide.filesystems.FileSystem
FileSystem.AtomicAction, FileSystem.Environment, FileSystem.Status
 
Fields inherited from class org.openide.filesystems.AbstractFileSystem
attr, change, info, list, transfer
 
Fields inherited from class org.openide.filesystems.FileSystem
PROP_HIDDEN, PROP_READ_ONLY, PROP_ROOT, PROP_SYSTEM_NAME, PROP_VALID
 
Constructor Summary
JarFileSystem()
          Default constructor.
JarFileSystem(FileSystemCapability cap)
          Constructor that can provide own capability for the file system.
 
Method Summary
 void addNotify()
          initialization of jar variable, that is necessary after JarFileSystem was removed from Repository
protected  Enumeration attributes(String name)
          Get all file attribute names for the file.
protected  String[] children(String name)
          Scans children for given name
protected  void createData(String name)
          Create new data file.
protected  void createFolder(String name)
          Creates new folder named name.
protected  Reference createReference(FileObject fo)
          Creates Reference.
protected  void delete(String name)
          Delete the file.
protected  void deleteAttributes(String name)
          Called when a file is deleted to also delete its attributes.
protected  void finalize()
          Close the jar file when we go away...
 FileObject find(String aPackage, String name, String ext)
          Finds file in the filesystem by name.
 FileObject findResource(String name)
          Finds file when its resource name is given.
protected  boolean folder(String name)
          Test if the file is folder or contains data.
 String getDisplayName()
          Provides a name for the system that can be presented to the user.
 File getJarFile()
          Get the file path for the ZIP or JAR file.
 Manifest getManifest()
          Get the JAR manifest.
 FileObject getRoot()
          Getter for root folder in the filesystem.
protected  InputStream inputStream(String name)
          Get input stream.
 boolean isReadOnly()
          This file system is read-only.
protected  Date lastModified(String name)
          Get last modification time.
protected  void lock(String name)
          Does nothing.
protected  void markUnimportant(String name)
          Does nothing.
protected  String mimeType(String name)
          Get the MIME type of the file.
protected  OutputStream outputStream(String name)
          Get output stream.
 void prepareEnvironment(FileSystem.Environment env)
          Prepare environment for external compilation or execution.
protected  Object readAttribute(String name, String attrName)
          Get the file attribute with the specified name.
protected  boolean readOnly(String name)
          Test whether this file can be written to or not.
 void removeNotify()
          Closes associated JAR file on cleanup, if possible.
protected  void rename(String oldName, String newName)
          Renames a file.
protected  void renameAttributes(String oldName, String newName)
          Called when a file is renamed, to appropriatelly update its attributes.
 void setJarFile(File aRoot)
          Set name of the ZIP/JAR file.
protected  long size(String name)
          Get the size of the file.
protected  void unlock(String name)
          Unlock the file.
protected  void writeAttribute(String name, String attrName, Object value)
          Set the file attribute with the specified name.
 
Methods inherited from class org.openide.filesystems.AbstractFileSystem
existingFileObjects, findReference, getActions, getRefreshTime, refreshResource, refreshRoot, setRefreshTime
 
Methods inherited from class org.openide.filesystems.FileSystem
addFileStatusListener, addPropertyChangeListener, addVetoableChangeListener, fireFileStatusChanged, firePropertyChange, fireVetoableChange, getActions, getCapability, getStatus, getSystemName, isDefault, isHidden, isPersistent, isValid, removeFileStatusListener, removePropertyChangeListener, removeVetoableChangeListener, runAtomicAction, setCapability, setHidden, setSystemName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarFileSystem

public JarFileSystem()
Default constructor.

JarFileSystem

public JarFileSystem(FileSystemCapability cap)
Constructor that can provide own capability for the file system.
Parameters:
cap - the capability
Method Detail

getRoot

public FileObject getRoot()
Getter for root folder in the filesystem.
Overrides:
getRoot in class AbstractFileSystem
Returns:
root folder of whole filesystem

findResource

public FileObject findResource(String name)
Description copied from class: FileSystem
Finds file when its resource name is given. The name has the usual format for the ClassLoader.getResource(String) method. So it may consist of "package1/package2/filename.ext". If there is no package, it may consist only of "filename.ext".
Overrides:
findResource in class AbstractFileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
name - resource name
Returns:
FileObject that represents file with given name or null if the file does not exist

find

public FileObject find(String aPackage,
                       String name,
                       String ext)
Description copied from class: FileSystem
Finds file in the filesystem by name.

The default implementation converts dots in the package name into slashes, concatenates the strings, adds any extension prefixed by a dot and calls the findResource method.

Note: when both of name and ext are null then name and extension should be ignored and scan should look only for a package.

Overrides:
find in class AbstractFileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
aPackage - package name where each package component is separated by a dot
name - name of the file (without dots) or null if one wants to obtain a folder (package) and not a file in it
ext - extension of the file (without leading dot) or null if one needs a package and not a file
Returns:
a file object that represents a file with the given name or null if the file does not exist

createReference

protected Reference createReference(FileObject fo)
Creates Reference. In FileSystem, which subclasses AbstractFileSystem, you can overload method createReference(FileObject fo) to achieve another type of Reference (weak, strong etc.)
Overrides:
createReference in class AbstractFileSystem
Parameters:
fo - is FileObject. It`s reference yourequire to get.
Returns:
Reference to FileObject

getManifest

public Manifest getManifest()
Get the JAR manifest. It will be lazily initialized.
Returns:
parsed manifest file for this archive

setJarFile

public void setJarFile(File aRoot)
                throws IOException,
                       PropertyVetoException
Set name of the ZIP/JAR file.
Parameters:
aRoot - path to new ZIP or JAR file
Throws:
IOException - if the file is not valid

getJarFile

public File getJarFile()
Get the file path for the ZIP or JAR file.
Returns:
the file path

getDisplayName

public String getDisplayName()
Description copied from class: FileSystem
Provides a name for the system that can be presented to the user.
Overrides:
getDisplayName in class AbstractFileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
user presentable name of the file system

isReadOnly

public boolean isReadOnly()
This file system is read-only.
Overrides:
isReadOnly in class FileSystem
Returns:
true

removeNotify

public void removeNotify()
Closes associated JAR file on cleanup, if possible.
Overrides:
removeNotify in class FileSystem

addNotify

public void addNotify()
initialization of jar variable, that is necessary after JarFileSystem was removed from Repository
Overrides:
addNotify in class FileSystem

prepareEnvironment

public void prepareEnvironment(FileSystem.Environment env)
Prepare environment for external compilation or execution.

Adds name of the ZIP/JAR file, if it has been set, to the class path.

Overrides:
prepareEnvironment in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
env - the environment to setup
Throws:
EnvironmentNotSupportedException - if external execution and compilation cannot be supported

children

protected String[] children(String name)
Scans children for given name

createFolder

protected void createFolder(String name)
                     throws IOException
Creates new folder named name.
Parameters:
name - name of folder
Throws:
IOException - if operation fails

createData

protected void createData(String name)
                   throws IOException
Create new data file.
Parameters:
name - name of the file
Returns:
the new data file object
Throws:
IOException - if the file cannot be created (e.g. already exists)

rename

protected void rename(String oldName,
                      String newName)
               throws IOException
Renames a file.
Parameters:
oldName - old name of the file
newName - new name of the file

delete

protected void delete(String name)
               throws IOException
Delete the file.
Parameters:
name - name of file
Throws:
IOException - if the file could not be deleted

lastModified

protected Date lastModified(String name)
Get last modification time.
Parameters:
name - the file to test
Returns:
the date

folder

protected boolean folder(String name)
Test if the file is folder or contains data.
Parameters:
name - name of the file
Returns:
true if the file is folder, false otherwise

readOnly

protected boolean readOnly(String name)
Test whether this file can be written to or not.
Parameters:
name - the file to test
Returns:
true if file is read-only

mimeType

protected String mimeType(String name)
Get the MIME type of the file. If filesystem has no special support for MIME types then can simply return null. FileSystem can register MIME types for a well-known extensions: FileUtil.setMIMEType(String ext, String mimeType) or together with filesystem supply some resolvers subclassed from MIMEResolver.
Parameters:
name - the file to test
Returns:
the MIME type textual representation (e.g. "text/plain") or null if no special support for recognizing MIME is implemented.

size

protected long size(String name)
Get the size of the file.
Parameters:
name - the file to test
Returns:
the size of the file in bytes or zero if the file does not contain data (does not exist or is a folder).

inputStream

protected InputStream inputStream(String name)
                           throws FileNotFoundException
Get input stream.
Parameters:
name - the file to test
Returns:
an input stream to read the contents of this file
Throws:
FileNotFoundException - if the file does not exists or is invalid

outputStream

protected OutputStream outputStream(String name)
                             throws IOException
Get output stream.
Parameters:
name - the file to test
Returns:
output stream to overwrite the contents of this file
Throws:
IOException - if an error occures (the file is invalid, etc.)

lock

protected void lock(String name)
             throws IOException
Does nothing.
Parameters:
name - name of the file

unlock

protected void unlock(String name)
Unlock the file. Does nothing.
Parameters:
name - name of the file

markUnimportant

protected void markUnimportant(String name)
Does nothing.
Parameters:
name - the file to mark

readAttribute

protected Object readAttribute(String name,
                               String attrName)
Get the file attribute with the specified name.
Parameters:
name - the file
attrName - name of the attribute
Returns:
appropriate (serializable) value or null if the attribute is unset (or could not be properly restored for some reason)

writeAttribute

protected void writeAttribute(String name,
                              String attrName,
                              Object value)
                       throws IOException
Set the file attribute with the specified name.
Parameters:
name - the file
attrName - name of the attribute
value - new value or null to clear the attribute. Must be serializable, although particular file systems may or may not use serialization to store attribute values.
Throws:
IOException - if the attribute cannot be set. If serialization is used to store it, this may in fact be a subclass such as NotSerializableException.

attributes

protected Enumeration attributes(String name)
Get all file attribute names for the file.
Parameters:
name - the file
Returns:
enumeration of keys (as strings)

renameAttributes

protected void renameAttributes(String oldName,
                                String newName)
Called when a file is renamed, to appropriatelly update its attributes.

Parameters:
oldName - old name of the file
newName - new name of the file

deleteAttributes

protected void deleteAttributes(String name)
Called when a file is deleted to also delete its attributes.
Parameters:
name - name of the file

finalize

protected void finalize()
                 throws Throwable
Close the jar file when we go away...
Overrides:
finalize in class Object


Built on February 22 2001.  |  Portions Copyright 1997-2000 Sun Microsystems, Inc. All rights reserved.