Package org.biojavax

Class RichObjectFactory

java.lang.Object
org.biojavax.RichObjectFactory

public class RichObjectFactory extends Object
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 Details

    • setRichObjectBuilder

      public static void setRichObjectBuilder(RichObjectBuilder b)
      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

      public static Object getObject(Class clazz, Object[] params)
      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 build
      params - the parameters to pass to the class' constructor
      Returns:
      the instantiated object
    • setApplicationClass

      public 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.
      Parameters:
      theBiojavaClass - one of the well-known builder classes: SimpleNamespace, SimpleComparableOntology, SimpleNCBITaxon, SimpleCrossRef, or SimpleDocRef
      theApplicationClass - - a subclass of theBiojavaClass
    • clearLRUCache

      public static void clearLRUCache()
      Removes all objects from the LRU cache.
    • clearLRUCache

      public static void clearLRUCache(Class clazz)
      Removes all objects of the specified class from the LRU cache.
      Parameters:
      clazz - The class of the objects to remove.
    • setLRUCacheSize

      public static void setLRUCacheSize(int size)
      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

      public static void setLRUCacheSize(Class clazz, int size)
      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

      public static void setDefaultNamespaceName(String name)
      Sets the default namespace name to use when loading sequences. Defaults to "lcl".
      Parameters:
      name - the namespace name to use.
    • setDefaultOntologyName

      public static void setDefaultOntologyName(String name)
      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

      public static Namespace 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: