org.ow2.util.archive.impl
Class DirectoryArchiveImpl

java.lang.Object
  extended by org.ow2.util.archive.impl.AbsArchiveImpl
      extended by org.ow2.util.archive.impl.DirectoryArchiveImpl
All Implemented Interfaces:
IArchive

public class DirectoryArchiveImpl
extends AbsArchiveImpl
implements IArchive

Creates wrapper around directory.

Author:
Florent Benoit

Constructor Summary
protected DirectoryArchiveImpl(File directory)
          Creates new instance of an IArchive for a directory.
 
Method Summary
 boolean close()
          Close the underlying Resource.
 boolean equals(Object o)
          Is that the given object is equals to our instance.
 Iterator<String> getEntries()
           
 IArchiveMetadata getMetadata()
           
 String getName()
           
 URL getResource(String resourceName)
           
 Iterator<URL> getResources()
           
 Iterator<URL> getResources(String resourceName)
           
 URL getURL()
           
 int hashCode()
          Gets hashcode for this object.
protected  void initMetadata()
          Init metadata by reading the Manifest file.
 String toString()
           
 
Methods inherited from class org.ow2.util.archive.impl.AbsArchiveImpl
readManifest
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryArchiveImpl

protected DirectoryArchiveImpl(File directory)
Creates new instance of an IArchive for a directory.

Parameters:
directory - the given directory.
Method Detail

getName

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

getMetadata

public IArchiveMetadata getMetadata()
Specified by:
getMetadata in interface IArchive
Overrides:
getMetadata in class AbsArchiveImpl
Returns:
the Metadata associated to this archive.

initMetadata

protected void initMetadata()
                     throws ArchiveException
Init metadata by reading the Manifest file.

Throws:
ArchiveException - if metadata are not initialized

close

public boolean close()
Close the underlying Resource.

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

getResource

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

getResources

public Iterator<URL> getResources()
                           throws ArchiveException
Specified by:
getResources in interface IArchive
Returns:
Returns an Iterator of Resource's URL.
Throws:
ArchiveException - if method fails.

getResources

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

getURL

public URL getURL()
           throws ArchiveException
Specified by:
getURL in interface IArchive
Returns:
Returns the resource URL.
Throws:
ArchiveException - if method fails.

equals

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

Overrides:
equals in class 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 Object
Returns:
hash code.

toString

public String toString()
Overrides:
toString in class AbsArchiveImpl
Returns:
string representation

getEntries

public Iterator<String> getEntries()
Specified by:
getEntries in interface IArchive
Returns:
all resources name


Copyright © 2007-2012 OW2 Consortium. All Rights Reserved.