RichObjectFactory (BioJava-1.5-beta API)
Keywords: org.biojavax.RichObjectFactory class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 Summary
`static void` | `clearLRUCache()` Removes all objects from the LRU cache.
`static void` | `clearLRUCache(Class clazz)` Removes all objects of the specified class from the LRU cache.
`static void` | `connectToBioSQL(Object session)` A utility method that configures the RichObjectFactory for use with a Hibernate session.
`static CrossReferenceResolver` | `getDefaultCrossReferenceResolver()` Returns the default cross ref resolver object.
`static Namespace` | `getDefaultNamespace()` Returns the default namespace object.
`static ComparableOntology` | `getDefaultOntology()` Returns the default ontology object.
`static PositionResolver` | `getDefaultPositionResolver()` Returns the default position resolver object.
`static RichSequenceHandler` | `getDefaultRichSequenceHandler()` Returns the default sequence resolver object.
`static Object` | `getObject(Class clazz, Object[] params)` Delegates to a RichObjectBuilder to construct/retrieve the object, and returns it.
`static 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` | `setDefaultCrossReferenceResolver(CrossReferenceResolver crr)` Sets the default crossref resolver to use when resolving remote entries.
`static void` | `setDefaultNamespaceName(String name)` 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` | `setDefaultPositionResolver(PositionResolver pr)` Sets the default position resolver to use when creating new rich feature locations.
`static void` | `setDefaultRichSequenceHandler(RichSequenceHandler rsh)` Sets the default sequence handler to use when performing sequence manipulation.
`static void` | `setLRUCacheSize(Class clazz, int size)` Sets the size of the LRU cache.
`static void` | `setLRUCacheSize(int size)` Sets the size of the LRU cache.
`static void` | `setRichObjectBuilder(RichObjectBuilder b)` Sets the builder to use when instantiating new Rich objects.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### 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:
    `SimpleRichObjectBuilder`, `BioSQLRichObjectBuilder`

### 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

    public static void setDefaultPositionResolver(PositionResolver pr)

  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:
    `PositionResolver`, `PositionResolver.AverageResolver`, `RichLocation`

### setDefaultCrossReferenceResolver

    public static void setDefaultCrossReferenceResolver(CrossReferenceResolver crr)

  Sets the default crossref resolver to use when resolving remote entries. Defaults to the DummyCrossReferenceResolver.

  Parameters:
    `crr` - the resolver to use.
  See Also:
    `CrossReferenceResolver`, `DummyCrossReferenceResolver`

### setDefaultRichSequenceHandler

    public static void setDefaultRichSequenceHandler(RichSequenceHandler rsh)

  Sets the default sequence handler to use when performing sequence manipulation. Defaults to the DummyRichSequenceHandler.

  Parameters:
    `rsh` - the resolver to use.
  See Also:
    `RichSequenceHandler`, `DummyRichSequenceHandler`

### getDefaultNamespace

    public static Namespace getDefaultNamespace()

  Returns the default namespace object. Defaults to "lcl".

  Returns:
    the default namespace.

### getDefaultOntology

    public static ComparableOntology getDefaultOntology()

  Returns the default ontology object. Defaults to "biojavax".

  Returns:
    the default ontology.

### getDefaultPositionResolver

    public static PositionResolver getDefaultPositionResolver()

  Returns the default position resolver object. Defaults to PositionResolver.AverageResolver

  Returns:
    the default position resolver.
  See Also:
    `PositionResolver.AverageResolver`

### getDefaultCrossReferenceResolver

    public static CrossReferenceResolver getDefaultCrossReferenceResolver()

  Returns the default cross ref resolver object. Defaults to DummyCrossReferenceResolver

  Returns:
    the default resolver.
  See Also:
    `DummyCrossReferenceResolver`

### getDefaultRichSequenceHandler

    public static RichSequenceHandler getDefaultRichSequenceHandler()

  Returns the default sequence resolver object. Defaults to DummyRichSequenceHandler.

  Returns:
    the default resolver.
  See Also:
    `DummyRichSequenceHandler`

### connectToBioSQL

    public static void connectToBioSQL(Object session)

  A utility method that configures the RichObjectFactory for use with a Hibernate session.

  Parameters:
    `session` - an object containing a Hibernate session.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD