org.geotools.util
Class ObjectCaches

Object
  extended by ObjectCaches

public final class ObjectCaches
extends Object

This is facade around several constructs used by GeoTools for internal caching.

This class provides the following services:

Since:
2.5
Author:
Jody Garnett, Cory Horner

Method Summary
static ObjectCache chain(ObjectCache level1, ObjectCache level2)
          Create a two level cache, operates as a level1 cache that is willing to obtain values from a (usually shared) level2 cache.
static ObjectCache create(Hints hints)
          Utility method used to produce cache based on provide Hint
static ObjectCache create(String policy, int size)
          Utility method used to produce an ObjectCache.
static String toKey(Citation citation, String code)
          Produce a good key based on the privided citaiton and code.
static Object toKey(Citation citation, String code1, String code2)
          Produce a good key based on a pair of codes.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

chain

public static ObjectCache chain(ObjectCache level1,
                                ObjectCache level2)
Create a two level cache, operates as a level1 cache that is willing to obtain values from a (usually shared) level2 cache.

This functionality is used to tie two ObjectCache implementations together (allowing them to collaborate while focusing on different use cases). The real world example of chaining is in AbstractFindableAuthorityFactory in which:

In this manner the find operation does not upset normal cache. It will not create any objects already present in the cache.

Parameters:
level1 -
level2 -
Returns:
ObjectCache

create

public static ObjectCache create(Hints hints)
                          throws FactoryRegistryException
Utility method used to produce cache based on provide Hint

Throws:
FactoryRegistryException

create

public static ObjectCache create(String policy,
                                 int size)
Utility method used to produce an ObjectCache.

Parameters:
policy - One of "weak", "all", "none", "soft"
size - Used to indicate requested size, exact use depends on policy
Returns:
A new ObjectCache
See Also:
Hints.BUFFER_POLICY

toKey

public static String toKey(Citation citation,
                           String code)
Produce a good key based on the privided citaiton and code. You can think of the citation as being "here" and the code being the "what".

Parameters:
code - Code
Returns:
A good key for use with ObjectCache

toKey

public static Object toKey(Citation citation,
                           String code1,
                           String code2)
Produce a good key based on a pair of codes.

Parameters:
code1 -
code2 -
Returns:
A object to use as a key


Copyright © 1996-2014 Geotools. All Rights Reserved.