|
Remote Systems v6.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.etools.systems.core.archiveutils.ArchiveHandlerManager
This class manages all the Archive Handlers that correspond to the archive file that the system would like to deal with. It contains methods for registering handlers with file types, as well as utilities for getting at the contents of archives that the Manager represents. This class is designed to be a singleton class, so the best way to use it is to use statements of the form "ArchiveHandlerManager.getInstance().method".
Field Summary | |
---|---|
protected HashMap |
_handlers
|
protected HashMap |
_handlerTypes
|
protected static ArchiveHandlerManager |
_instance
|
static String |
VIRTUAL_CANONICAL_SEPARATOR
|
static String |
VIRTUAL_SEPARATOR
|
Constructor Summary | |
---|---|
ArchiveHandlerManager()
|
Method Summary | |
---|---|
static String |
cleanUpVirtualPath(String fullVirtualName)
Converts the virtual path given by fullVirtualName
to the standard virtual form ('/' as separator, no leading or trailing '/'s) |
boolean |
createEmptyArchive(File newFile)
|
void |
dispose()
Disposes of all registered handlers. |
void |
disposeOfRegisteredHandlerFor(File file)
Removes the handler associated with file , freeing the file
to be used by other processes. |
String |
getClassification(File file,
String virtualPath)
Returns the classification for the entry in a archive with the given virtual path. |
String |
getComment(File archive)
|
VirtualChild[] |
getContents(File file,
String virtualpath)
Returns the children of an object in the virtual file system. |
long |
getExpandedSize(File archive)
|
protected String |
getExtension(File file)
|
protected String |
getExtension(String filename)
|
VirtualChild[] |
getFolderContents(File file,
String virtualpath)
Returns the children of an object in the virtual file system that are folders. |
static ArchiveHandlerManager |
getInstance()
|
Constructor |
getProperConstructor(Class handlerType)
|
String[] |
getRegisteredExtensions()
Returns the extensions for archive types that have been registered with the ArchiveHandlerManager. |
ISystemArchiveHandler |
getRegisteredHandler(File file)
Returns the registered handler for the File file . |
VirtualChild |
getVirtualObject(String fullyQualifiedName)
Given the absolute path to a virtual object, returns that object as a VirtualChild. |
protected boolean |
handlerHasProperConstructor(Class handlerType)
Returns whether or not handlerType has a constructor that takes only one parameter, a java.io.File. |
protected boolean |
handlerImplementsISystemArchiveHandler(Class handlerType)
Returns whether or not handlerType or one of its superclasses implements ISystemArchiveHandler. |
boolean |
isArchive(File file)
Tests whether a file is an known type of archive. |
boolean |
isRegisteredArchive(String filename)
Tests whether a file is an known type of archive, based on the file name. |
static boolean |
isVirtual(String path)
Tests whether the absolute path given by path
refers to a virtual object. |
boolean |
setRegisteredHandler(String ext,
Class handlerType)
Registers an extension and a handler type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String VIRTUAL_SEPARATOR
public static final String VIRTUAL_CANONICAL_SEPARATOR
protected static ArchiveHandlerManager _instance
protected HashMap _handlers
protected HashMap _handlerTypes
Constructor Detail |
public ArchiveHandlerManager()
Method Detail |
public static ArchiveHandlerManager getInstance()
public VirtualChild[] getContents(File file, String virtualpath) throws IOException
file
- The archive in whose virtual file system the children reside.virtualpath
- The parent virtual object whose children this method is to return. To
get the top level virtualchildren in the archive, set virtualpath to "" or null.
file
referred to by virtualpath
. If no class implementing
ISystemArchiveHandler can be found that corresponds to file, then this method returns null.
If the virtual object has no children, this method also returns null.
IOException
- if there was a problem getting the registered handler for the
file. This usually means the archive is corrupted.public VirtualChild[] getFolderContents(File file, String virtualpath)
file
- The archive in whose virtual file system the children reside.virtualpath
- The parent virtual object whose children this method is to return. To
get the top level virtualchildren in the archive, set virtualpath to "" or null.
file
referred to by virtualpath
that are themselves folders.
If no class implementing ISystemArchiveHandler can be found that corresponds to file, then
this method returns null. If the virtual object has no children, this method also returns null.public boolean isArchive(File file)
file
- the file to test.
public boolean isRegisteredArchive(String filename)
protected String getExtension(File file)
file
- the file whose extension we are computing.
file
. "Extension" is
defined as any letters in the filename after the last ".".
Returns "" if there is no extension.protected String getExtension(String filename)
filename
- the name of the file whose extension we are computing.
filename
. "Extension" is
defined as any letters in the filename after the last ".".
Returns "" if there is no extension.public VirtualChild getVirtualObject(String fullyQualifiedName)
fullyQualifiedName
- The absolute path to the object. Usually consists
of the fullyQualifiedName of the archive, followed by the virtual path separator
(defined in ArchiveHandlerManager.VIRTUAL_SEPARATOR) followed by the virtual path to
the object within the archive's virtual file system.public ISystemArchiveHandler getRegisteredHandler(File file)
file
. If
no handler exists for that file yet, create it. If the extension of
file
is not registered, then returns null.
public Constructor getProperConstructor(Class handlerType)
public boolean setRegisteredHandler(String ext, Class handlerType)
ext
- The extension to register with the ArchiveHandlerManagerhandlerType
- The class of handler to register with ext
.
Note that any class passed in must implement ISystemArchiveHandler.
protected boolean handlerHasProperConstructor(Class handlerType)
protected boolean handlerImplementsISystemArchiveHandler(Class handlerType)
public void disposeOfRegisteredHandlerFor(File file)
file
, freeing the file
to be used by other processes.
public static boolean isVirtual(String path)
path
refers to a virtual object.
path
-
public static String cleanUpVirtualPath(String fullVirtualName)
fullVirtualName
to the standard virtual form ('/' as separator, no leading or trailing '/'s)
fullVirtualName
- the path to convert
public void dispose()
public boolean createEmptyArchive(File newFile)
public String[] getRegisteredExtensions()
public String getComment(File archive)
public long getExpandedSize(File archive)
public String getClassification(File file, String virtualPath)
file
- the archive file.virtualPath
- the virtual path.
|
Remote Systems v6.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |