Class OptionKey<T>
- Type Parameters:
T- the type of option values.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DataOptionKey
OptionKeys are used for aspects that usually do not need to be configured, except in a few specialized cases.
For example, most data file formats read by SIS do not require the user to specify the character encoding,
because the encoding is often given in the file header or in the format specification. However, if SIS
needs to read plain text files and the default platform encoding is not suitable,
then the user can specify the desired encoding explicitly using the ENCODING option.
All options are hints and may be silently ignored. For example, most DataStores will ignore the
ENCODING option if irrelevant to their format, or if the encoding is specified in the data file header.
Options are transitive: if a data store uses others data stores for its internal working, the given options may also be given to those dependencies, at implementation choice.
Defining new options
Developers who wish to define their own options can define static constants in a subclass, as in the following example:public final class MyOptionKey<T> extends OptionKey<T> {
public static final OptionKey<String> MY_OPTION = new MyOptionKey<>("MY_OPTION", String.class);
private MyOptionKey(final String name, final Class<T> type) {
super(name, type);
}
}
- Since:
- 1.7
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final OptionKey<Supplier<ByteBuffer>> Provider of the byte buffer to use for input/output operations.static final OptionKey<CoverageModifier> Callback methods invoked for modifying some aspects of the grid coverages created by resources.static final OptionKey<CoordinateReferenceSystem> The coordinate reference system (CRS) of data to use if not explicitly defined.static final OptionKey<Charset> The character encoding of document content.static final OptionKey<FoliationRepresentation> Whether to assemble trajectory fragments (distinct CSV lines) into a singleFeatureinstance forming a foliation.static final OptionKey<GeometryLibrary> The library to use for creating geometric objects at reading time.static final OptionKey<Integer> The number of spaces to use for indentation when formatting texts in WKT or XML.static final OptionKey<Locale> The locale to use for locale-sensitive data.static final OptionKey<Path> Path to an auxiliary file containing metadata encoded in an ISO 19115-3 XML document.static final OptionKey<OpenOption[]> Whether a storage object shall be opened in read, write, append or other modes.static final OptionKey<StoreListeners> The listeners to declare as the parent of the data store listeners.static final OptionKey<ZoneId> The timezone to use when parsing or formatting dates and times without explicit timezone.static final OptionKey<String> The encoding of a URL (not the encoding of the document content).static final OptionKey<Supplier<XMLInputFactory>> Provider of a factory for creating XML stream readers or event readers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOptionKey(String name, Class<T> type) Creates a new key of the given name for values of the given type. -
Method Summary
Modifier and TypeMethodDescriptionReturns this option as a parameter descriptor.Methods inherited from class OptionKey
equals, getElementType, getName, getValueFrom, hashCode, setValueInto, toStringModifier and TypeMethodDescriptionbooleanDeprecated, for removal: This API element is subject to removal in a future version.Returnstrueif the given object is an instance of the same class having the same name and type.Deprecated, for removal: This API element is subject to removal in a future version.Returns the type of values associated with this option key.getName()Deprecated, for removal: This API element is subject to removal in a future version.Returns the name of this option key.getValueFrom(Map<? extends OptionKey<?>, ?> options) Deprecated, for removal: This API element is subject to removal in a future version.Returns the option value in the given map for this key, ornullif none.intDeprecated, for removal: This API element is subject to removal in a future version.Returns a hash code value for this object.Map<OptionKey<?>, Object> setValueInto(Map<OptionKey<?>, Object> options, T value) Deprecated, for removal: This API element is subject to removal in a future version.Sets a value for this option key in the given map, or in a new map if the given map isnull.Deprecated, for removal: This API element is subject to removal in a future version.Returns a string representation of this option key.
-
Field Details
-
LOCALE
The locale to use for locale-sensitive data. This option determines the language to use for writinginternational stringswhen the target storage supports only one language. It may also control number and date patterns in some file formats such as Comma Separated Values (CSV). However, most data formats will ignore this locale.This option is not for the locale of logging or warning messages. Messages locale is rather controlled by
DataStore.setLocale(Locale).- See Also:
-
TIMEZONE
The timezone to use when parsing or formatting dates and times without explicit timezone. If this option is not provided, then the default value is format specific. That default is often, but not necessarily, the platform default.- See Also:
-
INDENTATION
The number of spaces to use for indentation when formatting texts in WKT or XML. A value of -1 means to format the whole WKT or XML document on a single line without line feeds or indentation.If this option is not provided, then the most typical default value used in Apache SIS is 2. Such small indentation value is used because XML documents defined by OGC standards tend to be verbose.
- See Also:
-
ENCODING
The character encoding of document content. This option can be used when the file to read or write does not describe itself its encoding. For example, this option can be used when reading plain text files, but is ignored when reading XML files having a<?xml version="1.0" encoding="…"?>declaration.If this option is not provided, then the default value is format specific. That default is often, but not necessarily, the platform default.
- See Also:
-
URL_ENCODING
The encoding of a URL (not the encoding of the document content). This option may be used when converting aStringor aURLto aURIor aFile. The following rules apply:- URI are always encoded in UTF-8. Therefore, this option is ignored for URI.
- URL are often encoded in UTF-8, but not necessarily. Other encoding are possible (while not recommended), or some URL may not be encoded at all.
Example: Given the
"file:Map%20with%20spaces.png"URL, then:- If the URL encoding option is set to
"UTF-8"or"ISO-8859-1", then:- the encoded URI will be
"file:Map%20with%20spaces.png"; - the decoded URI or the file will be
"file:Map with spaces.png".
- the encoded URI will be
- If the URL encoding option is set to
nullor is not provided, then:- the encoded URI will be
"file:Map%2520with%2520spaces.png", i.e. the percent sign will be encoded as"%25"; - the decoded URI or the file will be
"file:Map%20with%20spaces.png".
- the encoded URI will be
- See Also:
-
OPEN_OPTIONS
Whether a storage object shall be opened in read, write, append or other modes. The main options that can be provided are:Supported open options Value Meaning StandardOpenOption.READOpen for reading data from the storage object. StandardOpenOption.WRITEOpen for modifying existing data in the storage object. StandardOpenOption.APPENDOpen for appending new data in the storage object. StandardOpenOption.CREATECreates a new storage object (file or database) if it does not exist. -
BYTE_BUFFER
Provider of the byte buffer to use for input/output operations. SomeDataStoreimplementations allow a buffer to be specified, thus allowing users to choose the buffer capacity, whether the buffer is direct, or to recycle existing buffers.It is user's responsibility to ensure that:
- The buffer does not contains any valuable data, as it will be cleared.
- The same buffer is not used concurrently by two different
DataStoreinstances.
-
XML_INPUT_FACTORY
Provider of a factory for creating XML stream readers or event readers. If this option is not specified or if the supplier returnsnull, Apache SIS uses a default factory with theXMLConstants.ACCESS_EXTERNAL_DTDproperty set to an empty string for security reasons. If a factory is supplied, the suppliers should set the factory properties itself for the desired security level. -
METADATA_PATH
Path to an auxiliary file containing metadata encoded in an ISO 19115-3 XML document. The given path, if not absolute, is relative to the path of the main storage file. If the file exists, it is parsed and its content is merged or appended after the metadata read by the storage. If the file does not exist, then it is ignored.Wildcard
It the'*'character is present in the path, then it is replaced by the name of the main file without its extension. For example if the main file is"city-center.tiff", then"*.xml"will become"city-center.xml". -
DEFAULT_CRS
The coordinate reference system (CRS) of data to use if not explicitly defined. This option can be used when the file to read does not describe itself the data CRS. For example, this option can be used when reading ASCII Grid without CRS information, but is ignored if the ASCII Grid file is accompanied by a*.prjfile giving the CRS. -
FOLIATION_REPRESENTATION
Whether to assemble trajectory fragments (distinct CSV lines) into a singleFeatureinstance forming a foliation. This is ignored if the file does not seem to contain moving features. -
GEOMETRY_LIBRARY
The library to use for creating geometric objects at reading time. Some available libraries are the Java Topology Suite (JTS), ESRI geometry API and Java2D. If this option is not specified, then a default library will be selected among the libraries available in the runtime environment. -
COVERAGE_MODIFIER
Callback methods invoked for modifying some aspects of the grid coverages created by resources. -
PARENT_LISTENERS
The listeners to declare as the parent of the data store listeners. This option can be used when theDataStoreto open is itself a child of anAggregate.
-
-
Constructor Details
-
OptionKey
-
-
Method Details
-
asOpenParameter
Returns this option as a parameter descriptor. Storing option values asParameterValueinstances is sometime convenient when the options need to be serialized, for example, in a text file or a database. While values are stored as Java objects of type<T>, theParameterValue.setValue(Object)method is capable to convert text representations to the expected object type.Parameter descriptors are available only for a subset of the options. This method may return a non-empty value only if the values of this option have a text representation.
- Returns:
- a parameter descriptor for this option.
- See Also:
-