Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.services.clientserver.archiveutils
Class ArchiveHandlerManager


java.lang.Object
  extended by 
org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager

public class ArchiveHandlerManager
extends Object

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

VIRTUAL_SEPARATOR

public static final 
String VIRTUAL_SEPARATOR
The string that separates the virtual part of an absolute path from the real part.

See Also:
Constant Field Values

VIRTUAL_CANONICAL_SEPARATOR

public static final 
String VIRTUAL_CANONICAL_SEPARATOR
See Also:
Constant Field Values

VIRTUAL_FOLDER_SEPARATOR

public static final 
String VIRTUAL_FOLDER_SEPARATOR
Folder separator used in virtual paths inside the archive, i.e. after the VIRTUAL_SEPARATOR.

Since:
org.eclipse.rse.services 3.0
See Also:
Constant Field Values

EXTENSION_SEPARATOR

public static final 
String EXTENSION_SEPARATOR
Character used to separate file extension from file name. This is used in order to recognize file patterns that should be treated as archives.

Since:
org.eclipse.rse.services 3.0
See Also:
Constant Field Values

_instance

protected static 
ArchiveHandlerManager _instance

_handlers

protected 
HashMap _handlers

_handlerTypes

protected 
HashMap _handlerTypes
Constructor Detail

ArchiveHandlerManager

public ArchiveHandlerManager()
Method Detail

getInstance

public static 
ArchiveHandlerManager getInstance()
Returns:
The singleton instance of this class.

getContents

public 
VirtualChild[] getContents(
File file,
                                  
String virtualpath)
                           throws 
SystemMessageException
Returns the children of an object in the virtual file system. Throws SystemMessageException instead of IOException since RSE 3.0.

Parameters:
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.
Returns:
An array of VirtualChild objects representing the children of the virtual object in 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.
Throws:
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.
Since:
3.0

getFolderContents

public 
VirtualChild[] getFolderContents(
File file,
                                        
String virtualpath)
                                 throws 
SystemMessageException
Returns the children of an object in the virtual file system that are folders.

Parameters:
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.
Returns:
An array of VirtualChild objects representing the children of the virtual object in 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.
Throws:
SystemMessageException - in case of an error
Since:
3.0

isArchive

public boolean isArchive(
File file)
Tests whether a file is an known type of archive.

Parameters:
file - the file to test.
Returns:
true if and only if the file is an archive whose type is registered with the ArchiveHandlerManager.

isRegisteredArchive

public boolean isRegisteredArchive(
String filename)
Tests whether a file is an known type of archive, based on the file name.

Parameters:
filename - the name of the file to test.
Returns:
true if and only if the file is an archive whose type is registered with the ArchiveHandlerManager.

getRegisteredExtension

protected 
String getRegisteredExtension(
File file)
Check if the file extension is registered archive type. notice here, the getExtension method does't work for name like fool.tar.gz

Parameters:
file - the file to check
Returns:
registered extension or null
Since:
org.eclipse.rse.services 3.0

getRegisteredExtension

protected 
String getRegisteredExtension(
String fileName)
check if the file extension is registered archive type.

Parameters:
fileName - the file name to check
Returns:
registered extension or null
Since:
org.eclipse.rse.services 3.0

getExtension

protected 
String getExtension(
File file)
Deprecated. Use getRegisteredExtension(File) instead

Parameters:
file - the file whose extension we are computing.
Returns:
the extension of file. "Extension" is defined as any letters in the filename after the last ".". Returns "" if there is no extension.

getExtension

protected 
String getExtension(
String filename)
Parameters:
filename - the name of the file whose extension we are computing.
Returns:
the extension of filename. "Extension" is defined as any letters in the filename after the last ".". Returns "" if there is no extension. * @deprecated Use getRegisteredExtension(String) instead

getVirtualObject

public 
VirtualChild getVirtualObject(
String fullyQualifiedName)
                              throws 
SystemMessageException
Given the absolute path to a virtual object, returns that object as a VirtualChild.

Parameters:
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.
Throws:
SystemMessageException - in case of an error
Since:
3.0

getRegisteredHandler

public 
ISystemArchiveHandler getRegisteredHandler(
File file)
                                           throws 
SystemMessageException
Returns the registered handler for the File file. If no handler exists for that file yet, create it. If the extension of file is not registered, then returns null.

Throws:
SystemMessageException - in case of an error instantiating the handler
Since:
3.0

getProperConstructor

public 
Constructor getProperConstructor(
Class handlerType)

setRegisteredHandler

public boolean setRegisteredHandler(
String ext,
                                    
Class handlerType)
Registers an extension and a handler type.

Parameters:
ext - The extension to register with the ArchiveHandlerManager
handlerType - The class of handler to register with ext. Note that any class passed in must implement ISystemArchiveHandler.
Returns:
Whether or not the registration was successful.

handlerHasProperConstructor

protected boolean handlerHasProperConstructor(
Class handlerType)
Returns whether or not handlerType has a constructor that takes only one parameter, a java.io.File.


handlerImplementsISystemArchiveHandler

protected boolean handlerImplementsISystemArchiveHandler(
Class handlerType)
Returns whether or not handlerType or one of its superclasses implements ISystemArchiveHandler.


disposeOfRegisteredHandlerFor

public void disposeOfRegisteredHandlerFor(
File file)
Removes the handler associated with file, freeing the file to be used by other processes.


isVirtual

public static boolean isVirtual(
String path)
Tests whether the absolute path given by path refers to a virtual object.

Parameters:
path - an absolute path string to check
Returns:
True if and only if the absolute path refers to a virtual object.

cleanUpVirtualPath

public static 
String cleanUpVirtualPath(
String fullVirtualName)
Converts the virtual path given by fullVirtualName to the standard virtual form ('/' as separator, no leading or trailing '/'s)

Parameters:
fullVirtualName - the path to convert
Returns:
the new path in standard form

dispose

public void dispose()
Disposes of all registered handlers.


createEmptyArchive

public void createEmptyArchive(
File newFile)
                        throws 
SystemMessageException
Create an empty archive

Throws:
SystemMessageException - in case of an error
Since:
3.0 returns void but throws SystemMessageException

getRegisteredExtensions

public 
String[] getRegisteredExtensions()
Returns the extensions for archive types that have been registered with the ArchiveHandlerManager.


getComment

public 
String getComment(
File archive)
                  throws 
SystemMessageException
Get archive comment.

Throws:
SystemMessageException - in case of an error
Since:
3.0

getExpandedSize

public long getExpandedSize(
File archive)
                     throws 
SystemMessageException
Get total expanded size of an archive.

Throws:
SystemMessageException - in case of an error
Since:
3.0

getClassification

public 
String getClassification(
File file,
                                
String virtualPath)
                         throws 
SystemMessageException
Returns the classification for the entry in a archive with the given virtual path.

Parameters:
file - the archive file.
virtualPath - the virtual path.
Returns:
the classification for the virtual file.
Throws:
SystemMessageException - in case of an error

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire