Package org.biojavax
Class RichObjectFactory
java.lang.Object
org.biojavax.RichObjectFactory
Runs a service that builds rich objects, and provides some default values
for things like default ontology, default namespace, etc.
- Since:
- 1.5
- Author:
- Richard Holland
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Removes all objects from the LRU cache.static void
clearLRUCache
(Class clazz) Removes all objects of the specified class from the LRU cache.static CrossReferenceResolver
Returns the default cross ref resolver object.static Namespace
Returns the default namespace object.static ComparableOntology
Returns the default ontology object.static PositionResolver
Returns the default position resolver object.static RichSequenceHandler
Returns the default sequence resolver object.static Object
Delegates to a RichObjectBuilder to construct/retrieve the object, and returns it.static final void
setApplicationClass
(Class theBiojavaClass, Class theApplicationClass) Allow application to override the default biojava class created in getObject - subclass restriction is checked in the builder.static void
Sets the default crossref resolver to use when resolving remote entries.static void
Sets the default namespace name to use when loading sequences.static void
setDefaultOntologyName
(String name) Sets the default ontology name to use when loading sequences.static void
Sets the default position resolver to use when creating new rich feature locations.static void
Sets the default sequence handler to use when performing sequence manipulation.static void
setLRUCacheSize
(int size) Sets the size of the LRU cache.static void
setLRUCacheSize
(Class clazz, int size) Sets the size of the LRU cache.static void
Sets the builder to use when instantiating new Rich objects.
-
Method Details
-
setRichObjectBuilder
Sets the builder to use when instantiating new Rich objects. The basic, default, one is a SimpleRichObjectBuilder, which just calls the constructor. Another useful one is BioSQLRichObjectBuilder, which attempts to load objects from the database. The latter is required if you are working with Hibernate as it will not work without it.- Parameters:
b
- the builder to use.- See Also:
-
getObject
Delegates to a RichObjectBuilder to construct/retrieve the object, and returns it. To increase efficiency, it keeps a list of recently requested objects. If it receives further requests for the same object, it returns them from the cache. The size of the cache can be altered using setLRUCacheSize(). The default cache size is 20 objects for each type of class requested.- Parameters:
clazz
- the class to buildparams
- the parameters to pass to the class' constructor- Returns:
- the instantiated object
-
setApplicationClass
Allow application to override the default biojava class created in getObject - subclass restriction is checked in the builder.- Parameters:
theBiojavaClass
- one of the well-known builder classes: SimpleNamespace, SimpleComparableOntology, SimpleNCBITaxon, SimpleCrossRef, or SimpleDocReftheApplicationClass
- - a subclass of theBiojavaClass
-
clearLRUCache
Removes all objects from the LRU cache. -
clearLRUCache
Removes all objects of the specified class from the LRU cache.- Parameters:
clazz
- The class of the objects to remove.
-
setLRUCacheSize
Sets the size of the LRU cache. This is the size per class of object requested, so if you set it to 20 and request 3 different types of object, you will get 20*3=60 entries in the cache. The default cache size is 20. Setting this value will undo any previous changes made using the setLRUCacheSize(Class,int) method below, but will not override future ones.- Parameters:
size
- the size of the cache.
-
setLRUCacheSize
Sets the size of the LRU cache. This is the size for the specific class of object requested, so does not affect the size of caches of other objects. If this method is not called, then the cache size defaults to 20, or whatever value was passed to setLRUCacheSize(int) above.- Parameters:
size
- the size of the cache.
-
setDefaultNamespaceName
Sets the default namespace name to use when loading sequences. Defaults to "lcl".- Parameters:
name
- the namespace name to use.
-
setDefaultOntologyName
Sets the default ontology name to use when loading sequences. Defaults to "biojavax".- Parameters:
name
- the ontology name to use.
-
setDefaultPositionResolver
Sets the default position resolver to use when creating new rich feature locations. Defaults to the AverageResolver- Parameters:
pr
- the position resolver to use.- See Also:
-
setDefaultCrossReferenceResolver
Sets the default crossref resolver to use when resolving remote entries. Defaults to the DummyCrossReferenceResolver.- Parameters:
crr
- the resolver to use.- See Also:
-
setDefaultRichSequenceHandler
Sets the default sequence handler to use when performing sequence manipulation. Defaults to the DummyRichSequenceHandler.- Parameters:
rsh
- the resolver to use.- See Also:
-
getDefaultNamespace
Returns the default namespace object. Defaults to "lcl".- Returns:
- the default namespace.
-
getDefaultOntology
Returns the default ontology object. Defaults to "biojavax".- Returns:
- the default ontology.
-
getDefaultPositionResolver
Returns the default position resolver object. Defaults to PositionResolver.AverageResolver- Returns:
- the default position resolver.
- See Also:
-
getDefaultCrossReferenceResolver
Returns the default cross ref resolver object. Defaults to DummyCrossReferenceResolver- Returns:
- the default resolver.
- See Also:
-
getDefaultRichSequenceHandler
Returns the default sequence resolver object. Defaults to DummyRichSequenceHandler.- Returns:
- the default resolver.
- See Also:
-