Class ProviderSpec
java.lang.Object
opennlp.tools.util.ext.ProviderSpec
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProviderSpecempty()booleaninthashCode()booleanhasOnlyOptions(String... names) Checks whether every option of this spec has one of the given names.location()booleanlocationEndsWith(String suffix) Checks whether the last path segment of the location ends with a suffix, ignoring case.static ProviderSpecCreates a spec with a location and without options.static ProviderSpecCreates a spec with a location and options.static ProviderSpecCreates a spec for a file or directory without options, seeof(Path, Map).static ProviderSpecCreates a spec for a file or directory with options.static ProviderSpecCreates a spec with options and without location.Reads an option.options()path()toString()The option values and the user info, query and fragment of the location are omitted, as they may hold credentials.
-
Method Details
-
empty
- Returns:
- A spec without location and options. Never
null.
-
of
Creates a spec with options and without location.- Parameters:
options- The options. Must not benull, an option name must not benullor blank and an option value must not benull.- Returns:
- The spec. Never
null. - Throws:
IllegalArgumentException- Thrown ifoptionsis invalid.
-
of
Creates a spec with a location and without options.- Parameters:
location- The absolute location. Must not benull.- Returns:
- The spec. Never
null. - Throws:
IllegalArgumentException- Thrown iflocationisnullor not absolute.
-
of
Creates a spec with a location and options.- Parameters:
location- The absolute location, which is taken as it is, unlike the location ofof(Path, Map). Must not benull.options- The options. Must not benull, an option name must not benullor blank and an option value must not benull.- Returns:
- The spec. Never
null. - Throws:
IllegalArgumentException- Thrown iflocationisnullor not absolute, or ifoptionsis invalid.
-
of
Creates a spec for a file or directory without options, seeof(Path, Map).- Parameters:
location- The file or directory. Must not benull.- Returns:
- The spec. Never
null. - Throws:
IllegalArgumentException- Thrown iflocationisnull.
-
of
Creates a spec for a file or directory with options. A relative path is resolved against the working directory of the running process when the spec is created, so a spec that is kept in astaticfield must not be created from a relative path. The file system is not read, so the location of a directory carries no trailing separator and a path holding..is kept as it is.- Parameters:
location- The file or directory. Must not benull.options- The options. Must not benull, an option name must not benullor blank and an option value must not benull.- Returns:
- The spec. Never
null. - Throws:
IllegalArgumentException- Thrown iflocationisnull, or ifoptionsis invalid.
-
location
- Returns:
- The location, or
Optional.empty()if this spec has none.
-
path
- Returns:
- The location as a path, or
Optional.empty()if this spec has no location or the location is not a hierarchicalfileURI of the default file system.
-
options
-
option
Reads an option.- Parameters:
key- The option name. Must not benull.defaultValue- The value to return if the option is absent. May benull.- Returns:
- The option value, or
defaultValue. - Throws:
IllegalArgumentException- Thrown ifkeyisnull.
-
hasOnlyOptions
Checks whether every option of this spec has one of the given names.- Parameters:
names- The accepted option names. Must not benullor contain anullelement.- Returns:
trueif this spec has no option with another name.- Throws:
IllegalArgumentException- Thrown ifnamesisnullor contains anullelement.
-
locationEndsWith
Checks whether the last path segment of the location ends with a suffix, ignoring case. A query and a fragment are not part of the comparison. For an opaque URI, such asjar:file:/models.jar!/model.onnx, the scheme-specific part is used as path. This is a convenience for routing a request to a provider, not a validation of the location.- Parameters:
suffix- The suffix, for example.onnx. Must not benullor empty.- Returns:
trueif this spec has a location and its last path segment ends withsuffix.- Throws:
IllegalArgumentException- Thrown ifsuffixisnullor empty.
-
equals
-
hashCode
-
toString
-