org.opengis.cite.ogcapifeatures10.util.OgcNameValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ets-ogcapi-features10 Show documentation
Show all versions of ets-ogcapi-features10 Show documentation
Describe purpose of test suite.
package org.opengis.cite.ogcapifeatures10.util;
/**
* @author Lyn Goltz
*/
public class OgcNameValidator {
/**
*
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
* HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
* pct-encoded = "%" HEXDIG HEXDIG ;
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
*
*/
private static String PCHAR = "[a-zA-Z0-9\\-\\._~!\\$&'\\(\\)\\*\\+,;=:@]|(%[0-9A-F]{2})";
/**
*
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
* HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
* pct-encoded = "%" HEXDIG HEXDIG ;
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
* pchar = unreserved / pct-encoded / sub-delims / "@"
*
*/
private static String PCHAR_NC = "[a-zA-Z0-9\\-\\._~!\\$&'\\(\\)\\*\\+,;=@]|(%[0-9A-F]{2})";
/**
*
* code = segment-nz-nc *( "/" segment-nz-nc )
*
*/
private static String CODE = "(" + PCHAR_NC + ")+" + "(/(" + PCHAR_NC + ")+)*";
/**
*
* codeURN = segment-nz-nc *( ":" segment-nz-nc )
*
*/
private static String CODE_URN = "(" + PCHAR_NC + ")+" + "(:(" + PCHAR_NC + ")+)*";
/**
*
* authority = segment-nz-nc ; a token from the register of OGC authorities2
*
*/
private static String VERSION = "(" + PCHAR_NC + ")+";
/**
*
* authority = segment-nz-nc ; a token from the register of OGC authorities2
*
*/
private static String VERSION_URN = "(" + PCHAR_NC + ")*";
/**
*
* authority = segment-nz-nc ; a token from the register of OGC authorities2
*
*/
private static String AUTHORIY = "(" + PCHAR_NC + ")+";
/**
*
* definition-type = segment-nz-nc ; a token from the register of OGC definition types1
*
*/
private static String DEFINITION_TYPE = "crs";
/**
*
* ResourceSpecificPath = definition-type "/" authority "/" version "/" code
*
*/
private static String RESOURCE_SPECIFIC_PATH = DEFINITION_TYPE + "/" + AUTHORIY + "/" + VERSION + "/" + CODE;
/**
*
* ResourceSpecificString = definition-type ":" authority ":" versionURN ":" codeURN
*
*/
private static String RESOURCE_SPECIFIC_URN = DEFINITION_TYPE + ":" + AUTHORIY + ":" + VERSION_URN + ":" + CODE_URN;
/**
*
* OGCResource = "def"
* URI = "http://www.opengis.net/" OGCResource "/" ResourceSpecificPath
*
*/
private static String OGC_NAME_URI = "http://www.opengis.net/def/" + RESOURCE_SPECIFIC_PATH;
/**
*
* OGCResource = "def"
* URN = "urn:ogc:" OGCResource ":" ResourceSpecificString
*
*/
private static String OGC_NAME_URN = "urn:ogc:def:" + RESOURCE_SPECIFIC_URN;
/**
* Checks if the passed urn is a valid urn according OGC Name Type Specification - definitions - part 1 – basic name
* (https://docs.opengeospatial.org/pol/09-048r5.html)
*
* @param urn
* the urn to check, null
results in a invalid URN.
* @return true
if the urn is valid according to OGC Name Type Specification - definitions - part 1 –
* basic name, false
if the urn is null, empty or not valid.
*/
public boolean isValid( String urn ) {
if ( urn == null )
return false;
return urn.matches( OGC_NAME_URI ) || urn.matches( OGC_NAME_URN );
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy