com.bbn.swede.core.libraries
Class LibraryEntry

java.lang.Object
  extended bycom.bbn.swede.core.libraries.LibraryEntry
All Implemented Interfaces:
ILibraryEntry

class LibraryEntry
extends Object
implements ILibraryEntry

This class implements the lower-level functionality related to a library entry.

This is not a public package, and is expected to be accessed only by Library, LibraryDescriptor and ILibraryEntryDescriptor.

For a more detailed explanation of Librarys, library entrys and how they relate, see Library.

Note that support for serialized IOWLAbstractSyntaxTrees is not yet implemented; it exists here to allow for better compatability when that support is added.

Author:
aperezlo
See Also:
Library

Constructor Summary
(package private) LibraryEntry(Library lib, File file, Properties props, IOWLAbstractSyntaxTree oast)
          This constructor is used to create a LibraryEntry from a file that exists on the filesystem, but not yet in a library.
(package private) LibraryEntry(Library lib, ZipEntry file, ZipEntry props, ZipEntry oast)
          This constructor is used to create a LibraryEntry from an already-existing library.
 
Method Summary
(package private)  boolean close()
          This method attempts to close all file handles and release all system resources held by this LibraryEntry.
 ILibraryEntryDescriptor createDescriptor()
          Retrieves the descriptor for this library entry.
(package private)  InputStream getFile()
          Attempts to return an InputStream to the file represented by this 'Entry.
(package private)  String getFilename()
          Retrieves the local filename of this entry.
(package private)  Library getLibrary()
          Retrieves the library that contains this entry.
(package private)  IOWLAbstractSyntaxTree getOAST()
          This method will return the OAST value for this 'Entry, rebuilding it from a serialized version on disk if neccessary.
(package private)  Properties getProperties()
          This method returns the Properties of this LibraryEntry, reading them from the library ZIP file if required.
(package private)  void setFile(File newFile)
          Set the file for this LibraryEntry.
(package private)  void setOAST(IOWLAbstractSyntaxTree newOAST)
          Note: This functionality does not yet work properly, and its behaviour is undefined.
(package private)  void setProperties(Properties props)
          Sets the properties of the library entry.
(package private)  void writeFile(OutputStream outstream)
          This method write this LibraryEntry's file to the outstream provided.
(package private)  void writeOAST(OutputStream outstream)
          Note: This functionality does not yet work properly, and its behaviour is undefined.
(package private)  void writeProperties(OutputStream outstream)
          This method uses the Properties.store(java.io.OutputStream, java.lang.String) method to write properties to an OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LibraryEntry

LibraryEntry(Library lib,
             ZipEntry file,
             ZipEntry props,
             ZipEntry oast)
This constructor is used to create a LibraryEntry from an already-existing library.

Parameters:
lib - the library to which this 'Entry will belong
file - the compressed file that this 'Entry represents
props - the compressed file that holds this 'Entry's properties
oast - the compressed file that holds the serialized version of the OAST

LibraryEntry

LibraryEntry(Library lib,
             File file,
             Properties props,
             IOWLAbstractSyntaxTree oast)
This constructor is used to create a LibraryEntry from a file that exists on the filesystem, but not yet in a library.

Parameters:
lib - the library to which this 'Entry will belong
file - the file, on disk, that this 'Entry represents
props - the properties, in memory, that describe this 'Entry's file
oast - the IOWLAbstractSyntaxTree to be serialized
Method Detail

getLibrary

Library getLibrary()
Retrieves the library that contains this entry.

Returns:
The containing library

getFilename

String getFilename()
Retrieves the local filename of this entry.

Returns:
the name of the file this 'Entry represents

getFile

InputStream getFile()
Attempts to return an InputStream to the file represented by this 'Entry. That stream could be to a file on disk, or to a compressed file within the library ZIP, depending on what type of 'Entry this is.
If neither of those locations are available for reading, then this method returns null

Returns:
a new InputStream to this 'Entry's file, or null
See Also:
InputStream

createDescriptor

public ILibraryEntryDescriptor createDescriptor()
Description copied from interface: ILibraryEntry
Retrieves the descriptor for this library entry.

Specified by:
createDescriptor in interface ILibraryEntry
Returns:
an ILibraryEntryDescriptor object which provides support for further operations upon this descriptor

setFile

void setFile(File newFile)
Set the file for this LibraryEntry.

Parameters:
newFile - the new file this 'Entry should represent

setProperties

void setProperties(Properties props)
Sets the properties of the library entry.

Parameters:
props - The new properties for the entry.

setOAST

void setOAST(IOWLAbstractSyntaxTree newOAST)
Note: This functionality does not yet work properly, and its behaviour is undefined.

Parameters:
newOAST - an OAST that this represents this 'Entry's file, or null

getOAST

IOWLAbstractSyntaxTree getOAST()
This method will return the OAST value for this 'Entry, rebuilding it from a serialized version on disk if neccessary.

Note: This functionality does not yet work properly, and its behaviour is undefined.

Returns:
the OAST that represents this 'Entry's file.

getProperties

Properties getProperties()
This method returns the Properties of this LibraryEntry, reading them from the library ZIP file if required.

Returns:
the Properties of this 'Entry's file
See Also:
Properties.load(java.io.InputStream)

close

boolean close()
This method attempts to close all file handles and release all system resources held by this LibraryEntry.

Returns:
true if the operation was successful, false otherwise

writeProperties

void writeProperties(OutputStream outstream)
This method uses the Properties.store(java.io.OutputStream, java.lang.String) method to write properties to an OutputStream. The stream is not closed as a result of an invokation of this method.

Parameters:
outstream - the stream to which this 'Entry's properties should be written
See Also:
Properties.store(java.io.OutputStream, java.lang.String)

writeFile

void writeFile(OutputStream outstream)
This method write this LibraryEntry's file to the outstream provided. This method does not close the OutputStream

Parameters:
outstream - the stream to which this 'Entry's file should be written

writeOAST

void writeOAST(OutputStream outstream)
Note: This functionality does not yet work properly, and its behaviour is undefined.

This method will not close the output stream.

Parameters:
outstream - the stream to which the OAST should be written


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.