org.objectweb.easybeans.container.archive
Class EZBDirectoryArchiveImpl

java.lang.Object
  extended by org.objectweb.easybeans.container.archive.EZBDirectoryArchiveImpl
All Implemented Interfaces:
EZBArchive

public class EZBDirectoryArchiveImpl
extends java.lang.Object
implements EZBArchive

Creates wrapper around directory.

Author:
Florent Benoit

Field Summary
private  java.io.File directory
          Internal resource used as archive.
 
Constructor Summary
protected EZBDirectoryArchiveImpl(java.io.File directory)
          Creates new instance of an EZBArchive for a directory.
 
Method Summary
private  void addFiles(java.io.File file, java.util.List<java.net.URL> listResources)
          Methods that loop on directories to find the children (files).
 boolean close()
          Close the underlying Resource.
private  java.lang.String encode(java.lang.String resourceName)
          Encode resource name to be used on Unix/Windows systems.
 boolean equals(java.lang.Object o)
          Is that the given object is equals to our instance.
 java.lang.String getName()
           
 java.net.URL getResource(java.lang.String resourceName)
           
 java.util.Iterator<java.net.URL> getResources()
           
 java.util.Iterator<java.net.URL> getResources(java.lang.String resourceName)
           
 java.net.URL getURL()
           
 int hashCode()
          Gets hashcode for this object.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

directory

private java.io.File directory
Internal resource used as archive.

Constructor Detail

EZBDirectoryArchiveImpl

protected EZBDirectoryArchiveImpl(java.io.File directory)
Creates new instance of an EZBArchive for a directory.

Parameters:
directory - the given directory.
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface EZBArchive
Returns:
a description of this archive. This name could be used in logger info.

encode

private java.lang.String encode(java.lang.String resourceName)
Encode resource name to be used on Unix/Windows systems.

Parameters:
resourceName - the name to encode.
Returns:
the encoded name.

close

public boolean close()
Close the underlying Resource.

Specified by:
close in interface EZBArchive
Returns:
Returns true if the close was succesful, false otherwise.

getResource

public java.net.URL getResource(java.lang.String resourceName)
                         throws EZBArchiveException
Specified by:
getResource in interface EZBArchive
Parameters:
resourceName - The resource name to be looked up.
Returns:
Returns the resource URL if the resource has been found. null otherwise.
Throws:
EZBArchiveException - if method fails.

getResources

public java.util.Iterator<java.net.URL> getResources()
                                              throws EZBArchiveException
Specified by:
getResources in interface EZBArchive
Returns:
Returns an Iterator of Resource's URL.
Throws:
EZBArchiveException - if method fails.

addFiles

private void addFiles(java.io.File file,
                      java.util.List<java.net.URL> listResources)
Methods that loop on directories to find the children (files).

Parameters:
file - the given directory/file.
listResources - the list on which to add new files.

getResources

public java.util.Iterator<java.net.URL> getResources(java.lang.String resourceName)
                                              throws EZBArchiveException
Specified by:
getResources in interface EZBArchive
Parameters:
resourceName - The resource name to be looked up.
Returns:
Returns an Iterator of matching resources.
Throws:
EZBArchiveException - if method fails.

getURL

public java.net.URL getURL()
                    throws EZBArchiveException
Specified by:
getURL in interface EZBArchive
Returns:
Returns the resource URL.
Throws:
EZBArchiveException - if method fails.

equals

public boolean equals(java.lang.Object o)
Is that the given object is equals to our instance.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare.
Returns:
true if equals, else false.

hashCode

public int hashCode()
Gets hashcode for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
string representation