Package org.eclipse.rdf4j.model.util
Class URIUtil
java.lang.Object
org.eclipse.rdf4j.model.util.URIUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getLocalNameIndex
(String uri) Finds the index of the first local name character in an (non-relative) URI.static boolean
isCorrectURISplit
(String namespace, String localName) Checks whether the URI consisting of the specified namespace and local name has been split correctly according to the URI splitting rules specified inURI
.static boolean
isValidLocalName
(String name) Checks whether the specified name is allowed as the local name part of an IRI according to the SPARQL 1.1/Turtle 1.1 spec.static boolean
isValidURIReference
(String uriRef) Verifies that the supplied string is a valid RDF (1.0) URI reference, as defined in section 6.4 of the RDF Concepts and Abstract Syntax specification (RDF 1.0 Recommendation of February 10, 2004).
-
Constructor Details
-
URIUtil
public URIUtil()
-
-
Method Details
-
getLocalNameIndex
Finds the index of the first local name character in an (non-relative) URI. This index is determined by the following the following steps:- Find the first occurrence of the '#' character,
- If this fails, find the last occurrence of the '/' character,
- If this fails, find the last occurrence of the ':' character.
- Add 1 to the found index and return this value.
IllegalArgumentException
.- Parameters:
uri
- A URI string.- Returns:
- The index of the first local name character in the URI string. Note that this index does not reference an actual character if the algorithm determines that there is not local name. In that case, the return index is equal to the length of the URI string.
- Throws:
IllegalArgumentException
- If the supplied URI string doesn't contain any of the separator characters. Every legal (non-relative) URI contains at least one ':' character to seperate the scheme from the rest of the URI.
-
isCorrectURISplit
Checks whether the URI consisting of the specified namespace and local name has been split correctly according to the URI splitting rules specified inURI
.- Parameters:
namespace
- The URI's namespace, must not be null.localName
- The URI's local name, must not be null.- Returns:
- true if the specified URI has been correctly split into a namespace and local name, false otherwise.
- See Also:
-
isValidURIReference
Verifies that the supplied string is a valid RDF (1.0) URI reference, as defined in section 6.4 of the RDF Concepts and Abstract Syntax specification (RDF 1.0 Recommendation of February 10, 2004).An RDF URI reference is valid if it is a Unicode string that:
- does not contain any control characters ( #x00 - #x1F, #x7F-#x9F)
- and would produce a valid URI character sequence (per RFC2396 , section 2.1) representing an absolute URI with optional fragment identifier when subjected to the encoding described below
- encoding the Unicode string as UTF-8, giving a sequence of octet values.
- %-escaping octets that do not correspond to permitted US-ASCII characters.
- Parameters:
uriRef
- a string representing an RDF URI reference.- Returns:
true
iff the supplied string is a syntactically valid RDF URI reference,false
otherwise.- See Also:
-
isValidLocalName
Checks whether the specified name is allowed as the local name part of an IRI according to the SPARQL 1.1/Turtle 1.1 spec.- Parameters:
name
- the candidate local name- Returns:
- true if it is a local name
-