com.bbn.swede.core.libraries
Class LibraryDescriptor

java.lang.Object
  extended bycom.bbn.swede.core.libraries.LibraryDescriptor
All Implemented Interfaces:
ILibraryDescriptor

public class LibraryDescriptor
extends Object
implements ILibraryDescriptor

The main interface for client code to manipulate libraries. This class serves in some capacity as a wrapper around the underlying library, and an abstraction from it. LibraryDescriptors are intended to be created only by a call to Library.createDescriptor().

Author:
aperezlo

Field Summary
(package private) static String FILE_EXTENSION
          File extension for entry metadata file.
(package private) static String FILE_PATH
          Path for library entries.
(package private) static String METADATA_EXTENSION
          File extension for library metadata file.
(package private) static String METADATA_PATH
          Path for library metadata.
(package private) static String OAST_EXTENSION
          File extension for serialized OWL abstract syntax trees.
(package private) static String OAST_PATH
          Path for serialized OWL abstract syntax trees.
 
Constructor Summary
(package private) LibraryDescriptor(Library library)
          Create a new LibraryDescriptor.
 
Method Summary
 void addEntry(ILibraryEntryDescriptor newOne)
          Add a new entry to this library descriptor's library.
 void addLibraryChangeListener(ILibraryChangeListener lcl)
          Registers an object for notifications of changes to this library.
 boolean close()
          Releases any system resources associated with the ILibrary that are held by this ILibraryDescriptor.
 boolean contains(String fileName)
          Checks whether this library contains a particular file.
 boolean containsURI(String sUri)
          Checks whether this library contains a file with a particular base URI.
 ILibraryEntryDescriptor createEntry(File file, Properties props, IOWLAbstractSyntaxTree oast)
          This method will create a new ILibraryEntry and add it to this object's ILibrary, and return the descriptor associated with the 'Entry.
 void delete()
          Called when a library is deleted.
 IStatus edit(LibraryEdit edit, IProgressMonitor progress)
          Performs an edit operation, encapsulated in the LibraryEdit object upon this library and its descriptor.
 boolean equals(Object arg0)
          Compares library descriptors for equality.
 IStatus export(IPath exportPath, ILibraryEntryDescriptor iled, IProgressMonitor monitor)
          This method provides a way to export an entry of a library to a particular directory, represented by the exportPath parameter.
 IConfiguration getConfiguration()
          Retrieves the configuration object for this descriptor.
 ILibraryEntryDescriptor getDescriptorFor(String fileName)
          Retrieves the entry descriptor for a particular file within the library.
 ILibraryEntryDescriptor getDescriptorForURI(String sUri)
          Retrieves the entry descriptor for a particular URI within this library.
 List getEntryDescriptors()
          Retrieves the descriptors for all entries in this library.
 ILibrary getLibrary()
          Retrieves the ILibrary with which this descriptor is associated.
 String getName()
          This method is unsynchronized, whereas getConfiguration() is.
 IConfigurationValidator getPropertiesValidator()
          Retrieves a configuration validator for this library's properties.
 boolean isAvailable()
          Returns true if this library is available for operations, and false otherwise.
 boolean open()
          Attempts to reserve system resources required for the proper operation of this ILibraryDescriptor's library.
 IStatus refresh(IProgressMonitor progress)
          This implementation of the interface encapsulates refresh operations in terms of a LibraryEdit object, and calls edit(LibraryEdit, IProgressMonitor).
 void removeEntry(ILibraryEntryDescriptor toRemove)
          Removes a library entry from this library.
 void removeLibraryChangeListener(ILibraryChangeListener lcl)
          Unregisters an object from notifications of changes to this library.
 void setLibrary(Library l)
          Associates this descriptor with a new library.
 void writeLibrary()
          Writes the library to disk in the default library location.
 void writeLibrary(String path)
          Writes the library to disk in the specified path.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OAST_EXTENSION

static final String OAST_EXTENSION
File extension for serialized OWL abstract syntax trees.

See Also:
Constant Field Values

METADATA_EXTENSION

static final String METADATA_EXTENSION
File extension for library metadata file.

See Also:
Constant Field Values

FILE_EXTENSION

static final String FILE_EXTENSION
File extension for entry metadata file.

See Also:
Constant Field Values

FILE_PATH

static final String FILE_PATH
Path for library entries.

See Also:
Constant Field Values

METADATA_PATH

static final String METADATA_PATH
Path for library metadata.

See Also:
Constant Field Values

OAST_PATH

static final String OAST_PATH
Path for serialized OWL abstract syntax trees.

See Also:
Constant Field Values
Constructor Detail

LibraryDescriptor

LibraryDescriptor(Library library)
Create a new LibraryDescriptor.

Parameters:
library - the library for which this object is a descriptor
Method Detail

isAvailable

public boolean isAvailable()
Description copied from interface: ILibraryDescriptor
Returns true if this library is available for operations, and false otherwise. Some examples of times when a library would be unavailable for operations include if the library is currently in the process of being written to disk, or if the library is being refreshed.

Specified by:
isAvailable in interface ILibraryDescriptor
Returns:
true if this library is available for operations, false otherwise

export

public IStatus export(IPath exportPath,
                      ILibraryEntryDescriptor iled,
                      IProgressMonitor monitor)
Description copied from interface: ILibraryDescriptor
This method provides a way to export an entry of a library to a particular directory, represented by the exportPath parameter. The iled represents the entry of the library that should be exported, optionally with the entry's associated metadata.

Specified by:
export in interface ILibraryDescriptor
Parameters:
exportPath - the path to which the desired entry should be exported
iled - the entry to be exported
monitor - an object which should be notified of the progress of this operation
Returns:
IStatus.OK if the operation was a success, IStatus.CANCEL if it was canceled, IStatus.ERROR otherwise.

addLibraryChangeListener

public void addLibraryChangeListener(ILibraryChangeListener lcl)
Description copied from interface: ILibraryDescriptor
Registers an object for notifications of changes to this library.

Specified by:
addLibraryChangeListener in interface ILibraryDescriptor
Parameters:
lcl - The listener to register. If lcl is already registered as a change listener for this library, this method has no effect.

removeLibraryChangeListener

public void removeLibraryChangeListener(ILibraryChangeListener lcl)
Description copied from interface: ILibraryDescriptor
Unregisters an object from notifications of changes to this library.

Specified by:
removeLibraryChangeListener in interface ILibraryDescriptor
Parameters:
lcl - The listener to unregister. If lcl is not registered as a change listener for this library, this method has no effect.

getConfiguration

public IConfiguration getConfiguration()
Description copied from interface: ILibraryDescriptor
Retrieves the configuration object for this descriptor.

Specified by:
getConfiguration in interface ILibraryDescriptor
Returns:
this descriptor's IConfiguration object.

delete

public void delete()
Description copied from interface: ILibraryDescriptor
Called when a library is deleted.

Specified by:
delete in interface ILibraryDescriptor

getName

public String getName()
This method is unsynchronized, whereas getConfiguration() is. This method will return the name of the library, even if it is being refreshed. Returns the name of this library. This call is exactly equivalent to the following snippet:
 _configuration.getName();
 

Specified by:
getName in interface ILibraryDescriptor
Returns:
the name of this library

writeLibrary

public void writeLibrary(String path)
Description copied from interface: ILibraryDescriptor
Writes the library to disk in the specified path.

Specified by:
writeLibrary in interface ILibraryDescriptor
Parameters:
path - a String representing a location on disk

writeLibrary

public void writeLibrary()
Description copied from interface: ILibraryDescriptor
Writes the library to disk in the default library location.

Specified by:
writeLibrary in interface ILibraryDescriptor

refresh

public IStatus refresh(IProgressMonitor progress)
This implementation of the interface encapsulates refresh operations in terms of a LibraryEdit object, and calls edit(LibraryEdit, IProgressMonitor).

This operation supports cancelation.

Specified by:
refresh in interface ILibraryDescriptor
Parameters:
progress - a progress monitor
Returns:
an IStatus object representing the result of the refresh operation attempt
See Also:
com.bbn.swede.core.libraries.ILibraryDescriptor#refresh(org.eclipse.core.runtime.IProgressMonitor)

edit

public IStatus edit(LibraryEdit edit,
                    IProgressMonitor progress)
Performs an edit operation, encapsulated in the LibraryEdit object upon this library and its descriptor.

Here is what actually happens - first, the library becomes unavailable for further operations, as ascertainable by a call to isAvailable(). Next, the files of this descriptor's library are unzipped into a location determined by a call to Libraries.getLibraryEditPath(String). Then edits are performed, first additions and deletions, then configurations. Finally the library is rebuilt from that directory, and if there were no errors, it is used as a replacement for the original library.

This operation supports cancelation.

Specified by:
edit in interface ILibraryDescriptor
Parameters:
edit - the edit operation
progress - an object to be notified of the progress of this operation
Returns:
IStatus.OK if the operation was a success, IStatus.CANCEL if it was canceled, or IStatus.ERROR otherwise
See Also:
com.bbn.swede.core.libraries.ILibraryDescriptor#edit( com.bbn.swede.core.libraries.LibraryEdit, org.eclipse.core.runtime.IProgressMonitor)

setLibrary

public void setLibrary(Library l)
Description copied from interface: ILibraryDescriptor
Associates this descriptor with a new library.

Specified by:
setLibrary in interface ILibraryDescriptor
Parameters:
l - the new library

close

public boolean close()
Description copied from interface: ILibraryDescriptor
Releases any system resources associated with the ILibrary that are held by this ILibraryDescriptor.

Specified by:
close in interface ILibraryDescriptor
Returns:
true if there were no exceptions generated during this operation, false otherwise

getPropertiesValidator

public IConfigurationValidator getPropertiesValidator()
Retrieves a configuration validator for this library's properties.

Returns:
an instance of IConfigurationValidator capable of validating the properties of this library

createEntry

public ILibraryEntryDescriptor createEntry(File file,
                                           Properties props,
                                           IOWLAbstractSyntaxTree oast)
Description copied from interface: ILibraryDescriptor
This method will create a new ILibraryEntry and add it to this object's ILibrary, and return the descriptor associated with the 'Entry.

Specified by:
createEntry in interface ILibraryDescriptor
Parameters:
file - the file representing the document to be added to the library
props - a set of properties holding metadata about the file
oast - a serialized version of the IOWLAbstractSyntaxTree associated with this ontology, or null
Returns:
a ILibraryEntryDescriptor that is associated witht the entry just created

open

public boolean open()
Description copied from interface: ILibraryDescriptor
Attempts to reserve system resources required for the proper operation of this ILibraryDescriptor's library.

Specified by:
open in interface ILibraryDescriptor
Returns:
true if the library was successfully opened, false otherwise

equals

public boolean equals(Object arg0)
Compares library descriptors for equality. Two LibraryDescriptors are considered to be equal iff:

See Also:
Object.equals(java.lang.Object)

addEntry

public void addEntry(ILibraryEntryDescriptor newOne)
Description copied from interface: ILibraryDescriptor
Add a new entry to this library descriptor's library. This is a temporary add and will not be permanent until the library is written to disk using either ILibraryDescriptor.writeLibrary() or ILibraryDescriptor.writeLibrary(String).

Specified by:
addEntry in interface ILibraryDescriptor
Parameters:
newOne - the ILibraryEntryDescriptor representing the entry to be added to this library descriptor's library

removeEntry

public void removeEntry(ILibraryEntryDescriptor toRemove)
Description copied from interface: ILibraryDescriptor
Removes a library entry from this library. This change is not permanent until the library is written to disk using either ILibraryDescriptor.writeLibrary() or ILibraryDescriptor.writeLibrary(String).

Specified by:
removeEntry in interface ILibraryDescriptor
Parameters:
toRemove - The entry top remove

getLibrary

public ILibrary getLibrary()
Description copied from interface: ILibraryDescriptor
Retrieves the ILibrary with which this descriptor is associated.

Specified by:
getLibrary in interface ILibraryDescriptor
Returns:
the associated library

getEntryDescriptors

public List getEntryDescriptors()
Description copied from interface: ILibraryDescriptor
Retrieves the descriptors for all entries in this library.

Specified by:
getEntryDescriptors in interface ILibraryDescriptor
Returns:
a List of ILibraryEntryDescriptor objects for the entries in this library

contains

public boolean contains(String fileName)
Description copied from interface: ILibraryDescriptor
Checks whether this library contains a particular file.

Specified by:
contains in interface ILibraryDescriptor
Parameters:
fileName - the file name
Returns:
true if there is a ILibraryEntryDescriptor that matches fileName, false if not.

containsURI

public boolean containsURI(String sUri)
Description copied from interface: ILibraryDescriptor
Checks whether this library contains a file with a particular base URI.

Specified by:
containsURI in interface ILibraryDescriptor
Parameters:
sUri - The desired base URI
Returns:
true if a document contained in this library has the specified base URI, false otherwise

getDescriptorFor

public ILibraryEntryDescriptor getDescriptorFor(String fileName)
Description copied from interface: ILibraryDescriptor
Retrieves the entry descriptor for a particular file within the library.

Specified by:
getDescriptorFor in interface ILibraryDescriptor
Parameters:
fileName - the file name of the desired entry
Returns:
the ILibraryEntryDescriptor associated with fileName, or null if one cannot be found

getDescriptorForURI

public ILibraryEntryDescriptor getDescriptorForURI(String sUri)
Description copied from interface: ILibraryDescriptor
Retrieves the entry descriptor for a particular URI within this library.

Specified by:
getDescriptorForURI in interface ILibraryDescriptor
Parameters:
sUri - The base URI of the desired entry
Returns:
the ILibraryEntryDescriptor associated with sUri, or null if a matching entry cannot be found


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