Class ConcurrentAuthorityFactory.Finder
java.lang.Object
org.apache.sis.referencing.factory.IdentifiedObjectFinder
org.apache.sis.referencing.factory.ConcurrentAuthorityFactory.Finder
- Enclosing class:
- ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFactory>
An implementation of
IdentifiedObjectFinder which delegates
the work to the underlying Data Access Object and caches the result.
Synchronization note
Our public API claims thatIdentifiedObjectFinders are not thread-safe.
Nevertheless we synchronize this particular implementation for safety, because the consequence of misuse
are more dangerous than other implementations. Furthermore, this is also a way to assert that no code path
go to the ConcurrentAuthorityFactory.create(AuthorityFactoryProxy, String) method from a non-overridden public method.- Since:
- 0.7
- Version:
- 1.2
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
IdentifiedObjectFinder.Domain -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intNumber of time thatacquire()has been invoked.private static final intNumber of values in theIdentifiedObjectFinder.Domainenumeration.private IdentifiedObjectFinderThe finder on which to delegate the work.Fields inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
COMPARISON_MODE, factory -
Constructor Summary
ConstructorsConstructorDescriptionFinder(ConcurrentAuthorityFactory<?> factory) Creates a finder for the given type of objects. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidacquire()Acquires a new finder.(package private) final Set<org.opengis.referencing.IdentifiedObject>cache(org.opengis.referencing.IdentifiedObject object, Set<org.opengis.referencing.IdentifiedObject> result) Stores the given result in the cache.private static Set<org.opengis.referencing.IdentifiedObject>[]createCacheEntry(org.opengis.referencing.IdentifiedObject object) Creates an initially empty cache entry for the given object.Set<org.opengis.referencing.IdentifiedObject>find(org.opengis.referencing.IdentifiedObject object) Looks up an object from this authority factory which is approximately equal to the specified object.getCodeCandidates(org.opengis.referencing.IdentifiedObject object) Returns a set of authority codes that may identify the same object than the specified one.(package private) final Set<org.opengis.referencing.IdentifiedObject>getFromCache(org.opengis.referencing.IdentifiedObject object) Returns the cached value for the given object, ornullif none.private static intindex(IdentifiedObjectFinder finder) Returns the index in the cachedSet<IdentifiedObject>[]array for a result using the given finder.private voidrelease()Releases the finder.Methods inherited from class org.apache.sis.referencing.factory.IdentifiedObjectFinder
createFromCodes, findSingleton, getSearchDomain, isIgnoringAxes, setIgnoringAxes, setSearchDomain, setWrapper
-
Field Details
-
DOMAIN_COUNT
private static final int DOMAIN_COUNTNumber of values in theIdentifiedObjectFinder.Domainenumeration. Hard-coded for efficiency. Value is verified using reflection by the testConcurrentAuthorityFactoryTest.verifyDomainCount().- See Also:
-
finder
-
acquireCount
private transient int acquireCount
-
-
Constructor Details
-
Finder
Finder(ConcurrentAuthorityFactory<?> factory) Creates a finder for the given type of objects.
-
-
Method Details
-
acquire
private void acquire() throws org.opengis.util.FactoryExceptionAcquires a new finder. Therelease()method must be invoked in afinallyblock after the call toacquire. The pattern must be as below (note that the call toacquire()is inside thetryblock):- Throws:
org.opengis.util.FactoryException
-
release
private void release()Releases the finder. -
getCodeCandidates
protected Set<String> getCodeCandidates(org.opengis.referencing.IdentifiedObject object) throws org.opengis.util.FactoryException Returns a set of authority codes that may identify the same object than the specified one. This method delegates to the data access object.- Overrides:
getCodeCandidatesin classIdentifiedObjectFinder- Parameters:
object- the object looked up.- Returns:
- a set of code candidates.
- Throws:
org.opengis.util.FactoryException- if an error occurred while fetching the set of code candidates.
-
getFromCache
final Set<org.opengis.referencing.IdentifiedObject> getFromCache(org.opengis.referencing.IdentifiedObject object) Returns the cached value for the given object, ornullif none. The returned set (if non-null) is unmodifiable.- Overrides:
getFromCachein classIdentifiedObjectFinder
-
cache
final Set<org.opengis.referencing.IdentifiedObject> cache(org.opengis.referencing.IdentifiedObject object, Set<org.opengis.referencing.IdentifiedObject> result) Stores the given result in the cache. This method wraps or copies the given set in an unmodifiable set and returns the result.- Overrides:
cachein classIdentifiedObjectFinderresult- the search result as a modifiable set.- Returns:
- a set with the same content than
result.
-
createCacheEntry
private static Set<org.opengis.referencing.IdentifiedObject>[] createCacheEntry(org.opengis.referencing.IdentifiedObject object) Creates an initially empty cache entry for the given object. -
index
Returns the index in the cachedSet<IdentifiedObject>[]array for a result using the given finder. -
find
public Set<org.opengis.referencing.IdentifiedObject> find(org.opengis.referencing.IdentifiedObject object) throws org.opengis.util.FactoryException Looks up an object from this authority factory which is approximately equal to the specified object. The default implementation performs the same lookup than the Data Access Object and caches the result.- Overrides:
findin classIdentifiedObjectFinder- Parameters:
object- the object looked up.- Returns:
- the identified objects, or an empty set if not found.
- Throws:
org.opengis.util.FactoryException- if an error occurred while creating an object.
-