org.semanticweb.owlapi.util
Class CachingBidirectionalShortFormProvider

java.lang.Object
  extended by org.semanticweb.owlapi.util.CachingBidirectionalShortFormProvider
All Implemented Interfaces:
BidirectionalShortFormProvider, ShortFormProvider
Direct Known Subclasses:
BidirectionalShortFormProviderAdapter

public abstract class CachingBidirectionalShortFormProvider
extends java.lang.Object
implements BidirectionalShortFormProvider

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 18-Apr-2007

A bidirectional short form provider that caches entity short forms. The provider has various methods to add, remove, update entities in the cache and also to rebuild the cache from scratch.


Constructor Summary
protected CachingBidirectionalShortFormProvider()
           
 
Method Summary
 void add(OWLEntity entity)
          Adds an entity to the cache.
 void dispose()
          Disposes of the short form proivider.
protected abstract  java.lang.String generateShortForm(OWLEntity entity)
          Generates the short form for the specified entity.
 java.util.Set<OWLEntity> getEntities(java.lang.String shortForm)
          For a given short form this method obtains the entities which have this short form.
 OWLEntity getEntity(java.lang.String shortForm)
          A convenience method which gets an entity from its short form.
 java.lang.String getShortForm(OWLEntity entity)
          Gets the short form for the specified entity.
 java.util.Set<java.lang.String> getShortForms()
          Gets all of the short forms that are cached by this short form provider.
 void rebuild(OWLEntitySetProvider<OWLEntity> entitySetProvider)
          Rebuilds the cache using entities obtained from the specified entity set provider.
 void remove(OWLEntity entity)
          Removes an entity and its short form from the cache.
 void update(OWLEntity entity)
          If the short form for a cached entity has changed then this method may be used to update the cached short form mapping for the entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingBidirectionalShortFormProvider

protected CachingBidirectionalShortFormProvider()
Method Detail

generateShortForm

protected abstract java.lang.String generateShortForm(OWLEntity entity)
Generates the short form for the specified entity. This short form will be cached so that it can be retrieved efficiently and so that the entity can be obtained from the short form. If the short form for the entity changes then the cach must explicilty be updated using the update method.

Parameters:
entity - The entity whose short form should be generated.

getShortForms

public java.util.Set<java.lang.String> getShortForms()
Gets all of the short forms that are cached by this short form provider.

Specified by:
getShortForms in interface BidirectionalShortFormProvider
Returns:
A set of strings that represent all of the cached short forms.

rebuild

public void rebuild(OWLEntitySetProvider<OWLEntity> entitySetProvider)
Rebuilds the cache using entities obtained from the specified entity set provider.

Parameters:
entitySetProvider - The OWLEntitySetProvider that should be used to obtain the entities whose short forms will be cached.

add

public void add(OWLEntity entity)
Adds an entity to the cache.

Parameters:
entity - The entity to be added to the cache - the short form will automatically be generated and added to the cache.

remove

public void remove(OWLEntity entity)
Removes an entity and its short form from the cache.

Parameters:
entity - The entity to be removed.

update

public void update(OWLEntity entity)
If the short form for a cached entity has changed then this method may be used to update the cached short form mapping for the entity.

Parameters:
entity - The entity whose short form should be updated.

getEntities

public java.util.Set<OWLEntity> getEntities(java.lang.String shortForm)
Description copied from interface: BidirectionalShortFormProvider
For a given short form this method obtains the entities which have this short form.

Specified by:
getEntities in interface BidirectionalShortFormProvider
Parameters:
shortForm - The short form of the entities that will be retrieved.
Returns:
The set of entities that have the specified short form. If there are no entities which have the specified short form then an empty set will be returned.

getEntity

public OWLEntity getEntity(java.lang.String shortForm)
Description copied from interface: BidirectionalShortFormProvider
A convenience method which gets an entity from its short form.

Specified by:
getEntity in interface BidirectionalShortFormProvider
Parameters:
shortForm - The short form of the entity.
Returns:
The actual entity or null if there is no entity which has the specified short form. If the specified short form corresponds to more than one entity then an entity will be chosen by the implementation of the short form provider.

getShortForm

public java.lang.String getShortForm(OWLEntity entity)
Description copied from interface: ShortFormProvider
Gets the short form for the specified entity.

Specified by:
getShortForm in interface ShortFormProvider
Parameters:
entity - The entity.
Returns:
A string which represents a short rendering of the speicified entity.

dispose

public void dispose()
Description copied from interface: ShortFormProvider
Disposes of the short form proivider. This frees any resources and clears any caches.

Specified by:
dispose in interface ShortFormProvider