|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager
public class 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 |
EXTENSION_SEPARATOR
Character used to separate file extension from file name. |
static String |
VIRTUAL_CANONICAL_SEPARATOR
|
static String |
VIRTUAL_FOLDER_SEPARATOR
Folder separator used in virtual paths inside the archive, i.e. after the VIRTUAL_SEPARATOR. |
static String |
VIRTUAL_SEPARATOR
The string that separates the virtual part of an absolute path from the real part. |
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) |
void |
createEmptyArchive(File newFile)
Create an empty archive |
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)
Get archive comment. |
VirtualChild[] |
getContents(File file,
String virtualpath)
Returns the children of an object in the virtual file system. |
long |
getExpandedSize(File archive)
Get total expanded size of an archive. |
protected String |
getExtension(File file)
Deprecated. Use getRegisteredExtension(File) instead |
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)
|
protected String |
getRegisteredExtension(File file)
Check if the file extension is registered archive type. |
protected String |
getRegisteredExtension(String fileName)
check if the file extension is registered archive type. |
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
public static final String VIRTUAL_FOLDER_SEPARATOR
public static final String EXTENSION_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 SystemMessageException
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 virtual children in the archive,
set virtual path to "" or null.
file
referred to by
virtual path
. 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.
SystemMessageException
- in case of an error, e.g. 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) throws SystemMessageException
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 virtual children in the archive,
set virtual path 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.
SystemMessageException
- in case of an errorpublic boolean isArchive(File file)
file
- the file to test.
public boolean isRegisteredArchive(String filename)
filename
- the name of the file to test.
protected String getRegisteredExtension(File file)
file
- the file to check
protected String getRegisteredExtension(String fileName)
fileName
- the file name to check
protected String getExtension(File file)
getRegisteredExtension(File)
instead
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.
* @deprecated Use getRegisteredExtension(String)
insteadpublic VirtualChild getVirtualObject(String fullyQualifiedName) throws SystemMessageException
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.
SystemMessageException
- in case of an errorpublic ISystemArchiveHandler getRegisteredHandler(File file) throws SystemMessageException
file
. If no
handler exists for that file yet, create it. If the extension of
file
is not registered, then returns null.
SystemMessageException
- in case of an error instantiating the
handlerpublic 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
- an absolute path string to check
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 void createEmptyArchive(File newFile) throws SystemMessageException
SystemMessageException
- in case of an errorpublic String[] getRegisteredExtensions()
public String getComment(File archive) throws SystemMessageException
SystemMessageException
- in case of an errorpublic long getExpandedSize(File archive) throws SystemMessageException
SystemMessageException
- in case of an errorpublic String getClassification(File file, String virtualPath) throws SystemMessageException
file
- the archive file.virtualPath
- the virtual path.
SystemMessageException
- in case of an error
|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |