Package org.apache.sis.internal.system
Class Semaphores
java.lang.Object
org.apache.sis.internal.system.Semaphores
Thread-local booleans that need to be shared across different packages. Each thread has its own set of booleans.
The
clear(int)
method must be invoked after the queryAndSet(int)
method in
a try ... finally
block.- Since:
- 0.5
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A lock for avoiding never-ending recursivity in theequals
method ofAbstractDerivedCRS
andAbstractCoordinateOperation
.static final int
A flag to indicate thatAbstractCoordinateOperation
is querying parameters of aMathTransform
enclosed in the operation.static final int
A flag to indicate that a finer logging level should be used for reporting geodetic object creations.private int
The bit flags.private static final ThreadLocal<Semaphores>
The flags per running thread.static final int
A flag to indicate that only metadata are desired and that there is no need to create costly objects.static final int
A flag to indicate that empty collections should be returned asnull
.static final int
A flag to indicate that a parameter value outside its domain of validity should not cause an exception to be thrown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear
(int flag) Clears the given flag.static void
clear
(int flag, boolean previous) Clears the given flag only if it was previously cleared.static boolean
query
(int flag) Returnstrue
if the given flag is set.static boolean
queryAndSet
(int flag) Sets the given flag.
-
Field Details
-
NULL_COLLECTION
public static final int NULL_COLLECTIONA flag to indicate that empty collections should be returned asnull
. Returning null collections is not a recommended practice, but is useful in some situations like marshalling a XML document with JAXB, when we want to omit empty XML blocks.- See Also:
-
METADATA_ONLY
public static final int METADATA_ONLYA flag to indicate that only metadata are desired and that there is no need to create costly objects. This flag is used during iteration over many coordinate operations before to select a single one by inspecting only their metadata.- See Also:
-
CONVERSION_AND_CRS
public static final int CONVERSION_AND_CRSA lock for avoiding never-ending recursivity in theequals
method ofAbstractDerivedCRS
andAbstractCoordinateOperation
. It is set totrue
when a comparison is in progress. This lock is necessary becauseAbstractDerivedCRS
objects contain aconversionFromBase
field, which contains aDefaultConversion.targetCRS
field referencing back theAbstractDerivedCRS
object.- See Also:
-
ENCLOSED_IN_OPERATION
public static final int ENCLOSED_IN_OPERATIONA flag to indicate thatAbstractCoordinateOperation
is querying parameters of aMathTransform
enclosed in the operation. This is often at the time of formatting the WKT of a"ProjectedCRS"
element.- See Also:
-
SUSPEND_PARAMETER_CHECK
A flag to indicate that a parameter value outside its domain of validity should not cause an exception to be thrown. This flag is set only when creating a deprecated operation from the EPSG database. Typically the operation is deprecated precisely because it used invalid parameter values, but SIS should still be able to create those deprecated objects if a user request them.Example: EPSG:3752 was a Mercator (variant A) projection but set the latitude of origin to 41°S.
- See Also:
-
FINER_OBJECT_CREATION_LOGS
public static final int FINER_OBJECT_CREATION_LOGSA flag to indicate that a finer logging level should be used for reporting geodetic object creations. This flag is used during operations that potentially create a large amount of CRS, for example when trying many CRS candidates in search for a CRS compliant with some criteria.- See Also:
-
FLAGS
The flags per running thread. -
flags
private int flagsThe bit flags.
-
-
Constructor Details
-
Semaphores
private Semaphores()For internal use only.
-
-
Method Details
-
query
public static boolean query(int flag) Returnstrue
if the given flag is set.- Parameters:
flag
- one ofCONVERSION_AND_CRS
,ENCLOSED_IN_OPERATION
or other constants.- Returns:
true
if the given flag is set.
-
queryAndSet
public static boolean queryAndSet(int flag) Sets the given flag.- Parameters:
flag
- one ofCONVERSION_AND_CRS
,ENCLOSED_IN_OPERATION
or other constants.- Returns:
true
if the given flag was already set.
-
clear
public static void clear(int flag) Clears the given flag.- Parameters:
flag
- one ofCONVERSION_AND_CRS
,ENCLOSED_IN_OPERATION
or other constants.
-
clear
public static void clear(int flag, boolean previous) Clears the given flag only if it was previously cleared. This is a convenience method for a common pattern withtry … finally
blocks.- Parameters:
flag
- one ofCONVERSION_AND_CRS
,ENCLOSED_IN_OPERATION
or other constants.previous
- value returned byqueryAndSet(int)
.
-