org.apache.felix.framework.cache
Class DirectoryContent

java.lang.Object
  extended by org.apache.felix.framework.cache.DirectoryContent
All Implemented Interfaces:
IContent

public class DirectoryContent
extends Object
implements IContent


Constructor Summary
DirectoryContent(Logger logger, Object revisionLock, File rootDir, File dir)
           
 
Method Summary
 void close()
           This method must be called when the content is no longer needed so that any resourses being used (e.g., open files) can be closed.
 Enumeration getEntries()
           Returns an enumeration of entry names as String objects.
 byte[] getEntryAsBytes(String name)
           This method returns the named entry as an array of bytes.
 IContent getEntryAsContent(String entryName)
           This method returns the named entry as an IContent Typically, this method only makes sense for entries that correspond to some form of aggregated resource (e.g., an embedded JAR file or directory), but implementations are free to interpret this however makes sense.
 String getEntryAsNativeLibrary(String name)
           This method returns the named entry as a file in the file system for use as a native library.
 InputStream getEntryAsStream(String name)
           This method returns the named entry as an input stream.
 boolean hasEntry(String name)
           This method determines if the specified named entry is contained in the associated content.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryContent

public DirectoryContent(Logger logger,
                        Object revisionLock,
                        File rootDir,
                        File dir)
Method Detail

close

public void close()
Description copied from interface: IContent

This method must be called when the content is no longer needed so that any resourses being used (e.g., open files) can be closed. Once this method is called, the content is no longer usable. If the content is already closed, then calls on this method should have no effect.

Specified by:
close in interface IContent

hasEntry

public boolean hasEntry(String name)
                 throws IllegalStateException
Description copied from interface: IContent

This method determines if the specified named entry is contained in the associated content. The entry name is a relative path with '/' separators.

Specified by:
hasEntry in interface IContent
Parameters:
name - The name of the entry to find.
Returns:
true if a corresponding entry was found, false otherwise.
Throws:
IllegalStateException

getEntries

public Enumeration getEntries()
Description copied from interface: IContent

Returns an enumeration of entry names as String objects. An entry name is a path constructed with '/' as path element separators and is relative to the root of the content. Entry names for entries that represent directories should end with the '/' character.

Specified by:
getEntries in interface IContent

getEntryAsBytes

public byte[] getEntryAsBytes(String name)
                       throws IllegalStateException
Description copied from interface: IContent

This method returns the named entry as an array of bytes.

Specified by:
getEntryAsBytes in interface IContent
Parameters:
name - The name of the entry to retrieve as a byte array.
Returns:
An array of bytes if the corresponding entry was found, null otherwise.
Throws:
IllegalStateException

getEntryAsStream

public InputStream getEntryAsStream(String name)
                             throws IllegalStateException,
                                    IOException
Description copied from interface: IContent

This method returns the named entry as an input stream.

Specified by:
getEntryAsStream in interface IContent
Parameters:
name - The name of the entry to retrieve as an input stream.
Returns:
An input stream if the corresponding entry was found, null otherwise.
Throws:
IllegalStateException
IOException

getEntryAsContent

public IContent getEntryAsContent(String entryName)
Description copied from interface: IContent

This method returns the named entry as an IContent Typically, this method only makes sense for entries that correspond to some form of aggregated resource (e.g., an embedded JAR file or directory), but implementations are free to interpret this however makes sense. This method should return a new IContent instance for every invocation and the caller is responsible for opening and closing the returned content object.

Specified by:
getEntryAsContent in interface IContent
Parameters:
entryName - The name of the entry to retrieve as an IContent.
Returns:
An IContent instance if a corresponding entry was found, null otherwise.

getEntryAsNativeLibrary

public String getEntryAsNativeLibrary(String name)
Description copied from interface: IContent

This method returns the named entry as a file in the file system for use as a native library. It may not be possible for all content implementations (e.g., memory only) to implement this method, in which case it is acceptable to return null.

Specified by:
getEntryAsNativeLibrary in interface IContent
Parameters:
name - The name of the entry to retrieve as a file.
Returns:
A string corresponding to the absolute path of the file if a corresponding entry was found, null otherwise.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.