Package org.apache.sis.internal.util
Class DefinitionURI
java.lang.Object
org.apache.sis.internal.util.DefinitionURI
Utility methods for parsing OGC's URI (URN or URL) in the
Some example of authorities are:
"urn:ogc:def" namespace.
For example, all the following URIs are for the same object:
"EPSG:4326"(older format)"EPSG::4326"(often seen for similarity with URN below)"urn:ogc:def:crs:EPSG::4326"(version number is omitted)"urn:ogc:def:crs:EPSG:8.2:4326"(explicit version number, here 8.2)"urn:x-ogc:def:crs:EPSG::4326"(prior registration of"ogc"to IANA)"http://www.opengis.net/def/crs/EPSG/0/4326""http://www.opengis.net/gml/srs/epsg.xml#4326"
code field will be "m%2Fs" instead of "m/s".
http://www.opengis.net/def/uom/SI/0/m%2Fs
Parts of URN
URN begins with"urn:ogc:def:" (formerly "urn:x-ogc:def:") followed by:
- an object type
- an authority
- an optional version number (often omitted)
- the code
- an arbitrary number of parameters
NameMeaning class.
| Object type | Meaning |
|---|---|
| axis | Coordinate system axe definition |
| axisDirection | Axis direction code definition |
| coordinateOperation | Coordinate operation definition |
| crs | Coordinate reference system definition |
| cs | Coordinate system definition |
| datum | Datum definition |
| dataType | Data type definition |
| derivedCRSType | Derived CRS type code definition |
| documentType | Document type definition |
| ellipsoid | Ellipsoid definition |
| featureType | Feature type definition |
| group | Operation parameter group definition |
| meaning | Parameter meaning definition |
| meridian | Prime meridian definition |
| method | Operation method definition |
| nil | Explanations for missing information |
| parameter | Operation parameter definition |
| phenomenon | Observable property definition |
| pixelInCell | Pixel in cell code definition |
| rangeMeaning | Range meaning code definition |
| referenceSystem | Value reference system definition |
| uom | Unit of measure definition |
| verticalDatumType | Vertical datum type code definition |
| Authority | Purpose |
|---|---|
"OGC" | Objects defined by the Open Geospatial Consortium. |
"EPSG" | Referencing objects defined in the EPSG database. |
"EDCS" | Environmental Data Coding Specification. |
"SI" | International System of Units. |
"UCUM" | Unified Code for Units of Measure. |
Combined URNs
This implementation does not handle combined URNs. An example of combined URN would be"urn:ogc:def:crs,crs:EPSG:6.3:27700,crs:EPSG:6.3:5701".- Since:
- 0.4
- Version:
- 1.3
- Author:
- Martin Desruisseaux (Geomatys)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe authority part of a URI, ornullif none (empty).The code part of a URI, ornullif none (empty).static final charThe separator between components in a URN.If the URI contains sub-components, those sub-components.static final StringThe domain of URLs in the OGC namespace.booleantrueif the URI is a"http://www.opengis.net/gml/…"URL.booleantrueif the URI is a"http://www.opengis.net/…"URL, orfalseif the URI is a"urn:ogc:def:…"URN.static final StringA version number to be considered as if no version were provided.String[]The parameters, ornullif none.static final StringThe "urn:ogc:def" prefix used in all URN supported by this class.static final charThe path separator in URN.The type part of a URI, ornullif none (empty).The version part of a URI, ornullif none (empty). -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcodeOf(String type, String authority, CharSequence uri) Returns the code part of the given URI, provided that it matches the given object type and authority.static DefinitionURIAttempts to parse the given URI, which may either a URN or URL.static booleanregionMatches(String part, String urn, int lower, int upper) Returnstrueif a sub-region ofurnmatches the givenpart, ignoring case, leading and trailing whitespaces.toString()Returns a string representation of this URI.
-
Field Details
-
PREFIX
The "urn:ogc:def" prefix used in all URN supported by this class.- See Also:
-
SEPARATOR
public static final char SEPARATORThe path separator in URN.- See Also:
-
COMPONENT_SEPARATOR
public static final char COMPONENT_SEPARATORThe separator between components in a URN.Example: in"urn:ogc:def:crs,crs:EPSG:9.1:27700,crs:EPSG:9.1:5701", the components are"crs:EPSG:9.1:27700"and"crs:EPSG:9.1:5701".- See Also:
-
DOMAIN
The domain of URLs in the OGC namespace.- See Also:
-
NO_VERSION
A version number to be considered as if no version were provided. This value is part of OGC specification (not a SIS-specific hack).- See Also:
-
isHTTP
public boolean isHTTPtrueif the URI is a"http://www.opengis.net/…"URL, orfalseif the URI is a"urn:ogc:def:…"URN. -
isGML
public boolean isGMLtrueif the URI is a"http://www.opengis.net/gml/…"URL. A value oftrueshould imply thatisHTTPis alsotrue. -
type
The type part of a URI, ornullif none (empty). Note that the set of valid types in OGC namespace is restricted. See class javadoc for more information.Example: In the"urn:ogc:def:crs:EPSG:8.2:4326"URN, this is"crs".- See Also:
-
authority
The authority part of a URI, ornullif none (empty). Note that the set of valid authorities in OGC namespace is restricted. See class javadoc for more information.Example: In the"urn:ogc:def:crs:EPSG:8.2:4326"URN, this is"EPSG". -
version
The version part of a URI, ornullif none (empty). This field is null if the version in the parsed string was "0".Example: In the"urn:ogc:def:crs:EPSG:8.2:4326"URN, this is"8.2". -
code
The code part of a URI, ornullif none (empty).Example: In the"urn:ogc:def:crs:EPSG:8.2:4326"URN, this is"4326". -
parameters
The parameters, ornullif none.Example: In the"urn:ogc:def:crs:OGC:1.3:AUTO42003:1:-100:45"URN, this is{"1", "-100", "45"}}. -
components
If the URI contains sub-components, those sub-components. Otherwisenull.URN example: if the URI is"urn:ogc:def:crs,crs:EPSG:9.1:27700,crs:EPSG:9.1:5701", then thisDefinitionURIwill contain the"urn:ogc:def:crs"header with two components:"urn:ogc:def:crs:EPSG:9.1:27700""urn:ogc:def:crs:EPSG:9.1:5701"
HTTP example: if the URI isNote that this array may contain"http://www.opengis.net/def/crs-compound?1=(…)/crs/EPSG/9.1/27700&2=(…)/crs/EPSG/9.1/5701", then thisDefinitionURIwill contain the"http://www.opengis.net/def/crs-compound"header with two components:"http://http://www.opengis.net/def/crs/EPSG/9.1/27700""http://http://www.opengis.net/def/crs/EPSG/9.1/5701"
nullelements if we failed to parse the corresponding component.
-
-
Method Details
-
parse
Attempts to parse the given URI, which may either a URN or URL. If this method does not recognize the given URI, then it returnsnull. If the given URI is incomplete, then thecodevalue will benull.- Parameters:
uri- the URI to parse.- Returns:
- the parse result, or
nullif the given URI is not recognized.
-
regionMatches
Returnstrueif a sub-region ofurnmatches the givenpart, ignoring case, leading and trailing whitespaces.- Parameters:
part- the expected part ("urn","ogc","def", etc.)urn- the URN for which to test a subregion.lower- index of the first character inurnto compare, after skipping whitespaces.upper- index after the last character inurnto compare, ignoring whitespaces.- Returns:
trueif the given sub-region ofurnmatch the given part.
-
codeOf
Returns the code part of the given URI, provided that it matches the given object type and authority. This method is useful when:- the URI is expected to have a specific object type and authority;
- the version number is considered irrelevant;
- the code is expected to have no parameters.
- The given authority followed by the code (e.g.
"EPSG:4326"). - The URN form (e.g.
"urn:ogc:def:crs:EPSG::4326"), ignoring version number. This method accepts also the former"x-ogc"in place of"ogc". - The HTTP form (e.g.
"http://www.opengis.net/def/crs/EPSG/0/4326"). - The GML form (e.g.
"http://www.opengis.net/gml/srs/epsg.xml#4326").
- Parameters:
type- the expected object type (e.g."crs") in lower cases. See class javadoc for a list of types.authority- the expected authority, typically"EPSG". See class javadoc for a list of authorities.uri- the URI to parse.- Returns:
- the code part of the given URI, or
nullif the codespace does not match the given type and authority, the code is empty, or the code is followed by parameters.
-
toString
Returns a string representation of this URI. If the URI were originally a GML's URL, then this method formats the URI in the"http://www.opengis.net/gml/srs/"namespace. Otherwise the URI were originally a URL, then this method formats the URI in the"http://www.opengis.net/"namespace. Otherwise this method formats the URI as a URN.
-