com.japisoft.zipbrowser
Class ZIPResourceManager

java.lang.Object
  |
  +--com.japisoft.zipbrowser.ZIPResourceManager
All Implemented Interfaces:
ResourceManager

public class ZIPResourceManager
extends java.lang.Object
implements ResourceManager

This is a manager for ZIP or JAR archive.

Version:
1.0
Author:
(c) 2004 JAPISoft / http://www.japisoft.com
See Also:
ResourceManager

Constructor Summary
ZIPResourceManager(java.io.File file)
           
 
Method Summary
 void deleteFile(ResourceItem item)
          Delete a file or an empty directory for this path
 byte[] getContent(ResourceItem item)
           
 boolean isConnectionSupported()
           
 boolean isLockSupported()
           
 ResourceItemModel list(ResourceItem item)
          List a directory
 void lock(ResourceItem item, boolean locked)
          Lock this resource located at the path.
 void renameFile(ResourceItem item, java.lang.String newPathName)
          Rename a file name to another one.
 void setContent(ResourceItem item, byte[] content)
          Reset a content located at this path
 java.lang.String start(java.lang.String host, java.lang.String user, java.lang.String password)
          Open a connection to a server or a specific resource.
 void stop()
          Close the current connection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZIPResourceManager

public ZIPResourceManager(java.io.File file)
Method Detail

start

public java.lang.String start(java.lang.String host,
                              java.lang.String user,
                              java.lang.String password)
                       throws ResourceException
Description copied from interface: ResourceManager
Open a connection to a server or a specific resource.

Specified by:
start in interface ResourceManager
Parameters:
host - The Remote server IP location
user - The user account name
password - The user password name
Returns:
The root directory for sample '/'
Throws:
ResourceException - If the connection cannot be opened

stop

public void stop()
Description copied from interface: ResourceManager
Close the current connection

Specified by:
stop in interface ResourceManager

list

public ResourceItemModel list(ResourceItem item)
                       throws ResourceException
Description copied from interface: ResourceManager
List a directory

Specified by:
list in interface ResourceManager
Parameters:
item - A directory
Returns:
a set of ResourceItem inside the ResourceModel
Throws:
ResourceException - If the listing is not possible

getContent

public byte[] getContent(ResourceItem item)
                  throws ResourceException
Specified by:
getContent in interface ResourceManager
Parameters:
item - A location for a file
Returns:
The content of the file located at the path. You may have to specify an encoding like UTF8 for converting it to a java.lang.String
Throws:
ResourceException - If the file cannot be downloaded

setContent

public void setContent(ResourceItem item,
                       byte[] content)
                throws ResourceException
Description copied from interface: ResourceManager
Reset a content located at this path

Specified by:
setContent in interface ResourceManager
Parameters:
item - A file location
content - A new content
Throws:
ResourceException - If the file cannot be updated

deleteFile

public void deleteFile(ResourceItem item)
                throws ResourceException
Description copied from interface: ResourceManager
Delete a file or an empty directory for this path

Specified by:
deleteFile in interface ResourceManager
Parameters:
item - A file or an empty directory location
Throws:
ResourceException - If the file cannot be deleted

renameFile

public void renameFile(ResourceItem item,
                       java.lang.String newPathName)
                throws ResourceException
Description copied from interface: ResourceManager
Rename a file name to another one. Note you must use the specific name syntax

Specified by:
renameFile in interface ResourceManager
Parameters:
item - A file or a directory
newPathName - A new name
Throws:
ResourceException - If the file or the directory cannot be renammed

lock

public void lock(ResourceItem item,
                 boolean locked)
          throws ResourceException
Description copied from interface: ResourceManager
Lock this resource located at the path. This method will have only effect if the isLockSupported method returns true

Specified by:
lock in interface ResourceManager
Parameters:
item - A file or a directory
locked - true for locking the resource path
Throws:
ResourceException - If the file cannot be locked

isLockSupported

public boolean isLockSupported()
Specified by:
isLockSupported in interface ResourceManager
Returns:
true if the file lock if supported

isConnectionSupported

public boolean isConnectionSupported()
Specified by:
isConnectionSupported in interface ResourceManager
Returns:
if an host, user and password is required before browing a content