/** * Releases resources immediately instead of waiting for the garbage collector. This method * disposes the backing store regardeless of {@link #canDisposeBackingStore} value. */ @Override public synchronized void dispose() throws FactoryException { if (disposer != null) { disposer.cancel(); disposer = null; } super.dispose(); }
/** * Returns an image datum from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized ImageDatum createImageDatum(final String code) throws FactoryException { final ImageDatum datum; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof ImageDatum) { datum = (ImageDatum) cached; } else { datum = getBackingStore().createImageDatum(code); } put(key, datum); return datum; }
/** * Returns {@code true} if this factory is available. The default implementation returns {@code * false} if {@link #createBackingStore} throws an exception. */ @Override public boolean isAvailable() { return super.isAvailable(); }
/** * Returns the direct dependencies. The returned list contains the backing store specified at * construction time, or the exception if it can't be obtained. */ @Override Collection<? super AuthorityFactory> dependencies() { Object factory; try { factory = getBackingStore(); } catch (FactoryException e) { factory = e; } return Collections.singleton(factory); }
boolean isAvailable() { try { return getBackingStore().isAvailable(); } catch (FactoryNotFoundException exception) { final Citation citation = getAuthority(); final Collection<? extends InternationalString> titles = citation.getAlternateTitles(); InternationalString title = citation.getTitle();
/** * Constructs an instance wrapping the specified factory. The {@code maxStrongReferences} * argument specify the maximum number of objects to keep by strong reference. If a greater * amount of objects are created, then the strong references for the oldest ones are replaced by * weak references. * * <p>This constructor is protected because subclasses must declare which of the {@link * DatumAuthorityFactory}, {@link CSAuthorityFactory}, {@link CRSAuthorityFactory} and {@link * CoordinateOperationAuthorityFactory} interfaces they choose to implement. * * @param factory The factory to cache. Can not be {@code null}. * @param maxStrongReferences The maximum number of objects to keep by strong reference. */ protected BufferedAuthorityFactory( AbstractAuthorityFactory factory, final int maxStrongReferences) { super(factory.getPriority()); while (factory instanceof BufferedAuthorityFactory) { factory = ((BufferedAuthorityFactory) factory).backingStore; } this.backingStore = factory; this.maxStrongReferences = maxStrongReferences; completeHints(); }
/** * Returns a description of the underlying backing store, or {@code null} if unknow. This is for * example the database software used for storing the data. * * @throws FactoryException if a failure occured while fetching the engine description. */ @Override public String getBackingStoreDescription() throws FactoryException { return getBackingStore().getBackingStoreDescription(); }
/** * Returns a temporal coordinate system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized TimeCS createTimeCS(final String code) throws FactoryException { final TimeCS cs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof TimeCS) { cs = (TimeCS) cached; } else { cs = getBackingStore().createTimeCS(code); } put(key, cs); return cs; }
/** * Gets a description of the object corresponding to a code. * * @param code Value allocated by authority. * @return A description of the object, or {@code null} if the object corresponding to the * specified {@code code} has no description. * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found. * @throws FactoryException if the query failed for some other reason. */ public InternationalString getDescriptionText(final String code) throws NoSuchAuthorityCodeException, FactoryException { return getBackingStore().getDescriptionText(code); }
/** * Returns a 3D coordinate reference system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized CompoundCRS createCompoundCRS(final String code) throws FactoryException { final CompoundCRS crs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof CompoundCRS) { crs = (CompoundCRS) cached; } else { crs = getBackingStore().createCompoundCRS(code); } put(key, crs); return crs; }
/** * Returns the set of authority codes of the given type. The {@code type} argument specify the * base class. * * @param type The spatial reference objects type. * @return The set of authority codes for spatial reference objects of the given type. If this * factory doesn't contains any object of the given type, then this method returns an * {@linkplain java.util.Collections#EMPTY_SET empty set}. * @throws FactoryException if access to the underlying database failed. */ public Set<String> getAuthorityCodes(final Class<? extends IdentifiedObject> type) throws FactoryException { return getBackingStore().getAuthorityCodes(type); }
/** * Returns an arbitrary object from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized IdentifiedObject createObject(final String code) throws FactoryException { final IdentifiedObject object; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof IdentifiedObject) { object = (IdentifiedObject) cached; } else { object = getBackingStore().createObject(code); } put(key, object); return object; }
/** * Returns a finder which can be used for looking up unidentified objects. The default * implementation delegates lookup to the underlying backing store and caches the result. * * @throws FactoryException if the finder can not be created. * @since 2.4 */ @Override public synchronized IdentifiedObjectFinder getIdentifiedObjectFinder( final Class<? extends IdentifiedObject> type) throws FactoryException { return new Finder(getBackingStore().getIdentifiedObjectFinder(type)); }
/** * Returns an extent (usually an area of validity) from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized Extent createExtent(final String code) throws FactoryException { final Extent extent; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof Extent) { extent = (Extent) cached; } else { extent = getBackingStore().createExtent(code); } put(key, extent); return extent; }
/** * Returns a derived coordinate reference system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized DerivedCRS createDerivedCRS(final String code) throws FactoryException { final DerivedCRS crs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof DerivedCRS) { crs = (DerivedCRS) cached; } else { crs = getBackingStore().createDerivedCRS(code); } put(key, crs); return crs; }
/** * Returns an engineering coordinate reference system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized EngineeringCRS createEngineeringCRS(final String code) throws FactoryException { final EngineeringCRS crs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof EngineeringCRS) { crs = (EngineeringCRS) cached; } else { crs = getBackingStore().createEngineeringCRS(code); } put(key, crs); return crs; }
/** * Returns a prime meridian from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized PrimeMeridian createPrimeMeridian(final String code) throws FactoryException { final PrimeMeridian meridian; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof PrimeMeridian) { meridian = (PrimeMeridian) cached; } else { meridian = getBackingStore().createPrimeMeridian(code); } put(key, meridian); return meridian; }
/** * Returns a coordinate system axis from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized CoordinateSystemAxis createCoordinateSystemAxis(final String code) throws FactoryException { final CoordinateSystemAxis axis; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof CoordinateSystemAxis) { axis = (CoordinateSystemAxis) cached; } else { axis = getBackingStore().createCoordinateSystemAxis(code); } put(key, axis); return axis; }
/** * Returns a cartesian coordinate system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized CartesianCS createCartesianCS(final String code) throws FactoryException { final CartesianCS cs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof CartesianCS) { cs = (CartesianCS) cached; } else { cs = getBackingStore().createCartesianCS(code); } put(key, cs); return cs; }
/** * Returns a vertical coordinate system from a code. * * @throws FactoryException if the object creation failed. */ @Override public synchronized VerticalCS createVerticalCS(final String code) throws FactoryException { final VerticalCS cs; final String key = trimAuthority(code); final Object cached = get(key); if (cached instanceof VerticalCS) { cs = (VerticalCS) cached; } else { cs = getBackingStore().createVerticalCS(code); } put(key, cs); return cs; }